From 5e8b6f96bbe5cf905bf4b8537e22f4a435dd97ee Mon Sep 17 00:00:00 2001 From: Tiago Ribeiro Date: Sat, 20 Jan 2024 01:15:12 +0000 Subject: [PATCH] Added a timezone selector to the Demographic Input --- src/components/DemographicInformationInput.tsx | 12 +++++++++++- src/pages/profile.tsx | 2 +- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/components/DemographicInformationInput.tsx b/src/components/DemographicInformationInput.tsx index c97a4aef..0728ca4e 100644 --- a/src/components/DemographicInformationInput.tsx +++ b/src/components/DemographicInformationInput.tsx @@ -1,5 +1,5 @@ import {EmploymentStatus, EMPLOYMENT_STATUS, Gender, User} from "@/interfaces/user"; -import {FormEvent, useState} from "react"; +import {FormEvent, useEffect, useState} from "react"; import countryCodes from "country-codes-list"; import {RadioGroup} from "@headlessui/react"; import Input from "./Low/Input"; @@ -12,6 +12,8 @@ import {KeyedMutator} from "swr"; import CountrySelect from "./Low/CountrySelect"; import GenderInput from "@/components/High/GenderInput"; import EmploymentStatusInput from "@/components/High/EmploymentStatusInput"; +import TimezoneSelect from "./Low/TImezoneSelect"; +import moment from "moment"; interface Props { user: User; @@ -25,6 +27,7 @@ export default function DemographicInformationInput({user, mutateUser}: Props) { const [gender, setGender] = useState(); const [employment, setEmployment] = useState(); const [position, setPosition] = useState(); + const [timezone, setTimezone] = useState(moment.tz.guess()); const [isLoading, setIsLoading] = useState(false); const [companyName, setCompanyName] = useState(); @@ -43,6 +46,7 @@ export default function DemographicInformationInput({user, mutateUser}: Props) { employment: user.type === "corporate" ? undefined : employment, position: user.type === "corporate" ? position : undefined, passport_id, + timezone, }, agentInformation: user.type === "agent" ? {companyName, commercialRegistration} : undefined, }) @@ -94,6 +98,12 @@ export default function DemographicInformationInput({user, mutateUser}: Props) { required /> )} + +
+ + +
+ {user.type === "corporate" && ( diff --git a/src/pages/profile.tsx b/src/pages/profile.tsx index 12806fbb..8273741b 100644 --- a/src/pages/profile.tsx +++ b/src/pages/profile.tsx @@ -82,7 +82,7 @@ function UserProfile({user, mutateUser}: Props) { const [commercialRegistration, setCommercialRegistration] = useState( user.type === "agent" ? user.agentInformation?.commercialRegistration : undefined, ); - const [timezone, setTimezone] = useState(user.demographicInformation?.timezone || "UTC"); + const [timezone, setTimezone] = useState(user.demographicInformation?.timezone || moment.tz.guess()); const {groups} = useGroups(); const {users} = useUsers();