-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #76 from infinite-loop-factory/feature/reaction-sp…
…eed-test-record reaction-speed-test 기록 페이지 supabase 연동
- Loading branch information
Showing
12 changed files
with
248 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./user"; | ||
export * from "./records"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import { getCurrentUser } from "@/services"; | ||
import { supabase } from "@/utils/supabase"; | ||
|
||
export const insertRecord = async (result_value: number) => { | ||
const user = await getCurrentUser(); | ||
|
||
if (!user) { | ||
throw new Error("User not authenticated"); | ||
} | ||
|
||
const { data, error } = await supabase | ||
.from("records") | ||
.insert([ | ||
{ | ||
user_id: user.id, | ||
result_value, | ||
unit: "ms", | ||
}, | ||
]) | ||
.select() | ||
.single(); | ||
|
||
if (error) throw error; | ||
return data; | ||
}; | ||
|
||
export const getRecords = async () => { | ||
const user = await getCurrentUser(); | ||
|
||
if (!user) { | ||
throw new Error("로그인이 필요합니다"); | ||
} | ||
|
||
const { data, error } = await supabase | ||
.from("records") | ||
.select("id, created_at, result_value, unit") | ||
.eq("user_id", user.id) | ||
.order("created_at", { ascending: false }); | ||
|
||
if (error) throw error; | ||
|
||
return data; | ||
}; |
Oops, something went wrong.