- Introduced new controllers for internet eligibility and service health checks to enhance backend functionality. - Created service modules for internet, SIM, and VPN offerings, improving organization and maintainability. - Developed various components for internet and SIM configuration, including forms and plan cards, to streamline user interactions. - Implemented hooks for managing service configurations and eligibility checks, enhancing frontend data handling. - Updated utility functions for pricing and catalog operations to support new service structures and improve performance.
33 lines
1002 B
TypeScript
33 lines
1002 B
TypeScript
"use client";
|
|
|
|
import { useCallback } from "react";
|
|
import { useQueryClient } from "@tanstack/react-query";
|
|
import { queryKeys } from "@/lib/api";
|
|
import { accountService } from "@/features/account/services/account.service";
|
|
import {
|
|
addressFormSchema,
|
|
addressFormToRequest,
|
|
type AddressFormData,
|
|
} from "@customer-portal/domain/customer";
|
|
import { useZodForm } from "@/hooks/useZodForm";
|
|
|
|
export function useAddressEdit(initial: AddressFormData) {
|
|
const queryClient = useQueryClient();
|
|
|
|
const handleSave = useCallback(
|
|
async (formData: AddressFormData) => {
|
|
const requestData = addressFormToRequest(formData);
|
|
await accountService.updateAddress(requestData);
|
|
// Address changes can affect server-personalized catalog results (eligibility).
|
|
await queryClient.invalidateQueries({ queryKey: queryKeys.services.all() });
|
|
},
|
|
[queryClient]
|
|
);
|
|
|
|
return useZodForm({
|
|
schema: addressFormSchema,
|
|
initialValues: initial,
|
|
onSubmit: handleSave,
|
|
});
|
|
}
|