diff --git a/frontend/src/components/MatchMapCard.tsx b/frontend/src/components/MatchMapCard.tsx index c6214dd..f952b94 100644 --- a/frontend/src/components/MatchMapCard.tsx +++ b/frontend/src/components/MatchMapCard.tsx @@ -1,4 +1,4 @@ -import { Component } from 'solid-js'; +import { Component, createSignal } from 'solid-js'; import { IMatchMap, IMatchMapUpdateDto, @@ -50,6 +50,21 @@ export const MatchMapCard: Component<{ _switchTeamInternals: true, }); }; + const [roundBackupFiles, setRoundBackupFiles] = createSignal(); + const loadRoundBackupFiles = async () => { + const resp = await fetcher<{ latestFiles: string[]; total: number }>( + 'GET', + `/api/matches/${props.match.id}/server/round_backups?count=15` + ); + if (resp) { + setRoundBackupFiles(resp.latestFiles); + } + }; + const openRoundBackup = () => { + loadRoundBackupFiles(); + modalRef?.showModal(); + }; + let modalRef: HTMLDialogElement | undefined; const teamA = () => { @@ -78,7 +93,7 @@ export const MatchMapCard: Component<{ [t('change map name'), changeMapName], [t('change map state'), changeMapState], props.match.currentMap === props.mapIndex - ? [t('load round backup'), () => modalRef?.showModal()] + ? [t('load round backup'), openRoundBackup] : [t('switch to this map'), mustConfirm(loadThisMap)], [t('switch team internals'), switchTeamInternals], ]} @@ -100,10 +115,14 @@ export const MatchMapCard: Component<{

{t(props.map.state)}

- + setRoundBackupFiles(undefined)}>

{t('Load Round Backup')}

- modalRef?.close()} /> + modalRef?.close()} + roundBackupFiles={roundBackupFiles()} + />
diff --git a/frontend/src/components/Modal.tsx b/frontend/src/components/Modal.tsx index 4cfceec..fdd1a3f 100644 --- a/frontend/src/components/Modal.tsx +++ b/frontend/src/components/Modal.tsx @@ -1,12 +1,14 @@ -import { Component, JSX } from 'solid-js'; +import { Component, ComponentProps, JSX, splitProps } from 'solid-js'; import { t } from '../utils/locale'; -export const Modal: Component<{ - children: JSX.Element; - ref?: HTMLDialogElement; -}> = (props) => { +export const Modal: Component< + ComponentProps<'dialog'> & { + children: JSX.Element; + } +> = (props) => { + const [local, others] = splitProps(props, ['children']); return ( - +