Add refetchThemes function to event theme context and usage
Introduce a new `refetchThemes` function in the event theme context to allow for refreshing event theme data. Update `EventThemeForm` to call `refetchThemes` after updating a theme, ensuring the data stays synchronized. This enhances the consistency of the UI after changes to event themes.
This commit is contained in:
@@ -36,7 +36,7 @@ type ThemeFormProps = {
|
||||
|
||||
export function EventThemeForm({ theme, mode }: ThemeFormProps) {
|
||||
const router = useRouter();
|
||||
const { createTheme, updateTheme } = useEventThemes();
|
||||
const { createTheme, updateTheme, refetchThemes } = useEventThemes();
|
||||
|
||||
// Form state
|
||||
const [formState, setFormState] = useState<
|
||||
@@ -202,6 +202,7 @@ export function EventThemeForm({ theme, mode }: ThemeFormProps) {
|
||||
router.push("/dashboard/event-themes");
|
||||
} else if (mode === "edit" && theme) {
|
||||
await updateTheme(theme.id, formState as EventThemeUpdate);
|
||||
await refetchThemes();
|
||||
router.push("/dashboard/event-themes");
|
||||
}
|
||||
} catch (err) {
|
||||
|
||||
Reference in New Issue
Block a user