-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "Chore: don't use layout with data"
This reverts commit caa5601.
- Loading branch information
1 parent
caa5601
commit 4d35f61
Showing
15 changed files
with
158 additions
and
178 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
75 changes: 0 additions & 75 deletions
75
packages/web-main/src/routes/_auth/_global/player.$playerId.economy.tsx
This file was deleted.
Oops, something went wrong.
44 changes: 0 additions & 44 deletions
44
packages/web-main/src/routes/_auth/_global/player.$playerId.events.tsx
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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
47 changes: 47 additions & 0 deletions
47
packages/web-main/src/routes/_auth/_global/player.$playerId/economy.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,47 @@ | ||
import { FC } from 'react'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { createFileRoute } from '@tanstack/react-router'; | ||
import { Currency } from './-PlayerCurrency'; | ||
import { GameServerSelect } from 'components/selects'; | ||
import { useForm } from 'react-hook-form'; | ||
import { playerQueryOptions } from 'queries/player'; | ||
import { playerOnGameServerQueryOptions } from 'queries/pog'; | ||
|
||
export const Route = createFileRoute('/_auth/_global/player/$playerId/economy')({ | ||
component: Component, | ||
loader: async ({ context, params }) => context.queryClient.ensureQueryData(playerQueryOptions(params.playerId)), | ||
}); | ||
|
||
type FormFields = { | ||
gameServerId: string | undefined; | ||
}; | ||
|
||
function Component() { | ||
const { playerId } = Route.useParams(); | ||
|
||
const { control, watch } = useForm<FormFields>({ | ||
mode: 'onChange', | ||
}); | ||
const gameServerId = watch('gameServerId'); | ||
|
||
return ( | ||
<> | ||
<GameServerSelect control={control} name="gameServerId" /> | ||
{gameServerId && <CurrencyWrapper playerId={playerId} gameServerId={gameServerId} />} | ||
</> | ||
); | ||
} | ||
|
||
const CurrencyWrapper: FC<{ playerId: string; gameServerId: string }> = ({ playerId, gameServerId }) => { | ||
const { data, isPending } = useQuery(playerOnGameServerQueryOptions(gameServerId, playerId)); | ||
|
||
if (isPending) { | ||
return <div>Loading currency data</div>; | ||
} | ||
|
||
if (!data) { | ||
return <div>could not load data</div>; | ||
} | ||
|
||
return <Currency playerId={playerId} gameServerId={gameServerId} currency={data.currency} />; | ||
}; |
18 changes: 18 additions & 0 deletions
18
packages/web-main/src/routes/_auth/_global/player.$playerId/events.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,18 @@ | ||
import { useTheme } from '@takaro/lib-components'; | ||
import { EventFeedWidget } from 'components/events/EventFeedWidget'; | ||
import { Section } from './-style'; | ||
import { createFileRoute } from '@tanstack/react-router'; | ||
|
||
export const Route = createFileRoute('/_auth/_global/player/$playerId/events')({ | ||
component: Component, | ||
}); | ||
|
||
function Component() { | ||
const { playerId } = Route.useParams(); | ||
const theme = useTheme(); | ||
return ( | ||
<Section style={{ height: '100%', overflowY: 'auto', paddingRight: theme.spacing[2] }}> | ||
<EventFeedWidget query={{ filters: { playerId: [playerId] } }} /> | ||
</Section> | ||
); | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/web-main/src/routes/_auth/_global/player.$playerId/index.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,7 @@ | ||
import { createFileRoute } from '@tanstack/react-router'; | ||
|
||
export const Route = createFileRoute('/_auth/_global/player/$playerId/')({ | ||
beforeLoad: ({ navigate, params }) => { | ||
navigate({ to: '/player/$playerId/info', params: { playerId: params.playerId } }); | ||
}, | ||
}); |
71 changes: 28 additions & 43 deletions
71
...s/_auth/_global/player.$playerId.info.tsx → ...s/_auth/_global/player.$playerId/info.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
Oops, something went wrong.