From 30806d37ca01f9bdf10f64c3c16266c159a5be2b Mon Sep 17 00:00:00 2001 From: Matt Burnett Date: Sat, 7 Dec 2024 16:00:09 +0100 Subject: [PATCH 1/3] Local commit: Partial commit to share with Andrew while we debug 404 error in org store addSocialLink method --- frontend/components/card/CardConnect.vue | 2 +- frontend/stores/organization.ts | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/frontend/components/card/CardConnect.vue b/frontend/components/card/CardConnect.vue index d068fcc2a..eff963d56 100644 --- a/frontend/components/card/CardConnect.vue +++ b/frontend/components/card/CardConnect.vue @@ -124,7 +124,7 @@ const props = defineProps<{ pageType: "organization" | "group" | "event" | "other"; }>(); -// TODO: uncomment and delete 'true' line after issue 1006 is done. +// TODO: restore after 1006 is resolved. // const { userIsSignedIn } = useUser(); const userIsSignedIn = true; const paramsId = useRoute().params.id; diff --git a/frontend/stores/organization.ts b/frontend/stores/organization.ts index dd7c47d21..c09f11368 100644 --- a/frontend/stores/organization.ts +++ b/frontend/stores/organization.ts @@ -229,7 +229,7 @@ export const useOrganizationStore = defineStore("organization", { const token = localStorage.getItem("accessToken"); const responseSocialLinks = await useFetch( - `${BASE_BACKEND_URL as string}/content/social_links/${org.id}/`, + `${BASE_BACKEND_URL as string}/content/social_links/${org.id}`, { method: "PUT", body: JSON.stringify({ @@ -249,7 +249,6 @@ export const useOrganizationStore = defineStore("organization", { if (responseSocialLinksData) { this.loading = false; - // return responseSocialLinksData.id; return responseSocialLinksData; } From 84ed05152f1721ed1ff9ca2263b8269ee5613040 Mon Sep 17 00:00:00 2001 From: Matt Burnett Date: Sat, 7 Dec 2024 16:01:34 +0100 Subject: [PATCH 2/3] Local commit: Added Popup file. --- frontend/components/popup/PopupNewField.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/components/popup/PopupNewField.vue b/frontend/components/popup/PopupNewField.vue index de0982e2b..743053405 100644 --- a/frontend/components/popup/PopupNewField.vue +++ b/frontend/components/popup/PopupNewField.vue @@ -82,6 +82,7 @@ const inputLabel = ref(""); const handleAddClick = () => { // Validate user input and emit 'add' event + payload to CardConnect.vue. // CardConnect.vue handles the data PUT's via the org store. + // if (!inputValue.value.trim()) { alert("Please enter a 'Link to account'."); From 5bb2947f36a5b2e10e1d7c216f17363997ad84dc Mon Sep 17 00:00:00 2001 From: Matt Burnett Date: Sat, 7 Dec 2024 16:26:39 +0100 Subject: [PATCH 3/3] Local commit: Restored files from PR 1037. CardConnect.vue PopupNewField.vue organization.ts types/social-links-payload.ts --- frontend/components/card/CardConnect.vue | 33 ++++++++++++++++----- frontend/components/popup/PopupNewField.vue | 19 +++++------- frontend/stores/organization.ts | 10 ++++--- frontend/types/social-links-payload.ts | 4 +++ 4 files changed, 42 insertions(+), 24 deletions(-) create mode 100644 frontend/types/social-links-payload.ts diff --git a/frontend/components/card/CardConnect.vue b/frontend/components/card/CardConnect.vue index 4ab6848b3..d068fcc2a 100644 --- a/frontend/components/card/CardConnect.vue +++ b/frontend/components/card/CardConnect.vue @@ -60,6 +60,7 @@ }" > + + (); -// TODO: restore after 1006 is resolved. +// TODO: uncomment and delete 'true' line after issue 1006 is done. // const { userIsSignedIn } = useUser(); const userIsSignedIn = true; - const paramsId = useRoute().params.id; const paramsIdGroup = useRoute().params.groupId; @@ -161,13 +165,26 @@ const socialLinksRef = computed(() => { } }); -const toggleEditMode = () => { - editModeEnabled.value = !editModeEnabled.value; -}; +const handlePopupAddClick = async (payload: AddPayload, close: () => void) => { + // Put the social links payload in the database. + // TODO: Needs more robust handling (ie try/catch + error trapping/handling) + const response = await organizationStore.addSocialLinks( + organization, + payload + ); + if (response) { + console.log("org store addSocialLinks response: " + response); + console.log( + "CardConnect addSocialLinks payload: " + JSON.stringify(payload) + ); + } -const onClose = (close: (ref?: HTMLElement) => void) => { close(); }; +const toggleEditMode = () => { + editModeEnabled.value = !editModeEnabled.value; +}; + const emit = defineEmits(["on-new-account", "on-account-removed"]); diff --git a/frontend/components/popup/PopupNewField.vue b/frontend/components/popup/PopupNewField.vue index 7e9710424..de0982e2b 100644 --- a/frontend/components/popup/PopupNewField.vue +++ b/frontend/components/popup/PopupNewField.vue @@ -23,6 +23,7 @@ id="popup-input" class="focus-brand h-8 w-52 rounded-sm border border-primary-text bg-transparent p-2" type="text" + required :placeholder="fieldNamePrompt" /> @@ -43,14 +45,11 @@ cols="10" :placeholder="descriptionPrompt" > -
+
+ (); -const inputValue = ref(null); -const inputLabel = ref(null); +const emit = defineEmits(["add-clicked", "on-close-clicked"]); const inputValue = ref(""); const inputLabel = ref(""); @@ -84,7 +82,6 @@ const inputLabel = ref(""); const handleAddClick = () => { // Validate user input and emit 'add' event + payload to CardConnect.vue. // CardConnect.vue handles the data PUT's via the org store. - // if (!inputValue.value.trim()) { alert("Please enter a 'Link to account'."); @@ -110,6 +107,4 @@ const handleAddClick = () => { label: inputLabel.value, }); }; - -const emit = defineEmits(["on-cta-clicked", "on-close-clicked"]); diff --git a/frontend/stores/organization.ts b/frontend/stores/organization.ts index 92e390031..dd7c47d21 100644 --- a/frontend/stores/organization.ts +++ b/frontend/stores/organization.ts @@ -5,6 +5,7 @@ import type { PiniaResOrganization, PiniaResOrganizations, } from "~/types/entities/organization"; +import type { AddPayload } from "~/types/social-links-payload"; interface OrganizationStore { loading: boolean; @@ -56,7 +57,7 @@ export const useOrganizationStore = defineStore("organization", { const token = localStorage.getItem("accessToken"); const responseOrg = await useFetch( - `${BASE_BACKEND_URL}/entities/organizations/`, + `${BASE_BACKEND_URL as string}/entities/organizations/`, { method: "POST", body: JSON.stringify({ @@ -170,7 +171,7 @@ export const useOrganizationStore = defineStore("organization", { const token = localStorage.getItem("accessToken"); const responseOrg = await $fetch( - BASE_BACKEND_URL + `/entities/organizations/${org.id}/`, + (BASE_BACKEND_URL as string) + `/entities/organizations/${org.id}/`, { method: "PUT", body: { @@ -184,7 +185,7 @@ export const useOrganizationStore = defineStore("organization", { ); const responseOrgTexts = await $fetch( - BASE_BACKEND_URL + + (BASE_BACKEND_URL as string) + `/entities/organization_texts/${org.organizationTextId}/`, { method: "PUT", @@ -228,7 +229,7 @@ export const useOrganizationStore = defineStore("organization", { const token = localStorage.getItem("accessToken"); const responseSocialLinks = await useFetch( - `${BASE_BACKEND_URL as string}/content/social_links/${org.id}`, + `${BASE_BACKEND_URL as string}/content/social_links/${org.id}/`, { method: "PUT", body: JSON.stringify({ @@ -248,6 +249,7 @@ export const useOrganizationStore = defineStore("organization", { if (responseSocialLinksData) { this.loading = false; + // return responseSocialLinksData.id; return responseSocialLinksData; } diff --git a/frontend/types/social-links-payload.ts b/frontend/types/social-links-payload.ts new file mode 100644 index 000000000..452c88470 --- /dev/null +++ b/frontend/types/social-links-payload.ts @@ -0,0 +1,4 @@ +export interface AddPayload { + link: string; + label: string; +}