From 63d72b59a9051da56b05dab444589f85b769f307 Mon Sep 17 00:00:00 2001 From: hlokomani-tuks <133780278+hlokomani-tuks@users.noreply.github.com> Date: Tue, 1 Oct 2024 03:47:15 +0200 Subject: [PATCH 1/5] removed location_id from fetch --- frontend/lib/api/fetchIssues.tsx | 3 ++- frontend/lib/types.ts | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/frontend/lib/api/fetchIssues.tsx b/frontend/lib/api/fetchIssues.tsx index 4e08e7f3..1efc11ba 100644 --- a/frontend/lib/api/fetchIssues.tsx +++ b/frontend/lib/api/fetchIssues.tsx @@ -31,7 +31,8 @@ const fetchIssues = async ( } if (location) { - requestBody.location = location; + const { location_id, ...locationWithoutId } = location; + requestBody.location = locationWithoutId; } const url = `${process.env.NEXT_PUBLIC_BACKEND_URL}/api/issues`; diff --git a/frontend/lib/types.ts b/frontend/lib/types.ts index 8b8c4b60..e3f06871 100644 --- a/frontend/lib/types.ts +++ b/frontend/lib/types.ts @@ -452,7 +452,7 @@ interface AnalysisResult { } interface Location { - location_id: string; + location_id?: string; province?: string; city?: string; suburb?: string; From 6e5423504bdc8abf3d28e51ead8f91b179c8776e Mon Sep 17 00:00:00 2001 From: hlokomani-tuks <133780278+hlokomani-tuks@users.noreply.github.com> Date: Tue, 1 Oct 2024 03:54:00 +0200 Subject: [PATCH 2/5] Fixed linting error --- frontend/lib/api/fetchIssues.tsx | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/lib/api/fetchIssues.tsx b/frontend/lib/api/fetchIssues.tsx index 1efc11ba..cb3d12b7 100644 --- a/frontend/lib/api/fetchIssues.tsx +++ b/frontend/lib/api/fetchIssues.tsx @@ -31,6 +31,7 @@ const fetchIssues = async ( } if (location) { + // eslint-disable-next-line @typescript-eslint/no-unused-vars const { location_id, ...locationWithoutId } = location; requestBody.location = locationWithoutId; } From 270e5b067e4a7c82288443bb47d9243156797caa Mon Sep 17 00:00:00 2001 From: hlokomani-tuks <133780278+hlokomani-tuks@users.noreply.github.com> Date: Tue, 1 Oct 2024 04:05:31 +0200 Subject: [PATCH 3/5] fix --- backend/src/modules/issues/repositories/issueRepository.ts | 2 +- frontend/lib/api/fetchIssues.tsx | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/backend/src/modules/issues/repositories/issueRepository.ts b/backend/src/modules/issues/repositories/issueRepository.ts index d5e5b9c3..2e1dc17e 100644 --- a/backend/src/modules/issues/repositories/issueRepository.ts +++ b/backend/src/modules/issues/repositories/issueRepository.ts @@ -48,7 +48,7 @@ export default class IssueRepository { category: category_id ( name ), - location: location_id ( + location: location_id!inner ( province, city, suburb, diff --git a/frontend/lib/api/fetchIssues.tsx b/frontend/lib/api/fetchIssues.tsx index cb3d12b7..4e08e7f3 100644 --- a/frontend/lib/api/fetchIssues.tsx +++ b/frontend/lib/api/fetchIssues.tsx @@ -31,9 +31,7 @@ const fetchIssues = async ( } if (location) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars - const { location_id, ...locationWithoutId } = location; - requestBody.location = locationWithoutId; + requestBody.location = location; } const url = `${process.env.NEXT_PUBLIC_BACKEND_URL}/api/issues`; From 4b1725b0dbba8b1b3ba3c545baa28b8de9401431 Mon Sep 17 00:00:00 2001 From: hlokomani-tuks <133780278+hlokomani-tuks@users.noreply.github.com> Date: Tue, 1 Oct 2024 04:08:40 +0200 Subject: [PATCH 4/5] handled possible null location for orgs --- frontend/app/(home)/organization/page.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/app/(home)/organization/page.tsx b/frontend/app/(home)/organization/page.tsx index c49f8780..98dcbf5c 100644 --- a/frontend/app/(home)/organization/page.tsx +++ b/frontend/app/(home)/organization/page.tsx @@ -175,8 +175,8 @@ export default function OrganizationPage() { items: [ { value: "all", label: "All Locations" }, ...(locations?.map(loc => ({ - value: loc.location_id.toString(), - label: `${loc.suburb ? loc.suburb + ", " : ""}${loc.city}, ${loc.province}`, + value: loc.location_id?.toString() ?? '', + label: `${loc.suburb ? loc.suburb + ", " : ""}${loc.city ?? ''}, ${loc.province ?? ''}`, })) || []), ], }; From c2ef270d1bd04680c87df5bc7101cf9e114a1ed1 Mon Sep 17 00:00:00 2001 From: hlokomani-tuks <133780278+hlokomani-tuks@users.noreply.github.com> Date: Tue, 1 Oct 2024 04:14:56 +0200 Subject: [PATCH 5/5] Reverted optional location_id --- frontend/lib/types.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/lib/types.ts b/frontend/lib/types.ts index e3f06871..8b8c4b60 100644 --- a/frontend/lib/types.ts +++ b/frontend/lib/types.ts @@ -452,7 +452,7 @@ interface AnalysisResult { } interface Location { - location_id?: string; + location_id: string; province?: string; city?: string; suburb?: string;