Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rating accumulation backend #4

Merged
merged 10 commits into from
Mar 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
134 changes: 59 additions & 75 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
"axios": "^1.3.4",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.0",
"durable-functions": "^3.0.0",
"env-var": "^7.3.0",
"framer-motion": "^10.8.5",
"js-cookie": "^3.0.1",
Expand Down
9 changes: 9 additions & 0 deletions packages/client/src/api/hooks/alertHooks.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { Alert, PontozoError } from '@pontozo/common'
import { useQuery } from '@tanstack/react-query'
import { functionAxios } from 'src/util/axiosConfig'

export const useFetchAlerts = () => {
return useQuery<Alert[], PontozoError>(['fetchAlerts'], async () => (await functionAxios.get(`/alerts`)).data, {
retry: false,
})
}
36 changes: 35 additions & 1 deletion packages/client/src/pages/adminIndex/AdminIndex.page.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,19 @@
import { Heading, Text } from '@chakra-ui/react'
import { Alert, AlertDescription, AlertIcon, AlertTitle, Heading, HStack, Text, VStack } from '@chakra-ui/react'
import { useFetchAlerts } from 'src/api/hooks/alertHooks'
import { HelmetTitle } from 'src/components/commons/HelmetTitle'
import { LoadingSpinner } from 'src/components/commons/LoadingSpinner'
import { NavigateWithError } from 'src/components/commons/NavigateWithError'
import { alertLevelToChakraStatus } from 'src/util/enumHelpers'
import { PATHS } from 'src/util/paths'

export const AdminIndex = () => {
const { data, isLoading, error } = useFetchAlerts()
if (isLoading) {
return <LoadingSpinner />
}
if (error) {
return <NavigateWithError error={error} to={PATHS.INDEX} />
}
return (
<>
<HelmetTitle title="Pontoz-O Admin" />
Expand All @@ -14,6 +26,28 @@ export const AdminIndex = () => {
fogást arra, hogy a haság és az olások elmenek amustól. A fetles ezer empőzs kasolta, hogy a szegséges ülöntés dikás karázsálnia az
ehető haságot.
</Text>
<Heading fontSize={30} mt={5}>
Figyelmeztetések
</Heading>
<VStack mt={5}>
{data.length > 0 ? (
data.map((a) => (
<Alert variant="left-accent" status={alertLevelToChakraStatus[a.level]} justifyContent="space-between">
<HStack gap={1}>
<AlertIcon />
<AlertTitle>{a.description}</AlertTitle>
</HStack>
<AlertDescription>
{new Date(a.timestamp).toLocaleDateString('hu')} {new Date(a.timestamp).toLocaleTimeString('hu')}
</AlertDescription>
</Alert>
))
) : (
<Text fontStyle="italic" textAlign="center">
Nincs egy figyelmeztetés se az elmúlt 14 napból!
</Text>
)}
</VStack>
</>
)
}
4 changes: 1 addition & 3 deletions packages/client/src/pages/error/error.page.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
import { Button, Heading, Text, VStack } from '@chakra-ui/react'
import { Link } from 'react-router-dom'
import { HelmetTitle } from 'src/components/commons/HelmetTitle'
import { PATHS } from 'src/util/paths'

export const ErrorPage = () => {
return (
<VStack w="100%" alignItems="center" my={2}>
<HelmetTitle title="Pontoz-O | Hiba" />
<Heading>Ismeretlen hiba</Heading>
<Text>{'Kérlek próbáld újra, és ha a hiba nem hárul el, jelezd a fejlesztőnek a feketesamu{kukac}gmail{pont}hu címen!'}</Text>
<Button as={Link} to={PATHS.INDEX} colorScheme="brand">
<Button onClick={() => window.location.reload()} colorScheme="brand">
Újrapróbálom
</Button>
</VStack>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const SubmitRatingModal = ({ variant, color, colorScheme }: Props) => {
<ModalBody textAlign="justify">
<Text mb={5}>
Köszönjük, hogy értékelted a versenyt! Az értékélest a 'Küldés' gombbal tudod véglegesíteni, ezután már nem fogod tudni
szerkeszteni. Ha szeretnél még szöveges formában visszajelzést küldeni a szervezőknek, azt megteheted az alábbi
szerkeszteni. Ha szeretnél még szöveges formában (névtelen) visszajelzést küldeni a szervezőknek, azt megteheted az alábbi
szövegdobozban.
</Text>
<FormControl>
Expand Down
12 changes: 11 additions & 1 deletion packages/client/src/util/enumHelpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EventRank, RatingRole, RatingStatus, UserRole } from '@pontozo/common'
import { AlertLevel, EventRank, RatingRole, RatingStatus, UserRole } from '@pontozo/common'

type RoleDict = {
[K in RatingRole]: string
Expand Down Expand Up @@ -80,3 +80,13 @@ export const rankColor: RankDict = {
[EventRank.FEATURED]: 'red',
[EventRank.NONE]: 'gray',
}

type AlertDict = {
[K in AlertLevel]: 'info' | 'warning' | 'error'
}

export const alertLevelToChakraStatus: AlertDict = {
[AlertLevel.INFO]: 'info',
[AlertLevel.WARN]: 'warning',
[AlertLevel.ERROR]: 'error',
}
Loading
Loading