import { MetaButton, MetaHeading, SelectTimeZone, useToast } from '@metafam/ds'; import { FlexContainer } from 'components/Container'; import { useSetupFlow } from 'contexts/SetupContext'; import { useUpdateProfileMutation } from 'graphql/autogen/types'; import { useUser } from 'lib/hooks'; import React, { useState } from 'react'; export type SetupTimezoneProps = { timeZone: string; setTimeZone: React.Dispatch>; }; export const SetupTimeZone: React.FC = ({ timeZone, setTimeZone, }) => { const { onNextPress, nextButtonLabel } = useSetupFlow(); const { user } = useUser(); const toast = useToast(); const [updateProfileRes, updateProfile] = useUpdateProfileMutation(); const [loading, setLoading] = useState(false); const handleNextPress = async () => { if (!user) return; setLoading(true); const { error } = await updateProfile({ playerId: user.id, input: { timezone: timeZone, }, }); if (error) { toast({ title: 'Error', description: 'Unable to update time zone. The octo is sad 😢', status: 'error', isClosable: true, }); setLoading(false); return; } onNextPress(); }; return ( Which time zone are you in? setTimeZone(tz.value)} labelStyle="abbrev" /> {nextButtonLabel} ); };