From 32393e9ff5aa242f9415747e4be9d8671a7de383 Mon Sep 17 00:00:00 2001 From: Paradoxe Ngwasi Date: Tue, 23 Jan 2024 05:55:14 +0000 Subject: [PATCH 01/12] implement GET public/team apis frontend --- .../team/[profileLink]/[teamId]/route.ts | 28 ++++----- .../features/usePublicOrganizationTeams.ts | 22 +++---- .../client/api/public-organization-team.ts | 59 ++++++++++++++++--- 3 files changed, 76 insertions(+), 33 deletions(-) diff --git a/apps/web/app/api/public/team/[profileLink]/[teamId]/route.ts b/apps/web/app/api/public/team/[profileLink]/[teamId]/route.ts index ae8430811..861839fe0 100644 --- a/apps/web/app/api/public/team/[profileLink]/[teamId]/route.ts +++ b/apps/web/app/api/public/team/[profileLink]/[teamId]/route.ts @@ -4,24 +4,24 @@ import { } from '@app/services/server/requests/public-organization-team'; import { NextResponse } from 'next/server'; -export async function GET(req: Request, { params }: { params: { profileLink: string; teamId: string } }) { +export async function GET(req: Request, { params }: { params: { profileLink: string; teamId: string } }) { const { searchParams } = new URL(req.url); - const { profileLink, teamId, } = params; - const { type } = searchParams as unknown as {type: string;}; + const { profileLink, teamId } = params; + const { type } = searchParams as unknown as { type: string }; if (type === 'misc') { - return NextResponse.json( - await getPublicOrganizationTeamMiscDataRequest({ - profileLink: profileLink, - teamId - }) - ); - } - return NextResponse.json( - await getPublicOrganizationTeamRequest({ + const response = await getPublicOrganizationTeamMiscDataRequest({ profileLink: profileLink, teamId - }) - ); + }); + + return NextResponse.json(response.data); + } + + const response = await getPublicOrganizationTeamRequest({ + profileLink: profileLink, + teamId + }); + return NextResponse.json(response.data); } diff --git a/apps/web/app/hooks/features/usePublicOrganizationTeams.ts b/apps/web/app/hooks/features/usePublicOrganizationTeams.ts index 468f14832..7467f68a6 100644 --- a/apps/web/app/hooks/features/usePublicOrganizationTeams.ts +++ b/apps/web/app/hooks/features/usePublicOrganizationTeams.ts @@ -36,7 +36,7 @@ export function usePublicOrganizationTeams() { } return queryCall(profileLink, teamId).then((res) => { - if (res.data?.data?.status === 404) { + if (res.data.status === 404) { setTeams([]); return res; } @@ -46,7 +46,7 @@ export function usePublicOrganizationTeams() { const newData = [ { ...updatedTeams[0], - ...res.data.data + ...res.data } ]; @@ -54,23 +54,23 @@ export function usePublicOrganizationTeams() { setTeams([ { ...updatedTeams[0], - ...res.data.data + ...res.data } ]); } } else { - setTeams([res.data.data]); + setTeams([res.data]); } const newPublicTeamData = { ...publicTeam, - ...res.data.data + ...res.data }; if (!isEqual(newPublicTeamData, publicTeam)) { setPublicTeam(newPublicTeamData); } - let responseTasks = (res.data?.data?.tasks as ITeamTask[]) || []; + let responseTasks = (res.data.tasks as ITeamTask[]) || []; if (responseTasks && responseTasks.length) { responseTasks = responseTasks.map((task) => { const clone = cloneDeep(task); @@ -92,16 +92,16 @@ export function usePublicOrganizationTeams() { const loadPublicTeamMiscData = useCallback( (profileLink: string, teamId: string) => { return queryCallMiscData(profileLink, teamId).then((res) => { - if (res.data?.data?.status === 404) { + if (res.data.status === 404) { setTeams([]); return res; } if (res.data) { - setTaskStatus(res.data.data?.statuses || []); - setTaskSizes(res.data.data?.sizes || []); - setTaskPriorities(res.data.data?.priorities || []); - setTaskLabels(res.data.data?.labels || []); + setTaskStatus(res.data?.statuses || []); + setTaskSizes(res.data?.sizes || []); + setTaskPriorities(res.data?.priorities || []); + setTaskLabels(res.data?.labels || []); } return res; diff --git a/apps/web/app/services/client/api/public-organization-team.ts b/apps/web/app/services/client/api/public-organization-team.ts index cdef52033..dc77a87a5 100644 --- a/apps/web/app/services/client/api/public-organization-team.ts +++ b/apps/web/app/services/client/api/public-organization-team.ts @@ -1,14 +1,57 @@ -import { IOrganizationTeamList, CreateResponse, IDataResponse } from '@app/interfaces'; -import api from '../axios'; +import { IDataResponse } from '@app/interfaces'; +import { get } from '../axios'; +import moment from 'moment'; +import { GAUZY_API_BASE_SERVER_URL } from '@app/constants'; export function getPublicOrganizationTeamsAPI(profile_link: string, team_id: string) { - return api.get | IDataResponse>( - `/public/team/${profile_link}/${team_id}?type=team` - ); + const relations = [ + 'tasks', + 'tasks.members', + 'tasks.teams', + 'tasks.tags', + 'members', + // 'members.role', + 'members.employee', + 'members.employee.user' + ]; + + const params = { + withLaskWorkedTask: 'true', + startDate: moment().startOf('day').toISOString(), + endDate: moment().endOf('day').toISOString() + } as { [x: string]: string }; + + relations.forEach((rl, i) => { + params[`relations[${i}]`] = rl; + }); + + const queries = new URLSearchParams(params || {}); + + const endpoint = GAUZY_API_BASE_SERVER_URL.value + ? `/public/team/${profile_link}/${team_id}?${queries.toString()}` + : `/public/team/${profile_link}/${team_id}?type=team`; + + return get(endpoint); } export function getPublicOrganizationTeamsMiscDataAPI(profile_link: string, team_id: string) { - return api.get | IDataResponse>( - `/public/team/${profile_link}/${team_id}?type=misc` - ); + const relations = ['statuses', 'priorities', 'sizes', 'labels', 'issueTypes']; + + const params = { + withLaskWorkedTask: 'true', + startDate: moment().startOf('day').toISOString(), + endDate: moment().endOf('day').toISOString() + } as { [x: string]: string }; + + relations.forEach((rl, i) => { + params[`relations[${i}]`] = rl; + }); + + const queries = new URLSearchParams(params || {}); + + const endpoint = GAUZY_API_BASE_SERVER_URL.value + ? `/public/team/${profile_link}/${team_id}?${queries.toString()}` + : `/public/team/${profile_link}/${team_id}?type=misc`; + + return get(endpoint); } From 2f0ebf5b05dd7fa4d73d01e726f42734f9748d00 Mon Sep 17 00:00:00 2001 From: Paradoxe Ngwasi Date: Tue, 23 Jan 2024 06:03:48 +0000 Subject: [PATCH 02/12] implement PUT /roles apis frontend --- apps/web/app/api/roles/[id]/route.ts | 32 +++++++++++------------ apps/web/app/services/client/api/roles.ts | 6 ++--- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/apps/web/app/api/roles/[id]/route.ts b/apps/web/app/api/roles/[id]/route.ts index 1654f262f..94bf659bc 100644 --- a/apps/web/app/api/roles/[id]/route.ts +++ b/apps/web/app/api/roles/[id]/route.ts @@ -10,29 +10,29 @@ export async function PUT(req: Request) { if (!user) return $res('unauthorized'); const body = (await req.json()) as IRole; - return $res( - await updateRoleRequest({ - bearer_token: access_token, - tenantId, - data: body - }) - ); + const response = await updateRoleRequest({ + bearer_token: access_token, + tenantId, + data: body + }); + + return $res(response.data); } -export async function DELETE(req: Request, { params }: { params: { id: string } }) { +export async function DELETE(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); if (!user) return $res('unauthorized'); - const { id } = params + const { id } = params; + + const response = await deleteRoleRequest({ + id: id as string, + bearer_token: access_token, + tenantId + }); - return $res( - await deleteRoleRequest({ - id: id as string, - bearer_token: access_token, - tenantId - }) - ); + return $res(response.data); } diff --git a/apps/web/app/services/client/api/roles.ts b/apps/web/app/services/client/api/roles.ts index c1e88d5ab..7b489bb87 100644 --- a/apps/web/app/services/client/api/roles.ts +++ b/apps/web/app/services/client/api/roles.ts @@ -1,5 +1,5 @@ import { IRole, PaginationResponse } from '@app/interfaces'; -import api, { get, post } from '../axios'; +import { deleteApi, get, post, put } from '../axios'; export function getRolesAPI() { return get>('/roles'); @@ -10,9 +10,9 @@ export function createRoleAPI(data: IRole) { } export function deleteRoleAPI(id: string) { - return api.delete(`/roles/${id}`); + return deleteApi(`/roles/${id}`); } export function updateRoleAPI(data: IRole) { - return api.put(`/roles/${data.id}`, data); + return put(`/roles/${data.id}`, data); } From 9cd8820ae2e45587ab7ba36a62916381d7008feb Mon Sep 17 00:00:00 2001 From: Paradoxe Ngwasi Date: Tue, 23 Jan 2024 06:11:29 +0000 Subject: [PATCH 03/12] implement POST tasks/task-linked-issue apis frontend --- apps/web/app/services/client/api/task-linked-issue.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apps/web/app/services/client/api/task-linked-issue.ts b/apps/web/app/services/client/api/task-linked-issue.ts index fad777e91..a2038ac36 100644 --- a/apps/web/app/services/client/api/task-linked-issue.ts +++ b/apps/web/app/services/client/api/task-linked-issue.ts @@ -1,10 +1,13 @@ import { ITaskLinkedIssue, ITaskLinkedIssueResponse, LinkedTaskIssue } from '@app/interfaces'; -import api from '../axios'; +import { post, put } from '../axios'; +import { GAUZY_API_BASE_SERVER_URL } from '@app/constants'; export function createTaskLinkedIsssueAPI(data: ITaskLinkedIssue) { - return api.post('/tasks/task-linked-issue', data); + const endpoint = GAUZY_API_BASE_SERVER_URL.value ? '/task-linked-issue' : '/tasks/task-linked-issue'; + return post(endpoint, data); } export function updateTaskLinkedIssueAPI(data: LinkedTaskIssue) { - return api.put('/tasks/task-linked-issue', data); + const endpoint = GAUZY_API_BASE_SERVER_URL.value ? `/task-linked-issue/${data.id}` : '/tasks/task-linked-issue'; + return put(endpoint, data); } From a84518dd295d4b342162e09a5ac08c9cb2b0064d Mon Sep 17 00:00:00 2001 From: Paradoxe Ngwasi Date: Tue, 23 Jan 2024 06:33:24 +0000 Subject: [PATCH 04/12] implement POST /task-related-issue-types api frontend --- .../task-related-issue-types/[id]/route.ts | 23 +++++++++---------- .../app/api/task-related-issue-types/route.ts | 4 +++- .../client/api/task-related-issue-type.ts | 15 ++++-------- 3 files changed, 19 insertions(+), 23 deletions(-) diff --git a/apps/web/app/api/task-related-issue-types/[id]/route.ts b/apps/web/app/api/task-related-issue-types/[id]/route.ts index 86e9f972f..0a6dffba9 100644 --- a/apps/web/app/api/task-related-issue-types/[id]/route.ts +++ b/apps/web/app/api/task-related-issue-types/[id]/route.ts @@ -6,33 +6,32 @@ import { } from '@app/services/server/requests/task-related-issue-type'; import { NextResponse } from 'next/server'; -export async function PUT(req: Request, { params }: { params: { id: string } }) { +export async function PUT(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); if (!user) return $res('Unauthorized'); - const { id } = params; const datas = (await req.json()) as unknown as ITaskRelatedIssueTypeCreate; - return $res( - await editTaskRelatedIssueTypeRequest({ - id, - datas, - bearer_token: access_token, - tenantId - }) - ); + + const response = await editTaskRelatedIssueTypeRequest({ + id, + datas, + bearer_token: access_token, + tenantId + }); + + return $res(response.data); } -export async function DELETE(req: Request, { params }: { params: { id: string } }) { +export async function DELETE(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); if (!user) return $res('Unauthorized'); - const { id } = params; return $res( diff --git a/apps/web/app/api/task-related-issue-types/route.ts b/apps/web/app/api/task-related-issue-types/route.ts index 4f6a2ac6c..79ca45f1b 100644 --- a/apps/web/app/api/task-related-issue-types/route.ts +++ b/apps/web/app/api/task-related-issue-types/route.ts @@ -35,5 +35,7 @@ export async function POST(req: Request) { const body = (await req.json()) as unknown as ITaskRelatedIssueTypeCreate; - return $res(await createRelatedIssueTypeRequest(body, access_token, body?.tenantId)); + const response = await createRelatedIssueTypeRequest(body, access_token, body?.tenantId); + + return $res(response.data); } diff --git a/apps/web/app/services/client/api/task-related-issue-type.ts b/apps/web/app/services/client/api/task-related-issue-type.ts index 87c07820c..183cc91cf 100644 --- a/apps/web/app/services/client/api/task-related-issue-type.ts +++ b/apps/web/app/services/client/api/task-related-issue-type.ts @@ -1,25 +1,20 @@ import { - CreateResponse, DeleteResponse, ITaskRelatedIssueTypeCreate, ITaskRelatedIssueTypeItemList, PaginationResponse } from '@app/interfaces'; -import api, { get } from '../axios'; +import api, { get, post, put } from '../axios'; export function createTaskRelatedIssueTypeAPI(data: ITaskRelatedIssueTypeCreate, tenantId?: string) { - return api.post>('/task-related-issue-types', data, { - headers: { - 'Tenant-Id': tenantId - } + return post('/task-related-issue-types', data, { + tenantId }); } export function editTaskRelatedIssueTypeAPI(id: string, data: ITaskRelatedIssueTypeCreate, tenantId?: string) { - return api.put>(`/task-related-issue-types/${id}`, data, { - headers: { - 'Tenant-Id': tenantId - } + return put(`/task-related-issue-types/${id}`, data, { + tenantId }); } From 7814227bcf19fef1fa6e7caa4585205bdbbd49e5 Mon Sep 17 00:00:00 2001 From: Paradoxe Ngwasi Date: Tue, 23 Jan 2024 06:38:19 +0000 Subject: [PATCH 05/12] implement DEL /task-related-issue-types/:id api frontend --- .../app/api/task-related-issue-types/[id]/route.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/apps/web/app/api/task-related-issue-types/[id]/route.ts b/apps/web/app/api/task-related-issue-types/[id]/route.ts index 0a6dffba9..c8b3245a4 100644 --- a/apps/web/app/api/task-related-issue-types/[id]/route.ts +++ b/apps/web/app/api/task-related-issue-types/[id]/route.ts @@ -34,11 +34,11 @@ export async function DELETE(req: Request, { params }: { params: { id: string } const { id } = params; - return $res( - await deleteTaskRelatedIssueTypeRequest({ - id, - bearer_token: access_token, - tenantId - }) - ); + const response = await deleteTaskRelatedIssueTypeRequest({ + id, + bearer_token: access_token, + tenantId + }); + + return $res(response.data); } From b9a4a8a1b72345b491aa819c7f3062d066b34d20 Mon Sep 17 00:00:00 2001 From: Paradoxe Ngwasi Date: Tue, 23 Jan 2024 06:38:26 +0000 Subject: [PATCH 06/12] implement PUT /task-related-issue-types/:id api frontend --- apps/web/app/services/client/api/task-related-issue-type.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/apps/web/app/services/client/api/task-related-issue-type.ts b/apps/web/app/services/client/api/task-related-issue-type.ts index 183cc91cf..c9f8d3d77 100644 --- a/apps/web/app/services/client/api/task-related-issue-type.ts +++ b/apps/web/app/services/client/api/task-related-issue-type.ts @@ -4,7 +4,7 @@ import { ITaskRelatedIssueTypeItemList, PaginationResponse } from '@app/interfaces'; -import api, { get, post, put } from '../axios'; +import { deleteApi, get, post, put } from '../axios'; export function createTaskRelatedIssueTypeAPI(data: ITaskRelatedIssueTypeCreate, tenantId?: string) { return post('/task-related-issue-types', data, { @@ -19,7 +19,7 @@ export function editTaskRelatedIssueTypeAPI(id: string, data: ITaskRelatedIssueT } export function deleteTaskRelatedIssueTypeAPI(id: string) { - return api.delete(`/task-related-issue-types/${id}`); + return deleteApi(`/task-related-issue-types/${id}`); } export async function getTaskRelatedIssueTypeList( From c06dd2ea65ca268d62d2c5c4efc8070395639964 Mon Sep 17 00:00:00 2001 From: Paradoxe Ngwasi Date: Tue, 23 Jan 2024 06:45:32 +0000 Subject: [PATCH 07/12] implement POST /task-sizes api frontend --- apps/web/app/api/task-sizes/route.ts | 4 +++- apps/web/app/services/client/api/task-sizes.ts | 8 +++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/web/app/api/task-sizes/route.ts b/apps/web/app/api/task-sizes/route.ts index 4b9cf60c4..ffe1a8daa 100644 --- a/apps/web/app/api/task-sizes/route.ts +++ b/apps/web/app/api/task-sizes/route.ts @@ -32,5 +32,7 @@ export async function POST(req: Request) { const body = (await req.json()) as unknown as ITaskSizesCreate; - return $res(await createSizesRequest(body, access_token, body?.tenantId)); + const response = await createSizesRequest(body, access_token, body?.tenantId); + + return $res(response.data); } diff --git a/apps/web/app/services/client/api/task-sizes.ts b/apps/web/app/services/client/api/task-sizes.ts index ebedd4c58..16b289ed4 100644 --- a/apps/web/app/services/client/api/task-sizes.ts +++ b/apps/web/app/services/client/api/task-sizes.ts @@ -5,13 +5,11 @@ import { ITaskSizesItemList, PaginationResponse } from '@app/interfaces'; -import api, { get } from '../axios'; +import api, { get, post } from '../axios'; export function createTaskSizesAPI(data: ITaskSizesCreate, tenantId?: string) { - return api.post>('/task-sizes', data, { - headers: { - 'Tenant-Id': tenantId - } + return post('/task-sizes', data, { + tenantId }); } From a035c742c02d2842514c288a7082590abb9b23a3 Mon Sep 17 00:00:00 2001 From: Paradoxe Ngwasi Date: Tue, 23 Jan 2024 06:49:25 +0000 Subject: [PATCH 08/12] implement PUT task-sizes/:id api frontend --- apps/web/app/api/task-sizes/[id]/route.ts | 25 ++++++++++--------- .../web/app/services/client/api/task-sizes.ts | 16 +++--------- 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/apps/web/app/api/task-sizes/[id]/route.ts b/apps/web/app/api/task-sizes/[id]/route.ts index d54aba1a0..0ed26ebaa 100644 --- a/apps/web/app/api/task-sizes/[id]/route.ts +++ b/apps/web/app/api/task-sizes/[id]/route.ts @@ -3,32 +3,33 @@ import { authenticatedGuard } from '@app/services/server/guards/authenticated-gu import { deleteTaskSizesRequest, editTaskSizesRequest } from '@app/services/server/requests'; import { NextResponse } from 'next/server'; -export async function PUT(req: Request, { params }: { params: { id: string } }) { +export async function PUT(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); if (!user) return $res('Unauthorized'); - const { id } = params + const { id } = params; const datas = (await req.json()) as unknown as ITaskSizesCreate; - return $res( - await editTaskSizesRequest({ - id, - datas, - bearer_token: access_token, - tenantId - }) - ); + + const response = await editTaskSizesRequest({ + id, + datas, + bearer_token: access_token, + tenantId + }); + + return $res(response.data); } -export async function DELETE(req: Request, { params }: { params: { id: string } }) { +export async function DELETE(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); if (!user) return $res('Unauthorized'); - const { id } = params + const { id } = params; return $res( await deleteTaskSizesRequest({ diff --git a/apps/web/app/services/client/api/task-sizes.ts b/apps/web/app/services/client/api/task-sizes.ts index 16b289ed4..5c9cec436 100644 --- a/apps/web/app/services/client/api/task-sizes.ts +++ b/apps/web/app/services/client/api/task-sizes.ts @@ -1,11 +1,5 @@ -import { - CreateResponse, - DeleteResponse, - ITaskSizesCreate, - ITaskSizesItemList, - PaginationResponse -} from '@app/interfaces'; -import api, { get, post } from '../axios'; +import { DeleteResponse, ITaskSizesCreate, ITaskSizesItemList, PaginationResponse } from '@app/interfaces'; +import api, { get, post, put } from '../axios'; export function createTaskSizesAPI(data: ITaskSizesCreate, tenantId?: string) { return post('/task-sizes', data, { @@ -14,10 +8,8 @@ export function createTaskSizesAPI(data: ITaskSizesCreate, tenantId?: string) { } export function editTaskSizesAPI(id: string, data: ITaskSizesCreate, tenantId?: string) { - return api.put>(`/task-sizes/${id}`, data, { - headers: { - 'Tenant-Id': tenantId - } + return put(`/task-sizes/${id}`, data, { + tenantId }); } From e517580ca22d649ea1acbcc92a35958ab8456151 Mon Sep 17 00:00:00 2001 From: Paradoxe Ngwasi Date: Tue, 23 Jan 2024 06:50:51 +0000 Subject: [PATCH 09/12] implement DEL task-sizes/:id api frontend --- apps/web/app/api/task-sizes/[id]/route.ts | 14 +++++++------- apps/web/app/services/client/api/task-sizes.ts | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/web/app/api/task-sizes/[id]/route.ts b/apps/web/app/api/task-sizes/[id]/route.ts index 0ed26ebaa..ab9644f12 100644 --- a/apps/web/app/api/task-sizes/[id]/route.ts +++ b/apps/web/app/api/task-sizes/[id]/route.ts @@ -31,11 +31,11 @@ export async function DELETE(req: Request, { params }: { params: { id: string } const { id } = params; - return $res( - await deleteTaskSizesRequest({ - id, - bearer_token: access_token, - tenantId - }) - ); + const response = await deleteTaskSizesRequest({ + id, + bearer_token: access_token, + tenantId + }); + + return $res(response.data); } diff --git a/apps/web/app/services/client/api/task-sizes.ts b/apps/web/app/services/client/api/task-sizes.ts index 5c9cec436..3f0551125 100644 --- a/apps/web/app/services/client/api/task-sizes.ts +++ b/apps/web/app/services/client/api/task-sizes.ts @@ -1,5 +1,5 @@ import { DeleteResponse, ITaskSizesCreate, ITaskSizesItemList, PaginationResponse } from '@app/interfaces'; -import api, { get, post, put } from '../axios'; +import { deleteApi, get, post, put } from '../axios'; export function createTaskSizesAPI(data: ITaskSizesCreate, tenantId?: string) { return post('/task-sizes', data, { @@ -14,7 +14,7 @@ export function editTaskSizesAPI(id: string, data: ITaskSizesCreate, tenantId?: } export function deleteTaskSizesAPI(id: string) { - return api.delete(`/task-sizes/${id}`); + return deleteApi(`/task-sizes/${id}`); } export async function getTaskSizesList(tenantId: string, organizationId: string, activeTeamId: string | null) { From 60bf9469119c53d5b0e34c73cbf1f8ebec0ef13e Mon Sep 17 00:00:00 2001 From: Paradoxe Ngwasi Date: Tue, 23 Jan 2024 07:00:10 +0000 Subject: [PATCH 10/12] implement task-statuses/:id api frontend --- apps/web/app/api/task-statuses/[id]/route.ts | 21 ++++++++++--------- .../app/services/client/api/task-status.ts | 8 +++---- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/apps/web/app/api/task-statuses/[id]/route.ts b/apps/web/app/api/task-statuses/[id]/route.ts index 64e656609..49299cccc 100644 --- a/apps/web/app/api/task-statuses/[id]/route.ts +++ b/apps/web/app/api/task-statuses/[id]/route.ts @@ -3,7 +3,7 @@ import { authenticatedGuard } from '@app/services/server/guards/authenticated-gu import { deleteTaskStatusRequest, editTaskStatusRequest } from '@app/services/server/requests/taskStatus'; import { NextResponse } from 'next/server'; -export async function PUT(req: Request, { params }: { params: { id: string } }) { +export async function PUT(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); @@ -12,17 +12,18 @@ export async function PUT(req: Request, { params }: { params: { id: string } }) const { id } = params; const datas = (await req.json()) as unknown as ITaskStatusCreate; - return $res( - await editTaskStatusRequest({ - id, - datas, - bearer_token: access_token, - tenantId - }) - ); + + const response = await editTaskStatusRequest({ + id, + datas, + bearer_token: access_token, + tenantId + }); + + return $res(response.data); } -export async function DELETE(req: Request, { params }: { params: { id: string } }) { +export async function DELETE(req: Request, { params }: { params: { id: string } }) { const res = new NextResponse(); const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res); diff --git a/apps/web/app/services/client/api/task-status.ts b/apps/web/app/services/client/api/task-status.ts index e8afdfc7b..8e549e9ab 100644 --- a/apps/web/app/services/client/api/task-status.ts +++ b/apps/web/app/services/client/api/task-status.ts @@ -5,7 +5,7 @@ import { ITaskStatusItemList, PaginationResponse } from '@app/interfaces'; -import api, { get } from '../axios'; +import api, { get, put } from '../axios'; export function createTaskStatusAPI(data: ITaskStatusCreate, tenantId?: string) { return api.post>('/task-statuses', data, { @@ -16,10 +16,8 @@ export function createTaskStatusAPI(data: ITaskStatusCreate, tenantId?: string) } export function editTaskStatusAPI(id: string, data: ITaskStatusCreate, tenantId?: string) { - return api.put>(`/task-statuses/${id}`, data, { - headers: { - 'Tenant-Id': tenantId - } + return put(`/task-statuses/${id}`, data, { + tenantId }); } From db14d6928eff12bfb1e6f36e3bf1cb95e4cf1564 Mon Sep 17 00:00:00 2001 From: Paradoxe Ngwasi Date: Tue, 23 Jan 2024 07:01:13 +0000 Subject: [PATCH 11/12] implement DEL task-statuses/:id api frontend --- apps/web/app/api/task-statuses/[id]/route.ts | 14 +++++++------- apps/web/app/services/client/api/task-status.ts | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/apps/web/app/api/task-statuses/[id]/route.ts b/apps/web/app/api/task-statuses/[id]/route.ts index 49299cccc..2d60edab8 100644 --- a/apps/web/app/api/task-statuses/[id]/route.ts +++ b/apps/web/app/api/task-statuses/[id]/route.ts @@ -31,11 +31,11 @@ export async function DELETE(req: Request, { params }: { params: { id: string } const { id } = params; - return $res( - await deleteTaskStatusRequest({ - id, - bearer_token: access_token, - tenantId - }) - ); + const response = await deleteTaskStatusRequest({ + id, + bearer_token: access_token, + tenantId + }); + + return $res(response.data); } diff --git a/apps/web/app/services/client/api/task-status.ts b/apps/web/app/services/client/api/task-status.ts index 8e549e9ab..cd149a7f0 100644 --- a/apps/web/app/services/client/api/task-status.ts +++ b/apps/web/app/services/client/api/task-status.ts @@ -5,7 +5,7 @@ import { ITaskStatusItemList, PaginationResponse } from '@app/interfaces'; -import api, { get, put } from '../axios'; +import api, { deleteApi, get, put } from '../axios'; export function createTaskStatusAPI(data: ITaskStatusCreate, tenantId?: string) { return api.post>('/task-statuses', data, { @@ -22,7 +22,7 @@ export function editTaskStatusAPI(id: string, data: ITaskStatusCreate, tenantId? } export function deleteTaskStatusAPI(id: string) { - return api.delete(`/task-statuses/${id}`); + return deleteApi(`/task-statuses/${id}`); } export async function getTaskStatusList(tenantId: string, organizationId: string, organizationTeamId: string | null) { From 78672d098a3465741085dea4a62d63bb7f6da37b Mon Sep 17 00:00:00 2001 From: Paradoxe Ngwasi Date: Tue, 23 Jan 2024 07:04:26 +0000 Subject: [PATCH 12/12] implement POST /task-statuses api frontend --- apps/web/app/api/task-statuses/route.ts | 4 +++- apps/web/app/services/client/api/task-status.ts | 16 ++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/apps/web/app/api/task-statuses/route.ts b/apps/web/app/api/task-statuses/route.ts index 58d1e5c09..b23d495f4 100644 --- a/apps/web/app/api/task-statuses/route.ts +++ b/apps/web/app/api/task-statuses/route.ts @@ -32,5 +32,7 @@ export async function POST(req: Request) { const body = (await req.json()) as unknown as ITaskStatusCreate; - return $res(await createStatusRequest(body, access_token, body?.tenantId)); + const response = await createStatusRequest(body, access_token, body?.tenantId); + + return $res(response.data); } diff --git a/apps/web/app/services/client/api/task-status.ts b/apps/web/app/services/client/api/task-status.ts index cd149a7f0..e5f3eecb5 100644 --- a/apps/web/app/services/client/api/task-status.ts +++ b/apps/web/app/services/client/api/task-status.ts @@ -1,17 +1,9 @@ -import { - CreateResponse, - DeleteResponse, - ITaskStatusCreate, - ITaskStatusItemList, - PaginationResponse -} from '@app/interfaces'; -import api, { deleteApi, get, put } from '../axios'; +import { DeleteResponse, ITaskStatusCreate, ITaskStatusItemList, PaginationResponse } from '@app/interfaces'; +import { deleteApi, get, post, put } from '../axios'; export function createTaskStatusAPI(data: ITaskStatusCreate, tenantId?: string) { - return api.post>('/task-statuses', data, { - headers: { - 'Tenant-Id': tenantId - } + return post('/task-statuses', data, { + tenantId }); }