rules, bracket page

This commit is contained in:
yohlo
2025-09-18 18:17:56 -05:00
parent 285a33c488
commit 602e6e3473
15 changed files with 273 additions and 24 deletions

View File

@@ -0,0 +1,44 @@
import {
Stack,
Button
} from "@mantine/core";
import { useState, useCallback } from "react";
import { useTournament } from "../queries";
import useUpdateTournament from "../hooks/use-update-tournament";
import { RichTextEditor } from "@/components/rich-text-editor";
interface EditRulesProps {
tournamentId: string;
onClose?: () => void
}
const EditRules = ({ tournamentId, onClose }: EditRulesProps) => {
const [search, setSearch] = useState("");
const { data: tournament, isLoading: tournamentLoading } =
useTournament(tournamentId);
const { mutate: updateTournament, isPending: updatePending } = useUpdateTournament(tournamentId);
const [value, setValue] = useState(tournament.rules);
const handleSubmit = useCallback(
(rules?: string) => {
updateTournament({ rules }, {
onSuccess: () => {
onClose?.();
}
});
},
[updateTournament, tournamentId]
);
return (
<Stack gap="xs" w="100%">
<RichTextEditor value={value || ""} onChange={setValue} />
<Button onClick={() => handleSubmit(value)}>Submit</Button>
<Button variant="subtle" color="red" onClick={onClose}>Cancel</Button>
</Stack>
);
};
export default EditRules;