diff --git a/packages/platform/atoms/hooks/useGetCityTimezones.ts b/packages/platform/atoms/hooks/useGetCityTimezones.ts index 70996b2916..b00de934ac 100644 --- a/packages/platform/atoms/hooks/useGetCityTimezones.ts +++ b/packages/platform/atoms/hooks/useGetCityTimezones.ts @@ -1,14 +1,23 @@ import { useQuery } from "@tanstack/react-query"; +import { SUCCESS_STATUS } from "@calcom/platform-constants"; +import type { ApiResponse } from "@calcom/platform-types"; + import http from "../lib/http"; +type Timezones = { city: string; timezone: string }[]; const useGetCityTimezones = () => { const pathname = `/timezones`; - const { isLoading, data } = useQuery({ + const { isLoading, data } = useQuery>({ queryKey: ["city-timezones"], queryFn: () => { - return http?.get(pathname).then((res) => res.data); + return http?.get>(pathname).then((res) => { + if (res.data.status === SUCCESS_STATUS) { + return res.data; + } + throw new Error(res.data.error.message); + }); }, }); diff --git a/packages/platform/atoms/timezone/index.tsx b/packages/platform/atoms/timezone/index.tsx index a81cbf20c0..a579e3aa54 100644 --- a/packages/platform/atoms/timezone/index.tsx +++ b/packages/platform/atoms/timezone/index.tsx @@ -6,5 +6,18 @@ import useGetCityTimezones from "../hooks/useGetCityTimezones"; export function Timezone(props: TimezoneSelectProps) { const { isLoading, data } = useGetCityTimezones(); - return ; + return ( + ({ + label: city, + timezone, + })) + : [] + } + isPending={isLoading} + /> + ); }