Skip to content

Commit

Permalink
Merge pull request #2112 from ever-co/feat/static-build-support-7
Browse files Browse the repository at this point in the history
Feat/Next-Frontend APIs
  • Loading branch information
evereq authored Jan 24, 2024
2 parents 25bedac + 78672d0 commit 900bf62
Show file tree
Hide file tree
Showing 15 changed files with 186 additions and 158 deletions.
28 changes: 14 additions & 14 deletions apps/web/app/api/public/team/[profileLink]/[teamId]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
32 changes: 16 additions & 16 deletions apps/web/app/api/roles/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
37 changes: 18 additions & 19 deletions apps/web/app/api/task-related-issue-types/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,39 @@ 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(
await deleteTaskRelatedIssueTypeRequest({
id,
bearer_token: access_token,
tenantId
})
);
const response = await deleteTaskRelatedIssueTypeRequest({
id,
bearer_token: access_token,
tenantId
});

return $res(response.data);
}
4 changes: 3 additions & 1 deletion apps/web/app/api/task-related-issue-types/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
39 changes: 20 additions & 19 deletions apps/web/app/api/task-sizes/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,38 +3,39 @@ 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;

const response = await deleteTaskSizesRequest({
id,
bearer_token: access_token,
tenantId
});

return $res(
await deleteTaskSizesRequest({
id,
bearer_token: access_token,
tenantId
})
);
return $res(response.data);
}
4 changes: 3 additions & 1 deletion apps/web/app/api/task-sizes/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
35 changes: 18 additions & 17 deletions apps/web/app/api/task-statuses/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -12,29 +12,30 @@ 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);

if (!user) return $res('Unauthorized');

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);
}
4 changes: 3 additions & 1 deletion apps/web/app/api/task-statuses/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
22 changes: 11 additions & 11 deletions apps/web/app/hooks/features/usePublicOrganizationTeams.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -46,31 +46,31 @@ export function usePublicOrganizationTeams() {
const newData = [
{
...updatedTeams[0],
...res.data.data
...res.data
}
];

if (!isEqual(newData, updatedTeams)) {
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);
Expand All @@ -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;
Expand Down
Loading

0 comments on commit 900bf62

Please sign in to comment.