add notifiaction handling, error handling

This commit is contained in:
Casey 2025-11-12 15:13:49 -06:00
parent ce708f5209
commit 1af288aa62
21 changed files with 4864 additions and 224 deletions

View file

@ -35,20 +35,44 @@ import Tab from "primevue/tab";
import TabPanels from "primevue/tabpanels";
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({
clientName: { type: String, required: true },
});
const getClientNames = async (type) => {
loadingStore.setLoading(true);
try {
const names = await Api.getCustomerNames(type);
clientNames.value = names;
} catch (error) {
errorStore.addError(error.message || "Error fetching client names");
} finally {
loadingStore.setLoading(false);
}
};
const getClient = async (name) => {
loadingStore.setLoading(true);
const clientData = await ApiWithToast.makeApiCall(() => Api.getClient(name));
client.value = clientData || {};
loadingStore.setLoading(false);
};
onMounted(async () => {
if (clientName === "new") {
// Logic for creating a new client
console.log("Creating a new client");
} else {
// Logic for fetching and displaying existing client data
const clientData = await Api.getClient(clientName);
client.value = clientData;
await getClient(clientName);
}
});
</script>