Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions public/locales/de/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -954,6 +954,7 @@
"clientLanguages": "Sprachen der Klient:innen",
"cancel": "Abbrechen",
"saveChanges": "Änderungen speichern",
"saveSuccess": "Organisationsdetails erfolgreich aktualisiert",
"validation": {
"required": "Dieses Feld ist erforderlich",
"websiteInvalid": "Webseite muss mit http:// oder https:// beginnen",
Expand Down
1 change: 1 addition & 0 deletions public/locales/en/translations.json
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,7 @@
"clientLanguages": "Client languages",
"cancel": "Cancel",
"saveChanges": "Save changes",
"saveSuccess": "Organisation details updated successfully",
"validation": {
"required": "This field is required",
"websiteInvalid": "Website must start with http:// or https://",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const AgentContactDetails = forwardRef<ContactDetailsRef, Props>(function
ref,
) {
const { t } = useTranslation();
const { mutate: updateAgent, isPending } = useUpdateAgentContact(String(agent?.representative?.id));
const { mutate: updateAgent, isPending } = useUpdateAgentContact(String(agent?.representative?.id), String(agent?.id));
const [isEditing, setIsEditing] = useState(false);

useEditingChangeNotifier(isEditing, onEditingChange);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const OrganisationDetails = forwardRef<EditableSectionRef, Props>(functio
) {
const { t, i18n } = useTranslation();
const [isEditing, setIsEditing] = useState(false);
const { mutate: updateOrganization /*, isPending */ } = useUpdateOrganization(String(agent?.operator));
const { mutate: updateOrganization /*, isPending */ } = useUpdateOrganization(String(agent?.id));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if isPending is no longer needed, then can remove the comment


useEditingChangeNotifier(isEditing, onEditingChange);
const { data: apiLanguages } = useApiLanguages();
Expand Down Expand Up @@ -56,12 +56,15 @@ export const OrganisationDetails = forwardRef<EditableSectionRef, Props>(functio
};

const onSubmit = (values: OrganisationDetailsFormData) => {
updateOrganization(values as unknown as ApiAgentProfileGet, {
onSuccess: () => {
reset(values);
setIsEditing(false);
updateOrganization(
{ about: values.about, website: values.website },
{
onSuccess: () => {
reset(values);
setIsEditing(false);
},
},
});
);
};

return (
Expand Down
4 changes: 2 additions & 2 deletions src/hooks/useUpdateAgentContact.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import { useMutationQuery } from "@/hooks";
import { ApiRepresentativeGet } from "need4deed-sdk";
import { DeepPartial } from "ts-type-safe";

export const useUpdateAgentContact = (personId: string) => {
export const useUpdateAgentContact = (personId: string, agentId: string) => {
return useMutationQuery<DeepPartial<ApiRepresentativeGet>, ApiAgentProfileGet>({
apiPath: `${apiPathPerson}${personId}`,
method: "patch",
successMessage: "dashboard.agentProfile.contactDetails.saveSuccess",
queryKeyToInvalidate: ["agent", personId],
queryKeyToInvalidate: ["agent", agentId],
});
};
18 changes: 10 additions & 8 deletions src/hooks/useUpdateOrganizationDetails.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
import { ApiAgentProfileGet } from "@/components/Dashboard/Profile/types";
import { apiPathOrganization } from "@/config/constants";
import { apiPathAgent } from "@/config/constants";
import { useMutationQuery } from "@/hooks";
import { ApiRepresentativeGet } from "need4deed-sdk";
import { DeepPartial } from "ts-type-safe";
import { ApiAgentPatch } from "need4deed-sdk";

export const useUpdateOrganization = (organizationId: string) => {
return useMutationQuery<DeepPartial<ApiRepresentativeGet>, ApiAgentProfileGet>({
apiPath: `${apiPathOrganization}${organizationId}`,
// Patches agent-level org details (about, website) via the agent endpoint.
// Note: address and district require the organization's numeric ID which is not
// currently exposed in the agent API response — those fields need a BE change.
export const useUpdateOrganization = (agentId: string) => {
return useMutationQuery<Pick<ApiAgentPatch, "about" | "website">, ApiAgentProfileGet>({
apiPath: `${apiPathAgent}/${agentId}`,
method: "patch",
successMessage: "__dashboard.agentProfile.contactDetails.saveSuccess",
queryKeyToInvalidate: ["organization", organizationId],
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I mentioned this during the fe refactor but the organization label confuses me. Would have said it made me more sense to call this hook useUpdateAgent but in the /Profile/sections dir we already have Organization components so I see why it's named as so

successMessage: "dashboard.agentProfile.organisationDetails.saveSuccess",
queryKeyToInvalidate: ["agent", agentId],
});
};
Loading