Fix updating slug (#4747)

pull/4728/head
Leo Giovanetti 2022-09-28 19:07:55 -03:00 committed by GitHub
parent f5faebad67
commit 7256dbf84f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 2 deletions

View File

@ -96,7 +96,8 @@ export type EventTypeSetupInfered = inferSSRProps<typeof getServerSideProps>;
const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => { const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
const { t } = useLocale(); const { t } = useLocale();
const { eventType, locationOptions, team, teamMembers } = props; const { eventType: dbEventType, locationOptions, team, teamMembers } = props;
const [eventType, setEventType] = useState(dbEventType);
const animationParentRef = useRef(null); const animationParentRef = useRef(null);
const router = useRouter(); const router = useRouter();
const { tabName } = querySchema.parse(router.query); const { tabName } = querySchema.parse(router.query);
@ -106,7 +107,8 @@ const EventTypePage = (props: inferSSRProps<typeof getServerSideProps>) => {
}, [animationParentRef]); }, [animationParentRef]);
const updateMutation = trpc.useMutation("viewer.eventTypes.update", { const updateMutation = trpc.useMutation("viewer.eventTypes.update", {
onSuccess: async ({ eventType }) => { onSuccess: async ({ eventType: newEventType }) => {
setEventType({ ...eventType, slug: newEventType.slug });
showToast( showToast(
t("event_type_updated_successfully", { t("event_type_updated_successfully", {
eventTypeTitle: eventType.title, eventTypeTitle: eventType.title,