Refactor contact handling across backend and frontend
Replaced usage of "ContactPerson" with "Contact" for consistency across the codebase. Updated related component props, state variables, API calls, and database queries to align with the new model. Also enhanced backend functionality with stricter validations and added support for handling active pgroups in contact management.
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
import { useState, useEffect } from 'react';
|
||||
import { ShipmentsService, Shipment, ContactPerson } from '../../openapi';
|
||||
import { ShipmentsService, Shipment, Contact } from '../../openapi';
|
||||
|
||||
const useShipments = () => {
|
||||
const [shipments, setShipments] = useState<Shipment[]>([]);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [defaultContactPerson, setDefaultContactPerson] = useState<ContactPerson | undefined>();
|
||||
const [defaultContact, setDefaultContact] = useState<Contact | undefined>();
|
||||
|
||||
const fetchAndSetShipments = async () => {
|
||||
try {
|
||||
@@ -16,10 +16,10 @@ const useShipments = () => {
|
||||
}
|
||||
};
|
||||
|
||||
const fetchDefaultContactPerson = async () => {
|
||||
const fetchDefaultContact = async () => {
|
||||
try {
|
||||
const contacts = await ShipmentsService.getShipmentContactPersonsShipmentsContactPersonsGet();
|
||||
setDefaultContactPerson(contacts[0]);
|
||||
setDefaultContact(contacts[0]);
|
||||
} catch (error) {
|
||||
console.error('Failed to fetch contact persons:', error);
|
||||
setError('Failed to load contact persons. Please try again later.');
|
||||
@@ -28,10 +28,10 @@ const useShipments = () => {
|
||||
|
||||
useEffect(() => {
|
||||
fetchAndSetShipments();
|
||||
fetchDefaultContactPerson();
|
||||
fetchDefaultContact();
|
||||
}, []);
|
||||
|
||||
return { shipments, error, defaultContactPerson, fetchAndSetShipments };
|
||||
return { shipments, error, defaultContact, fetchAndSetShipments };
|
||||
};
|
||||
|
||||
export default useShipments;
|
||||
Reference in New Issue
Block a user