diff --git a/src/components/Dashboard/Agents/AgentListController.tsx b/src/components/Dashboard/Agents/AgentListController.tsx index 4f797a8a..cf3b55ff 100644 --- a/src/components/Dashboard/Agents/AgentListController.tsx +++ b/src/components/Dashboard/Agents/AgentListController.tsx @@ -1,6 +1,7 @@ import { ApiAgentGetList, ApiOptionLists, SortOrder } from "need4deed-sdk"; import { AgentCardList } from "./AgentCardList"; import { useEffect } from "react"; +import { DashboardListLoading } from "@/components/Dashboard/common/DashboardListLoading"; import { useGetQuery, usePageParam } from "@/hooks"; import { apiPathAgent, cacheTTL } from "@/config/constants"; import { serializeAgentFilters } from "./helpers"; @@ -29,7 +30,7 @@ export const AgentListController = ({ setNumOfAgents, sortOrder, isFiltersOpen, }), ); - const { data, count } = useGetQuery({ + const { data, count, isLoading } = useGetQuery({ queryKey: ["agents"], apiPath: `${apiPathAgent}/`, params: { @@ -48,6 +49,8 @@ export const AgentListController = ({ setNumOfAgents, sortOrder, isFiltersOpen, setNumOfAgents(count); }, [count, setNumOfAgents]); + if (isLoading) return ; + return ( ({ + const { data, count, isLoading } = useGetQuery({ queryKey: ["opportunities"], apiPath: `${apiPathOpportunity}/`, params: { @@ -85,6 +86,8 @@ export function OpportunityListController({ setNumOfOpps(count); }, [count, setNumOfOpps]); + if (isLoading) return ; + return ( (functio .map((lang) => keyToLabel[String(lang.id)] || String(lang.id)) .join(", "); + // appointmentDistrict is server-calculated from postcode — read from API response, never from form state + const rawDetails = opportunity.accompanyingDetails as ApiOpportunityAccompanyingDetails & { + appointmentPostcode?: string; + appointmentDistrict?: Option; + }; + const lang = i18n.language as Lang; + const districtTitle = + rawDetails?.appointmentDistrict?.title?.[lang] ?? rawDetails?.appointmentDistrict?.title?.de ?? ""; + const postcode = rawDetails?.appointmentPostcode || ""; + const postcodeDisplay = postcode && districtTitle ? `${postcode}, ${districtTitle}` : postcode; + return ( @@ -139,7 +150,11 @@ export const AccompanyingDetails = forwardRef(functio minAppointmentDate={minAppointmentDate} /> ) : ( - + )} diff --git a/src/components/Dashboard/Profile/sections/AccompanyingDetails/AccompanyingDetailsDisplay.tsx b/src/components/Dashboard/Profile/sections/AccompanyingDetails/AccompanyingDetailsDisplay.tsx index 8862c548..a7aa785d 100644 --- a/src/components/Dashboard/Profile/sections/AccompanyingDetails/AccompanyingDetailsDisplay.tsx +++ b/src/components/Dashboard/Profile/sections/AccompanyingDetails/AccompanyingDetailsDisplay.tsx @@ -9,9 +9,10 @@ import { DateFieldRow, Details } from "./styles"; type Props = { values: AccompanyingDetailsFormData; languageLabel: string; + postcodeDisplay: string; }; -export const AccompanyingDetailsDisplay = ({ values, languageLabel }: Props) => { +export const AccompanyingDetailsDisplay = ({ values, languageLabel, postcodeDisplay }: Props) => { const { t } = useTranslation(); return ( @@ -28,7 +29,7 @@ export const AccompanyingDetailsDisplay = ({ values, languageLabel }: Props) => mode="display" type="text" label={t("dashboard.opportunityProfile.accompanyingDetails.appointmentPostcode")} - value={values.appointmentPostcode || ""} + value={postcodeDisplay} setValue={() => {}} /> diff --git a/src/components/Dashboard/Volunteers/VolunteerListController.tsx b/src/components/Dashboard/Volunteers/VolunteerListController.tsx index 6451485f..84236c9b 100644 --- a/src/components/Dashboard/Volunteers/VolunteerListController.tsx +++ b/src/components/Dashboard/Volunteers/VolunteerListController.tsx @@ -1,11 +1,12 @@ import { useEffect } from "react"; +import { DashboardListLoading } from "@/components/Dashboard/common/DashboardListLoading"; import { apiPathVolunteer, cacheTTL, TABLE_LIMIT } from "@/config/constants"; import { useGetQuery, usePageParam } from "@/hooks"; import { ApiOptionLists, ApiVolunteerGetList, SortOrder } from "need4deed-sdk"; import { CardsFilter } from "./Filters/types"; import { serializeFilters } from "./helpers"; -import { VolunteerCardList } from "./VolunteerCardList"; // We will modify this component +import { VolunteerCardList } from "./VolunteerCardList"; import { VolunteerTableList } from "./VolunteerTableList"; const CARD_COLUMNS = 3; @@ -49,7 +50,7 @@ export function VolunteerListController({ sortOrder, filter: serializedFilter, }; - const { data, count } = useGetQuery({ + const { data, count, isLoading } = useGetQuery({ queryKey: ["volunteers"], apiPath: apiPathVolunteer, params, @@ -61,6 +62,8 @@ export function VolunteerListController({ setNumOfVols(count); }, [count, setNumOfVols]); + if (isLoading) return ; + if (isListView) { return ( + {t("dashboard.home.content.loading")} + + ); +} diff --git a/src/hooks/useUpdateOpportunityAccompanyingDetails.ts b/src/hooks/useUpdateOpportunityAccompanyingDetails.ts index 31a9d833..4be885ff 100644 --- a/src/hooks/useUpdateOpportunityAccompanyingDetails.ts +++ b/src/hooks/useUpdateOpportunityAccompanyingDetails.ts @@ -6,7 +6,6 @@ export type OpportunityAccompanyingDetailsUpdateData = { accompanyingDetails: { appointmentAddress?: string; appointmentPostcode?: string; - appointmentDistrict?: string; appointmentDate?: string; appointmentTime?: string; refugeeNumber?: string;