mirror of
https://github.com/MetaFam/TheGame.git
synced 2026-04-24 03:00:09 -04:00
fix: s-s rendered page is trying to access an unavailable component
This commit is contained in:
@@ -5,22 +5,24 @@ import { useUpdateProfileMutation } from 'graphql/autogen/types';
|
||||
import { useUser } from 'lib/hooks';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
|
||||
export type SetupTimezoneProps = {
|
||||
timeZone: string;
|
||||
setTimeZone: React.Dispatch<React.SetStateAction<string>>;
|
||||
};
|
||||
|
||||
export const SetupTimeZone: React.FC<SetupTimezoneProps> = ({
|
||||
timeZone,
|
||||
setTimeZone,
|
||||
}) => {
|
||||
export const SetupTimeZone: React.FC = () => {
|
||||
const { onNextPress, nextButtonLabel } = useSetupFlow();
|
||||
const [timeZone, setTimeZone] = useState<string>('');
|
||||
const { user } = useUser();
|
||||
const toast = useToast();
|
||||
|
||||
const [updateProfileRes, updateProfile] = useUpdateProfileMutation();
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (user?.player) {
|
||||
const { player } = user;
|
||||
if (player.timezone && !timeZone) {
|
||||
setTimeZone(player.timezone);
|
||||
}
|
||||
}
|
||||
}, [user, timeZone]);
|
||||
|
||||
const handleNextPress = async () => {
|
||||
if (!user) return;
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
import { SetupProfile } from 'components/Setup/SetupProfile';
|
||||
import { SetupTimeZone } from 'components/Setup/SetupTimeZone';
|
||||
import { SetupContextProvider } from 'contexts/SetupContext';
|
||||
import { useUser } from 'lib/hooks';
|
||||
import { InferGetStaticPropsType } from 'next';
|
||||
import React, { useState } from 'react';
|
||||
import React from 'react';
|
||||
|
||||
export const getStaticProps = async () => ({
|
||||
props: {
|
||||
@@ -13,23 +12,11 @@ export const getStaticProps = async () => ({
|
||||
|
||||
export type DefaultSetupProps = InferGetStaticPropsType<typeof getStaticProps>;
|
||||
|
||||
const TimeZoneSetup: React.FC<DefaultSetupProps> = () => {
|
||||
const [timeZone, setTimeZone] = useState<string>('');
|
||||
const { user } = useUser();
|
||||
|
||||
if (user?.player) {
|
||||
const { player } = user;
|
||||
if (player.timezone && !timeZone) {
|
||||
setTimeZone(player.timezone);
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<SetupContextProvider>
|
||||
<SetupProfile>
|
||||
<SetupTimeZone timeZone={timeZone} setTimeZone={setTimeZone} />
|
||||
</SetupProfile>
|
||||
</SetupContextProvider>
|
||||
);
|
||||
};
|
||||
const TimeZoneSetup: React.FC<DefaultSetupProps> = () => (
|
||||
<SetupContextProvider>
|
||||
<SetupProfile>
|
||||
<SetupTimeZone />
|
||||
</SetupProfile>
|
||||
</SetupContextProvider>
|
||||
);
|
||||
export default TimeZoneSetup;
|
||||
|
||||
Reference in New Issue
Block a user