Skip to content

Commit 4bab1ea

Browse files
committed
setup files and systems
1 parent 60f0753 commit 4bab1ea

File tree

5 files changed

+46
-1
lines changed

5 files changed

+46
-1
lines changed

src/components/match-card.tsx

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ import Card from '@/components/card'
55
import { css } from 'linaria'
66
import { memo } from '@/utils/memo'
77
import clsx from 'clsx'
8+
import IconButton from './icon-button'
9+
import { mdiPencil } from '@mdi/js'
810

911
interface MatchCardProps {
1012
match: {
@@ -17,6 +19,7 @@ interface MatchCardProps {
1719
eventKey: string
1820
link?: boolean
1921
class?: string
22+
isAdmin?: boolean
2023
}
2124

2225
const matchCardStyle = css`
@@ -83,7 +86,7 @@ const blueStyle = css`
8386
`
8487

8588
export const MatchDetailsCard = memo(
86-
({ match, eventKey, link, class: className }: MatchCardProps) => {
89+
({ match, eventKey, link, class: className, isAdmin }: MatchCardProps) => {
8790
const matchName = formatMatchKey(match.key)
8891

8992
const createTeamLinks = (teams: string[]) =>
@@ -110,6 +113,12 @@ export const MatchDetailsCard = memo(
110113
{matchName.num && (
111114
<div class={matchNumStyle}>{`Match ${matchName.num}`}</div>
112115
)}
116+
{isAdmin && (
117+
<IconButton
118+
icon={mdiPencil}
119+
href={`/events/${eventKey}/match-editor`}
120+
/>
121+
)}
113122
</div>
114123
{match.time && (
115124
<time dateTime={match.time.toISOString()}>

src/routes.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,14 @@ const routes = [
1919
path: '/events/:eventKey/matches/:matchKey/scout',
2020
component: () => import('./routes/scout'),
2121
},
22+
{
23+
path: '/events/:eventKey/match-creator',
24+
component: () => import('./routes/match-creator'),
25+
},
26+
{
27+
path: '/events/:eventKey/match-editor',
28+
component: () => import('./routes/match-editor'),
29+
},
2230
{
2331
path: '/events/:eventKey/teams/:teamNum',
2432
component: () => import('./routes/event-team'),

src/routes/event.tsx

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { Heading } from '@/components/heading'
99
import { EventMatches } from '@/components/event-matches'
1010
import Loader from '@/components/loader'
1111
import { useEventMatches } from '@/cache/event-matches/use'
12+
import { useJWT } from '@/jwt'
1213

1314
interface Props {
1415
eventKey: string
@@ -52,6 +53,9 @@ const Event = ({ eventKey }: Props) => {
5253
const matches = useEventMatches(eventKey)
5354
const eventInfo = useEventInfo(eventKey)
5455
const newestIncompleteMatch = matches && nextIncompleteMatch(matches)
56+
const { jwt } = useJWT()
57+
const isAdmin =
58+
jwt && (jwt.peregrineRoles.isAdmin || jwt.peregrineRoles.isSuperAdmin)
5559

5660
return (
5761
<Page
@@ -65,6 +69,11 @@ const Event = ({ eventKey }: Props) => {
6569
</Heading>
6670
{eventInfo && <EventInfoCard event={eventInfo} />}
6771
<Button href={`/events/${eventKey}/analysis`}>Analysis</Button>
72+
{isAdmin && (
73+
<Button href={`/events/${eventKey}/match-creator`}>
74+
Create New Match
75+
</Button>
76+
)}
6877
</div>
6978

7079
<div class={sectionStyle}>
@@ -77,6 +86,7 @@ const Event = ({ eventKey }: Props) => {
7786
match={newestIncompleteMatch}
7887
eventKey={eventKey}
7988
link
89+
isAdmin
8090
/>
8191
)}
8292
{matches ? (

src/routes/match-creator.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Page from '@/components/page'
2+
3+
interface Props {
4+
eventKey: string
5+
}
6+
7+
export const MatchCreator = ({ eventKey }: Props) => {
8+
return <Page />
9+
}

src/routes/match-editor.tsx

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import Page from '@/components/page'
2+
3+
interface Props {
4+
eventKey: string
5+
}
6+
7+
export const MatchEditor = ({ eventKey }: Props) => {
8+
return <Page />
9+
}

0 commit comments

Comments
 (0)