Skip to content

Commit

Permalink
Merge pull request #2247 from ever-co/feat/static-build-support-15
Browse files Browse the repository at this point in the history
Tiny Fixes
  • Loading branch information
evereq authored Feb 28, 2024
2 parents feae9d1 + 2485146 commit e93160e
Show file tree
Hide file tree
Showing 10 changed files with 60 additions and 12 deletions.
4 changes: 3 additions & 1 deletion apps/web/app/api/auth/verify/resend-link/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 5 additions & 2 deletions apps/web/app/api/employee/working/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
2 changes: 1 addition & 1 deletion apps/web/app/api/invite/emails/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@ export async function POST(req: Request) {
access_token
);

$res(data);
return $res(data);
}
2 changes: 1 addition & 1 deletion apps/web/app/api/invite/resend/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@ export async function POST(req: Request) {
access_token
);

$res(data);
return $res(data);
}
6 changes: 4 additions & 2 deletions apps/web/app/api/invite/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
{
Expand All @@ -17,5 +19,5 @@ export async function GET(req: Request) {
access_token
);

$res(data);
return $res(data);
}
2 changes: 1 addition & 1 deletion apps/web/app/api/invite/validate-by-code/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
}
7 changes: 5 additions & 2 deletions apps/web/app/api/organization-projects/setting/[id]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -23,5 +26,5 @@ export async function PUT(req: Request, { params }: INextParams) {
tenantId
});

$res(response.data);
return $res(response.data);
}
21 changes: 20 additions & 1 deletion apps/web/app/api/tasks/team/route.ts
Original file line number Diff line number Diff line change
@@ -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) {
Expand Down Expand Up @@ -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);
}
4 changes: 3 additions & 1 deletion apps/web/app/services/client/api/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ export const resentVerifyUserLinkAPI = (user: IUser) => {
appEmailConfirmationUrl: VERIFY_EMAIL_CALLBACK_URL || appEmailConfirmationUrl
};

return post<ISuccessResponse>(`/auth/verify/resend-link`, body);
const endpoint = GAUZY_API_BASE_SERVER_URL.value ? '/auth/email/verify/resend-link' : `/auth/verify/resend-link`;

return post<ISuccessResponse>(endpoint, body);
};

export const signInEmailAPI = (email: string) => {
Expand Down
17 changes: 17 additions & 0 deletions apps/web/app/services/server/requests/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,23 @@ export function getTeamTasksRequest({
});
}

export function getTeamTasksIRequest({
tenantId,
bearer_token,
query
}: {
tenantId: string;
bearer_token: string;
query: string;
}) {
return serverFetch<PaginationResponse<ITeamTask>>({
path: `/tasks/team?${query}`,
method: 'GET',
bearer_token,
tenantId
});
}

export function getTaskByIdRequest({
tenantId,
organizationId,
Expand Down

0 comments on commit e93160e

Please sign in to comment.