-
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 #85 from game-node-app/dev
Dev
- Loading branch information
Showing
33 changed files
with
1,137 additions
and
57 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from "react"; | ||
import getTimeSinceString from "@/util/getTimeSinceString"; | ||
import { Text } from "@mantine/core"; | ||
|
||
interface Props { | ||
createdAtDate: string | undefined; | ||
} | ||
|
||
const sevenDaysMs = 7 * 24 * 60 * 60 * 1000; | ||
|
||
const ActivityCreateDate = ({ createdAtDate }: Props) => { | ||
if (!createdAtDate) { | ||
return; | ||
} | ||
const createdAt = new Date(createdAtDate); | ||
const timeSince = getTimeSinceString(createdAt); | ||
const isSevenDaysOrOlder = | ||
new Date().getTime() - createdAt.getTime() >= sevenDaysMs; | ||
return ( | ||
<Text c={"dimmed"} fz={"sm"}> | ||
{isSevenDaysOrOlder | ||
? createdAt.toLocaleDateString() | ||
: `${timeSince} ago`} | ||
</Text> | ||
); | ||
}; | ||
|
||
export default ActivityCreateDate; |
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
11 changes: 11 additions & 0 deletions
11
src/components/connections/hooks/useAvailableConnections.ts
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 { ConnectionsService } from "@/wrapper/server"; | ||
|
||
export function useAvailableConnections() { | ||
return useQuery({ | ||
queryKey: ["connections", "available"], | ||
queryFn: async () => { | ||
return ConnectionsService.connectionsControllerFindAvailableConnections(); | ||
}, | ||
}); | ||
} |
14 changes: 14 additions & 0 deletions
14
src/components/connections/hooks/useOwnUserConnectionByType.ts
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,14 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { ConnectionsService } from "@/wrapper/server"; | ||
import { ConnectionCreateDto } from "@/wrapper/server"; | ||
import type = ConnectionCreateDto.type; | ||
|
||
export function useOwnUserConnectionByType(type: type) { | ||
return useQuery({ | ||
queryKey: ["connections", "own", type], | ||
queryFn: async () => { | ||
return ConnectionsService.connectionsControllerFindOwnByType(type); | ||
}, | ||
retry: 1, | ||
}); | ||
} |
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,15 @@ | ||
import { useQuery } from "@tanstack/react-query"; | ||
import { ConnectionsService } from "@/wrapper/server"; | ||
|
||
/** | ||
* Returns the connections persisted by the current logged-in user. | ||
*/ | ||
export function useOwnUserConnections() { | ||
return useQuery({ | ||
queryKey: ["connections", "own"], | ||
queryFn: async () => { | ||
return ConnectionsService.connectionsControllerFindOwn(); | ||
}, | ||
retry: 1, | ||
}); | ||
} |
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,30 @@ | ||
import React from "react"; | ||
import { ActionIcon, Group, Tooltip } from "@mantine/core"; | ||
import { IconSquareCheck, IconSquareCheckFilled } from "@tabler/icons-react"; | ||
|
||
interface Props { | ||
isAllGamesSelected: boolean; | ||
onSelectAll: () => void; | ||
} | ||
|
||
const GameSelectActions = ({ onSelectAll, isAllGamesSelected }: Props) => { | ||
return ( | ||
<Group wrap={"nowrap"} gap={"xs"}> | ||
<Tooltip label={"Select all items"}> | ||
<ActionIcon | ||
size={"lg"} | ||
variant={"transparent"} | ||
onClick={onSelectAll} | ||
> | ||
{isAllGamesSelected ? ( | ||
<IconSquareCheckFilled className={"w-full h-full"} /> | ||
) : ( | ||
<IconSquareCheck className={"w-full h-full"} /> | ||
)} | ||
</ActionIcon> | ||
</Tooltip> | ||
</Group> | ||
); | ||
}; | ||
|
||
export default GameSelectActions; |
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,16 @@ | ||
import React, { PropsWithChildren } from "react"; | ||
import GameSelectViewContent from "@/components/general/view/select/GameSelectViewContent"; | ||
import GameViewPagination from "@/components/general/view/game/GameViewPagination"; | ||
import GameSelectActions from "@/components/general/view/select/GameSelectActions"; | ||
|
||
interface GameSelectViewProps extends PropsWithChildren {} | ||
|
||
const GameSelectView = ({ children }: GameSelectViewProps) => { | ||
return <>{children}</>; | ||
}; | ||
|
||
GameSelectView.Content = GameSelectViewContent; | ||
GameSelectView.Pagination = GameViewPagination; | ||
GameSelectView.Actions = GameSelectActions; | ||
|
||
export default GameSelectView; |
60 changes: 60 additions & 0 deletions
60
src/components/general/view/select/GameSelectViewContent.tsx
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,60 @@ | ||
import React, { PropsWithChildren, useMemo } from "react"; | ||
import { TGameOrSearchGame } from "@/components/game/util/types"; | ||
import { SimpleGrid, SimpleGridProps } from "@mantine/core"; | ||
import GameSelectViewFigure, { | ||
GameSelectViewFigureProps, | ||
} from "@/components/general/view/select/GameSelectViewFigure"; | ||
|
||
type SelectedProps = Pick< | ||
GameSelectViewFigureProps, | ||
"onSelected" | "onDeselected" | "checkIsSelected" | ||
>; | ||
|
||
interface Props extends PropsWithChildren<SimpleGridProps & SelectedProps> { | ||
items: TGameOrSearchGame[]; | ||
} | ||
|
||
const GameSelectViewContent = ({ | ||
items, | ||
children, | ||
checkIsSelected, | ||
onSelected, | ||
onDeselected, | ||
...others | ||
}: Props) => { | ||
const columns = useMemo(() => { | ||
if (items == undefined || items.length === 0) { | ||
return null; | ||
} | ||
|
||
return items.map((game) => { | ||
return ( | ||
<GameSelectViewFigure | ||
key={game.id!} | ||
checkIsSelected={checkIsSelected} | ||
onSelected={onSelected} | ||
onDeselected={onDeselected} | ||
game={game} | ||
/> | ||
); | ||
}); | ||
}, [checkIsSelected, items, onDeselected, onSelected]); | ||
|
||
return ( | ||
<SimpleGrid | ||
id={"game-view-content"} | ||
cols={{ | ||
base: 2, | ||
lg: 5, | ||
}} | ||
w={"100%"} | ||
h={"100%"} | ||
{...others} | ||
> | ||
{columns} | ||
{children} | ||
</SimpleGrid> | ||
); | ||
}; | ||
|
||
export default GameSelectViewContent; |
Oops, something went wrong.