Skip to content

Commit

Permalink
Merge pull request #274 from TaloDev/develop
Browse files Browse the repository at this point in the history
Release 0.33.1
  • Loading branch information
tudddorrr authored Aug 2, 2024
2 parents 458991b + 1e9118b commit 56061a8
Show file tree
Hide file tree
Showing 21 changed files with 51 additions and 42 deletions.
24 changes: 12 additions & 12 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
"lint-staged": {
"*.{ts,js,tsx,jsx}": "eslint --fix"
},
"version": "0.33.0",
"version": "0.33.1",
"engines": {
"node": "20.x"
},
Expand Down
2 changes: 1 addition & 1 deletion src/api/deleteAPIKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import makeValidatedRequest from './makeValidatedRequest'

const deleteAPIKey = makeValidatedRequest(
(gameId: number, apiKeyId: number) => api.delete(`/games/${gameId}/api-keys/${apiKeyId}`),
z.object({}).strict()
z.literal('')
)

export default deleteAPIKey
2 changes: 1 addition & 1 deletion src/api/deleteFeedbackCategory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import makeValidatedRequest from './makeValidatedRequest'

const deleteFeedbackCategory = makeValidatedRequest(
(gameId: number, feedbackCategoryId: number) => api.delete(`/games/${gameId}/game-feedback/categories/${feedbackCategoryId}`),
z.object({}).strict()
z.literal('')
)

export default deleteFeedbackCategory
2 changes: 1 addition & 1 deletion src/api/deleteGroup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import makeValidatedRequest from './makeValidatedRequest'

const deleteGroup = makeValidatedRequest(
(gameId: number, groupId: string) => api.delete(`/games/${gameId}/player-groups/${groupId}`),
z.object({}).strict()
z.literal('')
)

export default deleteGroup
2 changes: 1 addition & 1 deletion src/api/deleteLeaderboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import makeValidatedRequest from './makeValidatedRequest'

const deleteLeaderboard = makeValidatedRequest(
(gameId: number, leaderboardId: number) => api.delete(`/games/${gameId}/leaderboards/${leaderboardId}`),
z.object({}).strict()
z.literal('')
)

export default deleteLeaderboard
2 changes: 1 addition & 1 deletion src/api/deleteStat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import makeValidatedRequest from './makeValidatedRequest'

const deleteStat = makeValidatedRequest(
(gameId: number, statId: number) => api.delete(`/games/${gameId}/game-stats/${statId}`),
z.object({}).strict()
z.literal('')
)

export default deleteStat
2 changes: 1 addition & 1 deletion src/api/disableIntegration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import makeValidatedRequest from './makeValidatedRequest'

const disableIntegration = makeValidatedRequest(
(gameId: number, integrationId: number) => api.delete(`/games/${gameId}/integrations/${integrationId}`),
z.object({}).strict()
z.literal('')
)

export default disableIntegration
2 changes: 1 addition & 1 deletion src/api/logout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import makeValidatedRequest from './makeValidatedRequest'

const logout = makeValidatedRequest(
() => api.post('/users/logout'),
z.object({}).strict()
z.literal('')
)

export default logout
2 changes: 1 addition & 1 deletion src/api/requestNewPassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import makeValidatedRequest from './makeValidatedRequest'

const requestNewPassword = makeValidatedRequest(
(email: string) => api.post('/public/users/forgot_password', { email }),
z.object({}).strict()
z.literal('')
)

export default requestNewPassword
2 changes: 1 addition & 1 deletion src/api/resetPassword.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import makeValidatedRequest from './makeValidatedRequest'

const resetPassword = makeValidatedRequest(
(token: string, password: string) => api.post('/public/users/reset_password', { token, password }),
z.object({}).strict()
z.literal('')
)

export default resetPassword
2 changes: 1 addition & 1 deletion src/api/syncLeaderboards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import makeValidatedRequest from './makeValidatedRequest'

const syncLeaderboards = makeValidatedRequest(
(gameId: number, integrationId: number) => api.post(`/games/${gameId}/integrations/${integrationId}/sync-leaderboards`),
z.object({}).strict()
z.literal('')
)

export default syncLeaderboards
2 changes: 1 addition & 1 deletion src/api/syncStats.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import makeValidatedRequest from './makeValidatedRequest'

const syncStats = makeValidatedRequest(
(gameId: number, integrationId: number) => api.post(`/games/${gameId}/integrations/${integrationId}/sync-stats`),
z.object({}).strict()
z.literal('')
)

export default syncStats
4 changes: 2 additions & 2 deletions src/api/useLeaderboardEntries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import makeValidatedGetRequest from './makeValidatedGetRequest'
import { z } from 'zod'
import { leaderboardEntrySchema } from '../entities/leaderboardEntry'

export default function useLeaderboardEntries(activeGame: Game, leaderboardId: number, page: number) {
export default function useLeaderboardEntries(activeGame: Game, leaderboardId: number | undefined, page: number) {
const fetcher = async ([url]: [string]) => {
const qs = new URLSearchParams({ page: String(page) }).toString()

Expand All @@ -19,7 +19,7 @@ export default function useLeaderboardEntries(activeGame: Game, leaderboardId: n
}

const { data, error, mutate } = useSWR(
[`/games/${activeGame.id}/leaderboards/${leaderboardId}/entries`, page],
leaderboardId ? [`/games/${activeGame.id}/leaderboards/${leaderboardId}/entries`, page] : null,
fetcher
)

Expand Down
4 changes: 2 additions & 2 deletions src/components/ActivityRenderer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ type ActivityRendererProps = {
items: {
createdAt: string
description: string
extra: Record<string, unknown>
extra?: Record<string, unknown>
}[]
}
}
Expand All @@ -28,7 +28,7 @@ export default function ActivityRenderer({ section }: ActivityRendererProps) {

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>
<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>
}
Expand Down
21 changes: 14 additions & 7 deletions src/components/charts/__tests__/ChartTooltip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@ describe('<ChartTooltip />', () => {
payload: {
count: 0,
name: 'Treasure discovered',
change: 0
change: 0,
date: 1612147200000
}
},
{
payload: {
count: 3,
name: 'Item looted',
change: 1
change: 1,
date: 1612147200000
}
}
]}
Expand All @@ -38,21 +40,24 @@ describe('<ChartTooltip />', () => {
payload: {
count: 0,
name: 'Treasure discovered',
change: 0
change: 0,
date: 1612147200000
}
},
{
payload: {
count: 2,
name: 'Treasure discovered',
change: 0
change: 0,
date: 1612147200000
}
},
{
payload: {
count: 3,
name: 'Item looted',
change: 0
change: 0,
date: 1612147200000
}
}
]}
Expand All @@ -72,14 +77,16 @@ describe('<ChartTooltip />', () => {
payload: {
count: 0,
name: 'Treasure discovered',
change: 0
change: 0,
date: 1612147200000
}
},
{
payload: {
count: 0,
name: 'Item looted',
change: 0
change: 0,
date: 1612147200000
}
}
]}
Expand Down
2 changes: 1 addition & 1 deletion src/entities/apiKey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const apiKeySchema = z.object({
gameId: z.number(),
createdBy: z.string(),
createdAt: z.string().datetime(),
lastUsedAt: z.string().datetime().nullable()
lastUsedAt: z.string().datetime().optional()
})

export type APIKey = z.infer<typeof apiKeySchema>
2 changes: 1 addition & 1 deletion src/entities/dataExport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const dataExportSchema = z.object({
createdBy: z.string(),
status: z.nativeEnum(DataExportStatus),
createdAt: z.string().datetime(),
failedAt: z.string().datetime().nullable()
failedAt: z.string().datetime().optional()
})

export type DataExport = z.infer<typeof dataExportSchema>
2 changes: 1 addition & 1 deletion src/entities/gameActivity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export const gameActivitySchema = z.object({
id: z.number(),
type: z.number(),
description: z.string(),
extra: z.record(z.unknown()),
extra: z.record(z.unknown()).optional(),
createdAt: z.string().datetime()
})

Expand Down
3 changes: 2 additions & 1 deletion src/entities/invite.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { z } from 'zod'
import { UserType } from './user'
import { organisationSchema } from './organisation'

export const inviteSchema = z.object({
id: z.number(),
email: z.string().email(),
organisationId: z.number(),
organisation: organisationSchema,
type: z.nativeEnum(UserType),
invitedBy: z.string(),
createdAt: z.string().datetime()
Expand Down
7 changes: 4 additions & 3 deletions src/pages/LeaderboardEntries.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,15 @@ import { useRecoilValue } from 'recoil'
import activeGameState, { SelectedActiveGame } from '../state/activeGameState'
import findLeaderboard from '../api/findLeaderboard'
import { LeaderboardEntry } from '../entities/leaderboardEntry'
import { Leaderboard } from '../entities/leaderboard'

export default function LeaderboardEntries() {
const location = useLocation()
const { internalName } = useParams()

const [isLoading, setLoading] = useState(!location.state?.leaderboard)
const activeGame = useRecoilValue(activeGameState) as SelectedActiveGame
const [leaderboard, setLeaderboard] = useState(location.state?.leaderboard)
const [leaderboard, setLeaderboard] = useState<Leaderboard | undefined>(location.state?.leaderboard)

const [page, setPage] = useState(0)
const { entries, count, itemsPerPage, loading, error: fetchError, mutate } = useLeaderboardEntries(activeGame, leaderboard?.id, page)
Expand Down Expand Up @@ -64,7 +65,7 @@ export default function LeaderboardEntries() {

const onHideToggle = async (entry: LeaderboardEntry) => {
try {
const { entry: updatedEntry } = await updateLeaderboardEntry(activeGame.id, leaderboard?.id, entry.id, { hidden: !entry.hidden })
const { entry: updatedEntry } = await updateLeaderboardEntry(activeGame.id, leaderboard!.id, entry.id, { hidden: !entry.hidden })

mutate((data) => {
if (!data) {
Expand Down Expand Up @@ -95,7 +96,7 @@ export default function LeaderboardEntries() {
return (
<Page
showBackButton
title={`${leaderboard.name} entries`}
title={leaderboard ? `${leaderboard.name} entries` : ''}
isLoading={loading}
>
{error && <ErrorMessage error={error} />}
Expand Down

0 comments on commit 56061a8

Please sign in to comment.