fix: refs #7322 handle null responses in client, agency and address fetching #1313
|
@ -69,14 +69,16 @@ const onAddressSelected = (addressId) => {
|
||||||
}
|
}
|
||||||
|
|
||||||
const fetchClient = async () => {
|
const fetchClient = async () => {
|
||||||
const { data } = await getClient(client.value)
|
const response = await getClient(client.value)
|
||||||
const [retrievedClient] = data;
|
if (!response) return;
|
||||||
|
const [retrievedClient] = response.data;
|
||||||
selectedClient.value = retrievedClient;
|
selectedClient.value = retrievedClient;
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchAddresses = async () => {
|
const fetchAddresses = async () => {
|
||||||
const { data } = await getAddresses(client.value);
|
const response = await getAddresses(client.value);
|
||||||
addressesOptions.value = data;
|
if (!response) return;
|
||||||
|
addressesOptions.value = response.data;
|
||||||
|
|
||||||
const { defaultAddress } = selectedClient.value;
|
const { defaultAddress } = selectedClient.value;
|
||||||
address.value = defaultAddress.id;
|
address.value = defaultAddress.id;
|
||||||
|
|
|
@ -39,14 +39,16 @@ onBeforeMount(async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchClient = async (formData) => {
|
const fetchClient = async (formData) => {
|
||||||
const { data } = await getClient(formData.clientId);
|
const response = await getClient(formData.clientId);
|
||||||
const [client] = data;
|
if (!response) return;
|
||||||
|
const [client] = response.data;
|
||||||
selectedClient.value = client;
|
selectedClient.value = client;
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchAddresses = async (formData) => {
|
const fetchAddresses = async (formData) => {
|
||||||
const { data } = await getAddresses(formData.clientId);
|
const response = await getAddresses(formData.clientId);
|
||||||
addressesOptions.value = data;
|
if (!response) return;
|
||||||
|
addressesOptions.value = response.data;
|
||||||
|
|
||||||
const { defaultAddress } = selectedClient.value;
|
const { defaultAddress } = selectedClient.value;
|
||||||
formData.addressId = defaultAddress.id;
|
formData.addressId = defaultAddress.id;
|
||||||
|
@ -58,8 +60,9 @@ const onClientSelected = async (formData) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchAvailableAgencies = async (formData) => {
|
const fetchAvailableAgencies = async (formData) => {
|
||||||
const { data } = await getAgencies(formData);
|
const response = await getAgencies(formData);
|
||||||
agenciesOptions.value = data;
|
if (!response) return;
|
||||||
|
agenciesOptions.value = response.data;
|
||||||
|
|
||||||
const defaultAgency = agenciesOptions.value.find(
|
const defaultAgency = agenciesOptions.value.find(
|
||||||
(agency) =>
|
(agency) =>
|
||||||
|
|
|
@ -39,14 +39,16 @@ onBeforeMount(async () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
const fetchClient = async (formData) => {
|
const fetchClient = async (formData) => {
|
||||||
const { data } = await getClient(formData.clientId);
|
const response = await getClient(formData.clientId);
|
||||||
const [client] = data;
|
if (!response) return;
|
||||||
|
const [client] = response.data;
|
||||||
selectedClient.value = client;
|
selectedClient.value = client;
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchAddresses = async (formData) => {
|
const fetchAddresses = async (formData) => {
|
||||||
const { data } = await getAddresses(formData.clientId);
|
const response = await getAddresses(formData.clientId);
|
||||||
addressesOptions.value = data;
|
if (!response) return;
|
||||||
|
addressesOptions.value = response.data;
|
||||||
|
|
||||||
const { defaultAddress } = selectedClient.value;
|
const { defaultAddress } = selectedClient.value;
|
||||||
formData.addressId = defaultAddress.id;
|
formData.addressId = defaultAddress.id;
|
||||||
|
@ -58,8 +60,9 @@ const onClientSelected = async (formData) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchAvailableAgencies = async (formData) => {
|
const fetchAvailableAgencies = async (formData) => {
|
||||||
const { data } = await getAgencies(formData);
|
const response = await getAgencies(formData);
|
||||||
agenciesOptions.value = data;
|
if (!response) return;
|
||||||
|
agenciesOptions.value = response.data;
|
||||||
|
|
||||||
const defaultAgency = agenciesOptions.value.find(
|
const defaultAgency = agenciesOptions.value.find(
|
||||||
(agency) =>
|
(agency) =>
|
||||||
|
|
|
@ -240,8 +240,9 @@ const onClientSelected = async (formData) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchAvailableAgencies = async (formData) => {
|
const fetchAvailableAgencies = async (formData) => {
|
||||||
const { data } = await getAgencies(formData);
|
const response = await getAgencies(formData);
|
||||||
agenciesOptions.value = data;
|
if (!response) return;
|
||||||
|
agenciesOptions.value = response.data;
|
||||||
|
|
||||||
const defaultAgency = agenciesOptions.value.find(
|
const defaultAgency = agenciesOptions.value.find(
|
||||||
(agency) =>
|
(agency) =>
|
||||||
|
@ -252,14 +253,16 @@ const fetchAvailableAgencies = async (formData) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchClient = async (formData) => {
|
const fetchClient = async (formData) => {
|
||||||
const { data } = await getClient(formData.clientId);
|
const response = await getClient(formData.clientId);
|
||||||
const [client] = data;
|
if (!response) return;
|
||||||
|
const [client] = response.data;
|
||||||
selectedClient.value = client;
|
selectedClient.value = client;
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchAddresses = async (formData) => {
|
const fetchAddresses = async (formData) => {
|
||||||
const { data } = await getAddresses(formData.clientId);
|
const response = await getAddresses(formData.clientId);
|
||||||
addressesOptions.value = data;
|
if (!response) return;
|
||||||
|
addressesOptions.value = response.data;
|
||||||
|
|
||||||
const { defaultAddress } = selectedClient.value;
|
const { defaultAddress } = selectedClient.value;
|
||||||
formData.addressId = defaultAddress.id;
|
formData.addressId = defaultAddress.id;
|
||||||
|
|
Loading…
Reference in New Issue