From 8f9eb24c23b5e789861f52080bbbf12d9807a9cc Mon Sep 17 00:00:00 2001 From: Mika Date: Thu, 11 Jul 2024 15:05:18 +0200 Subject: [PATCH] web: fix dates on website --- web/src/components/CategoryContainer.vue | 35 +++---- web/src/components/HeaderBar.vue | 60 ++++++----- web/src/components/ListViewElement.vue | 123 ++++++++++------------- web/src/components/MainPage.vue | 1 + web/src/types.ts | 6 +- 5 files changed, 108 insertions(+), 117 deletions(-) diff --git a/web/src/components/CategoryContainer.vue b/web/src/components/CategoryContainer.vue index 2149374..421f76f 100644 --- a/web/src/components/CategoryContainer.vue +++ b/web/src/components/CategoryContainer.vue @@ -5,9 +5,9 @@ @@ -21,32 +21,21 @@ notes="" /> --> - - diff --git a/web/src/components/HeaderBar.vue b/web/src/components/HeaderBar.vue index 44fd68d..1cca1df 100644 --- a/web/src/components/HeaderBar.vue +++ b/web/src/components/HeaderBar.vue @@ -13,7 +13,7 @@ - + Add Group @@ -24,7 +24,7 @@
{ - const res = await axios.get( - import.meta.env.VITE_BACKEND_URL + "/licenses", - { - headers: { - Authorization: `Bearer ${store.token}`, - }, - } - ); + const res = await axiosInstance.get("/licenses"); return res.data; }, select: (data) => { @@ -220,7 +212,7 @@ const { data } = useQuery({ }, }); -const { isPending, mutate } = useMutation({ +const { mutate: licenseMutate } = useMutation({ mutationFn: async (newLicense: CreateLicenseDto) => { await axiosInstance.post("/licenses", newLicense); }, @@ -233,6 +225,19 @@ const { isPending, mutate } = useMutation({ }, }); +const { mutate: groupsMutate } = useMutation({ + mutationFn: async (newGroup: CreateGroupDto) => { + await axiosInstance.post("/groups", newGroup); + }, + onError: (error) => { + snackbar.value = true; + }, + onSuccess: () => { + queryClient.invalidateQueries({ queryKey: ["licenses"] }); + group.value = false; + }, +}); + function handlelogout() { store.setToken(null); } @@ -245,12 +250,25 @@ async function submit(event: SubmitEventPromise) { group_id: addLicenseGroup.value, amount: addAmount.value, key: addLicenseKey.value, - start: addStartDate.value, - stop: addStopDate.value, + start: addStartDate.value ?? null, + end: addStopDate.value ?? null, notes: addNotes.value, }; console.log(data); - mutate(data); + licenseMutate(data); + } else { + console.log("Invalid"); + } +} + +async function submitGroup(event: SubmitEventPromise) { + const result = await event; + if (result.valid) { + const groupsData = { + name: groupGroupName.value, + }; + console.log(groupsData); + groupsMutate(groupsData); } else { console.log("Invalid"); } @@ -263,7 +281,7 @@ const snackbar = ref(false); // const group = ref(false); // Dialog for Group -const groupLicenseName = ref(""); +const groupGroupName = ref(""); // Rules for Group Dialog const licenseGroupRules = [ @@ -312,12 +330,6 @@ const addNotes = ref(""); // Date Picker const addStartDate = ref(); const addStopDate = ref(); - -// -// EDIT SECTION -// - -const edit = ref(false);