-
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.
- Loading branch information
Showing
46 changed files
with
1,052 additions
and
1,071 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,14 @@ | ||
import { LoadingSkeleton } from "../components/LoadingSkeleton"; | ||
import { useCardsContext } from "../providers/dataproviders/cardsProvider"; | ||
import { useCards } from "../hooks/useCard"; | ||
import { CardsEmpty } from "./CardsEmpty"; | ||
import { CardsTable } from "./CardsTable"; | ||
|
||
export const Cards = () => { | ||
const { data: cards, loading } = useCardsContext(); | ||
const { data: cards, isLoading } = useCards(); | ||
|
||
return ( | ||
<LoadingSkeleton loading={loading}> | ||
{cards.length ? <CardsTable /> : <CardsEmpty />} | ||
<LoadingSkeleton loading={isLoading}> | ||
{cards?.length ? <CardsTable /> : <CardsEmpty />} | ||
</LoadingSkeleton> | ||
); | ||
}; |
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,20 @@ | ||
import { useMutation, useQuery } from "@tanstack/react-query"; | ||
import { Card, CardJSON, convertCardJSON } from "../types/cards"; | ||
import { getApi, patchApi } from "../util/fetch"; | ||
|
||
const ENDPOINT = "cards"; | ||
|
||
export const useCards = () => | ||
useQuery<Card[]>({ | ||
queryKey: ["cards"], | ||
queryFn: () => getApi<Card[], CardJSON[]>(ENDPOINT, convertCardJSON), | ||
}); | ||
|
||
export const usePatchCards = () => { | ||
return useMutation({ | ||
mutationFn: (args: { id: number; newName: string }) => | ||
patchApi(`${ENDPOINT}/${args.id}`, { | ||
name: args.newName, | ||
}), | ||
}); | ||
}; |
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,17 @@ | ||
import { useMutation, useQuery } from "@tanstack/react-query"; | ||
import { convertDayJSON, Day, DayJSON } from "../types/days"; | ||
import { deleteAPI, getApi } from "../util/fetch"; | ||
|
||
const ENDPOINT = "admin/days"; | ||
|
||
export const useDays = () => | ||
useQuery({ | ||
queryKey: ["days"], | ||
queryFn: () => getApi<Day[], DayJSON[]>(ENDPOINT, convertDayJSON), | ||
}); | ||
|
||
export const useDeleteDay = () => { | ||
return useMutation({ | ||
mutationFn: (id: number) => deleteAPI(`${ENDPOINT}/${id}`), | ||
}); | ||
}; |
This file was deleted.
Oops, something went wrong.
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,19 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { getApi } from "../util/fetch"; | ||
import { | ||
convertLeaderboardItemJSON, | ||
LeaderboardItem, | ||
LeaderboardItemJSON, | ||
} from "../types/leaderboard"; | ||
|
||
const ENDPOINT = "leaderboard"; | ||
|
||
export const useLeaderboardItems = () => | ||
useQuery({ | ||
queryKey: ["leaderboard"], | ||
queryFn: () => | ||
getApi<LeaderboardItem[], LeaderboardItemJSON[]>( | ||
ENDPOINT, | ||
convertLeaderboardItemJSON, | ||
), | ||
}); |
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,11 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { getApi } from "../util/fetch"; | ||
import { convertScanJSON, Scan, ScanJSON } from "../types/scans"; | ||
|
||
const ENDPOINT = "scans"; | ||
|
||
export const useScans = () => | ||
useQuery({ | ||
queryKey: ["scans"], | ||
queryFn: () => getApi<Scan[], ScanJSON[]>(ENDPOINT, convertScanJSON), | ||
}); |
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,26 @@ | ||
import { useMutation, useQuery } from "@tanstack/react-query"; | ||
import { getApi, patchApi } from "../util/fetch"; | ||
import { converSettingsJSON, Settings, SettingsJSON } from "../types/settings"; | ||
|
||
const ENDPOINT = "settings"; | ||
|
||
export const useSettings = () => | ||
useQuery({ | ||
queryKey: ["settings"], | ||
queryFn: () => getApi<Settings, SettingsJSON>(ENDPOINT, converSettingsJSON), | ||
}); | ||
|
||
export const usePatchSettings = () => { | ||
return useMutation({ | ||
mutationFn: (args: { | ||
scanInOut: boolean; | ||
leaderboard: boolean; | ||
public: boolean; | ||
}) => | ||
patchApi(ENDPOINT, { | ||
scanInOut: args.scanInOut, | ||
leaderboard: args.leaderboard, | ||
public: args.public, | ||
}), | ||
}); | ||
}; |
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
Oops, something went wrong.