add query for client details

This commit is contained in:
Casey 2025-11-13 15:17:43 -06:00
parent 172927e069
commit 0b280cec8e
8 changed files with 114 additions and 69 deletions

View file

@ -37,10 +37,9 @@ import TabPanel from "primevue/tabpanel";
import Api from "../../api";
import ApiWithToast from "../../api-toast";
import { useLoadingStore } from "../../stores/loading";
import { useErrorStore } from "../../stores/errors";
const loadingStore = useLoadingStore();
const errorStore = useErrorStore();
const clientNames = ref([]);
const client = ref({});
const { clientName } = defineProps({
@ -50,10 +49,10 @@ const { clientName } = defineProps({
const getClientNames = async (type) => {
loadingStore.setLoading(true);
try {
const names = await Api.getCustomerNames(type);
const names = await Api.getClientNames(type);
clientNames.value = names;
} catch (error) {
errorStore.addError(error.message || "Error fetching client names");
console.error("Error fetching client names in Client.vue: ", error.message || error);
} finally {
loadingStore.setLoading(false);
}
@ -61,9 +60,14 @@ const getClientNames = async (type) => {
const getClient = async (name) => {
loadingStore.setLoading(true);
const clientData = await ApiWithToast.makeApiCall(() => Api.getClient(name));
client.value = clientData || {};
loadingStore.setLoading(false);
try {
const clientData = await Api.getClient(name);
client.value = clientData || {};
} catch (error) {
console.error("Error fetching client data in Client.vue: ", error.message || error);
} finally {
loadingStore.setLoading(false);
}
};
onMounted(async () => {