-
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.
refactor: update types on the client
- Loading branch information
Showing
30 changed files
with
177 additions
and
158 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
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,4 +1,4 @@ | ||
import { cn } from "~/utils"; | ||
import { cn } from "~/utils/handlers"; | ||
|
||
interface NoticeProps { | ||
text: string; | ||
|
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
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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export * from "./Button"; | ||
export * from "./Input"; |
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 |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { useContext } from "react"; | ||
|
||
import { AppContext, AuthContext, MonthContext } from "~/context"; | ||
|
||
// App Context | ||
export function useAppContext() { | ||
const context = useContext(AppContext); | ||
|
||
if (!context) { | ||
throw new Error( | ||
"No context found. App's context must be used within a ContextProvider.", | ||
); | ||
} | ||
return context; | ||
} | ||
|
||
// Auth Context | ||
export function useAuthContext() { | ||
const context = useContext(AuthContext); | ||
|
||
if (!context) { | ||
throw new Error( | ||
"No context found. App's context must be used within a AuthContextProvider.", | ||
); | ||
} | ||
return context; | ||
} | ||
|
||
// Month Context | ||
export function useMonthContext() { | ||
const context = useContext(MonthContext); | ||
|
||
if (!context) { | ||
throw new Error( | ||
"No context found. Month context must be used within a ContextProvider.", | ||
); | ||
} | ||
return context; | ||
} |
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,49 +1,3 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
|
||
import { getEntries } from "~/api/entries"; | ||
import { getUserTasks } from "~/api/tasks"; | ||
import { getUserYear } from "~/api/users"; | ||
|
||
export * from "./useAppContext"; | ||
export * from "./useMonthContext"; | ||
export * from "./context"; | ||
export * from "./queries"; | ||
export * from "./useMonthRating"; | ||
export * from "./useAuthContext"; | ||
|
||
// Year | ||
export function useUserYear(year: number) { | ||
const { data, isLoading, isError } = useQuery({ | ||
queryKey: ["year"], | ||
queryFn: () => getUserYear(year), | ||
}); | ||
|
||
return { data, isLoading, isError }; | ||
} | ||
|
||
// Tasks | ||
export function useTasks() { | ||
const { data, isLoading, isError } = useQuery({ | ||
queryKey: ["tasks"], | ||
queryFn: () => getUserTasks(), | ||
}); | ||
|
||
return { data, isLoading, isError }; | ||
} | ||
|
||
// Entries | ||
interface UseEntriesProps { | ||
taskId?: string; | ||
year: number; | ||
month: number; | ||
day?: number; | ||
} | ||
|
||
export function useEntries(props: UseEntriesProps) { | ||
const { taskId, year, month, day } = props; | ||
|
||
const { data, isLoading, isError } = useQuery({ | ||
queryKey: ["entires"], | ||
queryFn: () => getEntries({ taskId, year, month, day }), | ||
}); | ||
|
||
return { data, isLoading, isError }; | ||
} |
Oops, something went wrong.