-
-
Notifications
You must be signed in to change notification settings - Fork 1
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 #269 from TaloDev/develop
Release 0.33.0
- Loading branch information
Showing
17 changed files
with
179 additions
and
81 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Binary file not shown.
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,27 @@ | ||
import useSWR from 'swr' | ||
import buildError from '../utils/buildError' | ||
import { Game } from '../entities/game' | ||
import makeValidatedGetRequest from './makeValidatedGetRequest' | ||
import { z } from 'zod' | ||
import { playerAuthActivitySchema } from '../entities/playerAuthActivity' | ||
|
||
export default function usePlayerAuthActivities(activeGame: Game, playerId: string) { | ||
const fetcher = async ([url]: [string]) => { | ||
const res = await makeValidatedGetRequest(url, z.object({ | ||
activities: z.array(playerAuthActivitySchema) | ||
})) | ||
|
||
return res | ||
} | ||
|
||
const { data, error } = useSWR( | ||
[`/games/${activeGame.id}/players/${playerId}/auth-activities`], | ||
fetcher | ||
) | ||
|
||
return { | ||
activities: data?.activities ?? [], | ||
loading: !data && !error, | ||
error: error && buildError(error) | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 SecondaryTitle from './SecondaryTitle' | ||
import { format } from 'date-fns' | ||
|
||
type ActivityRendererProps = { | ||
section: { | ||
date: Date | ||
items: { | ||
createdAt: string | ||
description: string | ||
extra: Record<string, unknown> | ||
}[] | ||
} | ||
} | ||
|
||
export default function ActivityRenderer({ section }: ActivityRendererProps) { | ||
return ( | ||
<div className='space-y-4'> | ||
<SecondaryTitle className='text-lg'>{format(section.date, 'dd MMM Y')}</SecondaryTitle> | ||
|
||
{section.items.map((item, itemIdx) => ( | ||
<div key={itemIdx} className='border-t-2 border-gray-700 pt-4'> | ||
<p><span className='text-sm mr-2 text-indigo-300'>{format(new Date(item.createdAt), 'HH:mm')}</span> {item.description}</p> | ||
|
||
{item.extra && | ||
<div className='-ml-2 flex flex-wrap'> | ||
{Object.keys(item.extra).sort((a, b) => { | ||
if (b === 'Player') return 1 | ||
|
||
return a.localeCompare(b) | ||
}).map((key) => ( | ||
<code key={key} className='bg-gray-900 rounded p-2 text-xs md:text-sm ml-2 mt-2'>{key} = {String(item.extra[key])}</code> | ||
))} | ||
</div> | ||
} | ||
</div> | ||
))} | ||
</div> | ||
) | ||
} |
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,11 @@ | ||
import { z } from 'zod' | ||
|
||
export const playerAuthActivitySchema = z.object({ | ||
id: z.number(), | ||
type: z.number(), | ||
description: z.string(), | ||
extra: z.record(z.unknown()), | ||
createdAt: z.string().datetime() | ||
}) | ||
|
||
export type PlayerAuthActivity = z.infer<typeof playerAuthActivitySchema> |
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,7 +1,5 @@ | ||
import EventsOverview from '../components/events/EventsOverview' | ||
|
||
const Events = () => { | ||
export default function Events() { | ||
return <EventsOverview /> | ||
} | ||
|
||
export default Events |
Oops, something went wrong.