Skip to content

Commit

Permalink
setup files and systems
Browse files Browse the repository at this point in the history
  • Loading branch information
varCepheid committed Nov 9, 2023
1 parent 60f0753 commit 4bab1ea
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/components/match-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import Card from '@/components/card'
import { css } from 'linaria'
import { memo } from '@/utils/memo'
import clsx from 'clsx'
import IconButton from './icon-button'
import { mdiPencil } from '@mdi/js'

interface MatchCardProps {
match: {
Expand All @@ -17,6 +19,7 @@ interface MatchCardProps {
eventKey: string
link?: boolean
class?: string
isAdmin?: boolean
}

const matchCardStyle = css`
Expand Down Expand Up @@ -83,7 +86,7 @@ const blueStyle = css`
`

export const MatchDetailsCard = memo(
({ match, eventKey, link, class: className }: MatchCardProps) => {
({ match, eventKey, link, class: className, isAdmin }: MatchCardProps) => {
const matchName = formatMatchKey(match.key)

const createTeamLinks = (teams: string[]) =>
Expand All @@ -110,6 +113,12 @@ export const MatchDetailsCard = memo(
{matchName.num && (
<div class={matchNumStyle}>{`Match ${matchName.num}`}</div>
)}
{isAdmin && (
<IconButton
icon={mdiPencil}
href={`/events/${eventKey}/match-editor`}
/>
)}
</div>
{match.time && (
<time dateTime={match.time.toISOString()}>
Expand Down
8 changes: 8 additions & 0 deletions src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,14 @@ const routes = [
path: '/events/:eventKey/matches/:matchKey/scout',
component: () => import('./routes/scout'),
},
{
path: '/events/:eventKey/match-creator',
component: () => import('./routes/match-creator'),
},
{
path: '/events/:eventKey/match-editor',
component: () => import('./routes/match-editor'),
},
{
path: '/events/:eventKey/teams/:teamNum',
component: () => import('./routes/event-team'),
Expand Down
10 changes: 10 additions & 0 deletions src/routes/event.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Heading } from '@/components/heading'
import { EventMatches } from '@/components/event-matches'
import Loader from '@/components/loader'
import { useEventMatches } from '@/cache/event-matches/use'
import { useJWT } from '@/jwt'

interface Props {
eventKey: string
Expand Down Expand Up @@ -52,6 +53,9 @@ const Event = ({ eventKey }: Props) => {
const matches = useEventMatches(eventKey)
const eventInfo = useEventInfo(eventKey)
const newestIncompleteMatch = matches && nextIncompleteMatch(matches)
const { jwt } = useJWT()
const isAdmin =
jwt && (jwt.peregrineRoles.isAdmin || jwt.peregrineRoles.isSuperAdmin)

return (
<Page
Expand All @@ -65,6 +69,11 @@ const Event = ({ eventKey }: Props) => {
</Heading>
{eventInfo && <EventInfoCard event={eventInfo} />}
<Button href={`/events/${eventKey}/analysis`}>Analysis</Button>
{isAdmin && (
<Button href={`/events/${eventKey}/match-creator`}>
Create New Match
</Button>
)}
</div>

<div class={sectionStyle}>
Expand All @@ -77,6 +86,7 @@ const Event = ({ eventKey }: Props) => {
match={newestIncompleteMatch}
eventKey={eventKey}
link
isAdmin
/>
)}
{matches ? (
Expand Down
9 changes: 9 additions & 0 deletions src/routes/match-creator.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Page from '@/components/page'

interface Props {
eventKey: string
}

export const MatchCreator = ({ eventKey }: Props) => {
return <Page />
}
9 changes: 9 additions & 0 deletions src/routes/match-editor.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Page from '@/components/page'

interface Props {
eventKey: string
}

export const MatchEditor = ({ eventKey }: Props) => {
return <Page />
}

0 comments on commit 4bab1ea

Please sign in to comment.