diff --git a/GZCTF/ClientApp/src/components/HintList.tsx b/GZCTF/ClientApp/src/components/HintList.tsx new file mode 100644 index 000000000..e75238484 --- /dev/null +++ b/GZCTF/ClientApp/src/components/HintList.tsx @@ -0,0 +1,73 @@ +import { FC } from 'react' +import { + ScrollArea, + Input, + Stack, + TextInput, + TextInputProps, + Button, + ActionIcon, +} from '@mantine/core' +import { mdiClose, mdiPlus } from '@mdi/js' +import { Icon } from '@mdi/react' + +interface HintListProps extends TextInputProps { + hints: string[] + onChangeHint: (value: string[]) => void + disabled?: boolean + height?: number +} + +export const HintList: FC = (props) => { + const { hints, onChangeHint, disabled, height, ...rest } = props + + const hintdict = hints.map((hint, key) => ({ hint, key })) + + const handleChange = (key: number, value: string) => { + const newHints = [...hintdict] + newHints[key].hint = value + onChangeHint(newHints.map((h) => h.hint)) + } + + const handleAdd = () => { + const newHints = [...hintdict, { hint: '', key: hintdict.length }] + onChangeHint(newHints.map((h) => h.hint)) + } + + const handleDelete = (key: number) => { + const newHints = hintdict.filter((h) => h.key !== key) + onChangeHint(newHints.map((h) => h.hint)) + } + + return ( + + + + {hintdict.map((kv) => ( + handleChange(kv.key, e.target.value)} + rightSection={ + handleDelete(kv.key)}> + + + } + /> + ))} + + + + + ) +} + +export default HintList diff --git a/GZCTF/ClientApp/src/pages/admin/games/[id]/challenges/[chalId]/Index.tsx b/GZCTF/ClientApp/src/pages/admin/games/[id]/challenges/[chalId]/Index.tsx index 6bc9c57fa..5c56f31f1 100644 --- a/GZCTF/ClientApp/src/pages/admin/games/[id]/challenges/[chalId]/Index.tsx +++ b/GZCTF/ClientApp/src/pages/admin/games/[id]/challenges/[chalId]/Index.tsx @@ -36,6 +36,7 @@ import { ChallengeTagLabelMap, } from '@Utils/ChallengeItem' import api, { ChallengeUpdateModel, ChallengeTag, ChallengeType } from '@Api' +import HintList from '@Components/HintList' const GameChallengeEdit: FC = () => { const navigate = useNavigate() @@ -260,8 +261,8 @@ const GameChallengeEdit: FC = () => { return { value: tag[1], ...data } })} /> - -