From f0cfb3da315df538282bac25005c6813ec5acb3d Mon Sep 17 00:00:00 2001 From: Paradoxe Ngwasi Date: Wed, 28 Feb 2024 03:48:02 +0000 Subject: [PATCH 1/5] fixed verify/resend-link api --- apps/web/app/services/client/api/auth.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/apps/web/app/services/client/api/auth.ts b/apps/web/app/services/client/api/auth.ts index 4ea9900a8..87c7dcf38 100644 --- a/apps/web/app/services/client/api/auth.ts +++ b/apps/web/app/services/client/api/auth.ts @@ -83,7 +83,9 @@ export const resentVerifyUserLinkAPI = (user: IUser) => { appEmailConfirmationUrl: VERIFY_EMAIL_CALLBACK_URL || appEmailConfirmationUrl }; - return post(`/auth/verify/resend-link`, body); + const endpoint = GAUZY_API_BASE_SERVER_URL.value ? '/auth/email/verify/resend-link' : `/auth/verify/resend-link`; + + return post(endpoint, body); }; export const signInEmailAPI = (email: string) => { From 8f96743cd155a0e2b6feac6480c82de607cd47df Mon Sep 17 00:00:00 2001 From: Paradoxe Ngwasi Date: Wed, 28 Feb 2024 04:45:42 +0000 Subject: [PATCH 2/5] fixed response tasks/team nextjs route --- .../app/api/auth/verify/resend-link/route.ts | 4 +++- apps/web/app/api/tasks/team/route.ts | 21 ++++++++++++++++++- .../web/app/services/server/requests/tasks.ts | 17 +++++++++++++++ 3 files changed, 40 insertions(+), 2 deletions(-) diff --git a/apps/web/app/api/auth/verify/resend-link/route.ts b/apps/web/app/api/auth/verify/resend-link/route.ts index 125acf18d..0b909c0c8 100644 --- a/apps/web/app/api/auth/verify/resend-link/route.ts +++ b/apps/web/app/api/auth/verify/resend-link/route.ts @@ -11,7 +11,9 @@ export async function POST(req: Request) { const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); - if (!user) return $res('Unauthorized'); + if (!user) { + return $res('Unauthorized'); + } const { data } = await resentVerifyUserLinkRequest({ bearer_token: access_token, diff --git a/apps/web/app/api/tasks/team/route.ts b/apps/web/app/api/tasks/team/route.ts index d5cb012c2..07e40c6d1 100644 --- a/apps/web/app/api/tasks/team/route.ts +++ b/apps/web/app/api/tasks/team/route.ts @@ -1,6 +1,6 @@ import { getActiveTeamIdCookie } from '@app/helpers/cookies'; import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app'; -import { createTaskRequest, getTeamTasksRequest } from '@app/services/server/requests'; +import { createTaskRequest, getTeamTasksIRequest, getTeamTasksRequest } from '@app/services/server/requests'; import { NextResponse } from 'next/server'; export async function POST(req: Request) { @@ -52,3 +52,22 @@ export async function POST(req: Request) { return $res(tasks); } + +export async function GET(req: Request) { + const res = new NextResponse(); + const { $res, user, tenantId, access_token } = await authenticatedGuard(req, res); + + const query = new URL(req.url); + + if (!user) { + return $res('Unauthorized'); + } + + const { data: tasks } = await getTeamTasksIRequest({ + tenantId, + bearer_token: access_token, + query: query.searchParams.toString() + }); + + return $res(tasks); +} diff --git a/apps/web/app/services/server/requests/tasks.ts b/apps/web/app/services/server/requests/tasks.ts index 63b751554..61a85c92c 100644 --- a/apps/web/app/services/server/requests/tasks.ts +++ b/apps/web/app/services/server/requests/tasks.ts @@ -54,6 +54,23 @@ export function getTeamTasksRequest({ }); } +export function getTeamTasksIRequest({ + tenantId, + bearer_token, + query +}: { + tenantId: string; + bearer_token: string; + query: string; +}) { + return serverFetch>({ + path: `/tasks/team?${query}`, + method: 'GET', + bearer_token, + tenantId + }); +} + export function getTaskByIdRequest({ tenantId, organizationId, From 71edc30d3a0c404498796428dd9d54243704cd9c Mon Sep 17 00:00:00 2001 From: Paradoxe Ngwasi Date: Wed, 28 Feb 2024 05:17:15 +0000 Subject: [PATCH 3/5] fixed response /invite nextjs route --- apps/web/app/api/invite/route.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/apps/web/app/api/invite/route.ts b/apps/web/app/api/invite/route.ts index 7ffec62c9..5a604edc7 100644 --- a/apps/web/app/api/invite/route.ts +++ b/apps/web/app/api/invite/route.ts @@ -5,7 +5,9 @@ import { NextResponse } from 'next/server'; export async function GET(req: Request) { const res = new NextResponse(); const { $res, user, access_token, tenantId, organizationId, teamId } = await authenticatedGuard(req, res); - if (!user) return NextResponse.json({ error: 'Unauthorized' }); + if (!user) { + return NextResponse.json({ error: 'Unauthorized' }); + } const { data } = await getTeamInvitationsRequest( { @@ -17,5 +19,7 @@ export async function GET(req: Request) { access_token ); - $res(data); + console.log(data); + + return $res(data); } From 4dacc5dc8754df8f467483af4082ae3bc0fe7e6c Mon Sep 17 00:00:00 2001 From: Paradoxe Ngwasi Date: Wed, 28 Feb 2024 05:17:29 +0000 Subject: [PATCH 4/5] tiny changes --- apps/web/app/api/invite/route.ts | 2 -- 1 file changed, 2 deletions(-) diff --git a/apps/web/app/api/invite/route.ts b/apps/web/app/api/invite/route.ts index 5a604edc7..9ba4b00f4 100644 --- a/apps/web/app/api/invite/route.ts +++ b/apps/web/app/api/invite/route.ts @@ -19,7 +19,5 @@ export async function GET(req: Request) { access_token ); - console.log(data); - return $res(data); } From 24851466636aa56edcc53daef604676544670fb0 Mon Sep 17 00:00:00 2001 From: Paradoxe Ngwasi Date: Wed, 28 Feb 2024 05:44:26 +0000 Subject: [PATCH 5/5] fixed: return response for routes that don't --- apps/web/app/api/employee/working/route.ts | 7 +++++-- apps/web/app/api/invite/emails/route.ts | 2 +- apps/web/app/api/invite/resend/route.ts | 2 +- apps/web/app/api/invite/validate-by-code/route.ts | 2 +- .../app/api/organization-projects/setting/[id]/route.ts | 7 +++++-- 5 files changed, 13 insertions(+), 7 deletions(-) diff --git a/apps/web/app/api/employee/working/route.ts b/apps/web/app/api/employee/working/route.ts index be5643a38..061206e17 100644 --- a/apps/web/app/api/employee/working/route.ts +++ b/apps/web/app/api/employee/working/route.ts @@ -5,9 +5,12 @@ import { NextResponse } from 'next/server'; export async function GET(req: Request) { const res = new NextResponse(); const { $res, user, access_token, tenantId, organizationId } = await authenticatedGuard(req, res); - if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); + + if (!user) { + return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); + } const { data } = await getOrganizationEmployees(access_token, tenantId, organizationId); - $res(data); + return $res(data); } diff --git a/apps/web/app/api/invite/emails/route.ts b/apps/web/app/api/invite/emails/route.ts index 0afd5221b..3366f6d1b 100644 --- a/apps/web/app/api/invite/emails/route.ts +++ b/apps/web/app/api/invite/emails/route.ts @@ -65,5 +65,5 @@ export async function POST(req: Request) { access_token ); - $res(data); + return $res(data); } diff --git a/apps/web/app/api/invite/resend/route.ts b/apps/web/app/api/invite/resend/route.ts index 38887c4d8..ba9c6ffca 100644 --- a/apps/web/app/api/invite/resend/route.ts +++ b/apps/web/app/api/invite/resend/route.ts @@ -32,5 +32,5 @@ export async function POST(req: Request) { access_token ); - $res(data); + return $res(data); } diff --git a/apps/web/app/api/invite/validate-by-code/route.ts b/apps/web/app/api/invite/validate-by-code/route.ts index 5338481c2..304b79aff 100644 --- a/apps/web/app/api/invite/validate-by-code/route.ts +++ b/apps/web/app/api/invite/validate-by-code/route.ts @@ -15,5 +15,5 @@ export async function POST(req: Request) { const { data } = await verifyInviteCodeRequest(body); - NextResponse.json(data, { status: 200 }); + return NextResponse.json(data, { status: 200 }); } diff --git a/apps/web/app/api/organization-projects/setting/[id]/route.ts b/apps/web/app/api/organization-projects/setting/[id]/route.ts index ab96a8a0c..aefab205f 100644 --- a/apps/web/app/api/organization-projects/setting/[id]/route.ts +++ b/apps/web/app/api/organization-projects/setting/[id]/route.ts @@ -12,7 +12,10 @@ export async function PUT(req: Request, { params }: INextParams) { } const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); - if (!user) return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); + + if (!user) { + return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); + } const body = await req.json(); @@ -23,5 +26,5 @@ export async function PUT(req: Request, { params }: INextParams) { tenantId }); - $res(response.data); + return $res(response.data); }