Skip to content

Commit

Permalink
Merge pull request #2516 from ever-co/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
evereq authored May 13, 2024
2 parents b3711a0 + 2f7cd34 commit f41b4cb
Show file tree
Hide file tree
Showing 27 changed files with 504 additions and 292 deletions.
3 changes: 2 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@
"comparization",
"plan",
"setwork",
"Clik"
"Clik",
"Relationnal"
],
"useGitignore": true,
"ignorePaths": [
Expand Down
37 changes: 18 additions & 19 deletions apps/web/app/[locale]/auth/passcode/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,23 +139,23 @@ function PasscodeScreen({ form, className }: { form: TAuthenticationPasscode } &
const [disabled, setDisabled] = useState(true);

useEffect(() => {
let interval: NodeJS.Timeout | undefined = undefined;
if (timer > 0) {
interval = setInterval(() => {
setTimer((prevTimer) => prevTimer - 1);
}, 1000);
} else {
setDisabled(false);
clearInterval(interval);
}
let interval: NodeJS.Timeout | undefined = undefined;
if (timer > 0) {
interval = setInterval(() => {
setTimer((prevTimer) => prevTimer - 1);
}, 1000);
} else {
setDisabled(false);
clearInterval(interval);
}

return () => clearInterval(interval);
}, [timer]);
return () => clearInterval(interval);
}, [timer]);

const handleResendClick = () => {
setDisabled(true);
setTimer(60);
};
const handleResendClick = () => {
setDisabled(true);
setTimer(60);
};

const resetForm = () => {
if (inputsRef.current) {
Expand Down Expand Up @@ -239,8 +239,7 @@ function PasscodeScreen({ form, className }: { form: TAuthenticationPasscode } &
</span>
) : (
<span className=" dark:text-primary-light">
{t('pages.auth.RESEND_CODE_IN')} {' '}
{formatTime(timer)}
{t('pages.auth.RESEND_CODE_IN')} {formatTime(timer)}
</span>
)}
</button>
Expand Down Expand Up @@ -358,7 +357,7 @@ export function WorkSpaceComponent(props: IWorkSpace) {
<Text.Heading as="h3" className="text-center">
{t('pages.auth.SELECT_WORKSPACE')}
</Text.Heading>
<ScrollArea className='h-64 relative w-full pr-2 '>
<ScrollArea className="h-64 relative w-full pr-2 ">
<div className="flex flex-col gap-y-4 ">
{props.workspaces?.map((worksace, index) => (
<div
Expand Down Expand Up @@ -434,7 +433,7 @@ export function WorkSpaceComponent(props: IWorkSpace) {
</div>
))}
</div>
<ScrollBar className='-pr-20'/>
<ScrollBar className="-pr-20" />
</ScrollArea>
<div className="flex items-center justify-between w-full">
<div className="flex flex-col space-y-2">
Expand Down
8 changes: 4 additions & 4 deletions apps/web/app/[locale]/auth/passcode/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants';
// import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants';
import AuthPasscode from './component';

export async function generateStaticParams() {
return [{ locale: APPLICATION_DEFAULT_LANGUAGE }];
}
// export function generateStaticParams() {
// return [{ locale: APPLICATION_DEFAULT_LANGUAGE }];
// }

export default function Page() {
return <AuthPasscode />;
Expand Down
8 changes: 4 additions & 4 deletions apps/web/app/[locale]/auth/password/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants';
// import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants';
import AuthPassword from './component';

export async function generateStaticParams() {
return [{ locale: APPLICATION_DEFAULT_LANGUAGE }];
}
// export async function generateStaticParams() {
// return [{ locale: APPLICATION_DEFAULT_LANGUAGE }];
// }

export default function Page() {
return <AuthPassword />;
Expand Down
8 changes: 4 additions & 4 deletions apps/web/app/[locale]/auth/team/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants';
// import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants';
import AuthTeam from './component';

export async function generateStaticParams() {
return [{ locale: APPLICATION_DEFAULT_LANGUAGE }];
}
// export async function generateStaticParams() {
// return [{ locale: APPLICATION_DEFAULT_LANGUAGE }];
// }

export default function Page() {
return <AuthTeam />;
Expand Down
8 changes: 4 additions & 4 deletions apps/web/app/[locale]/board/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants';
// import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants';
import BoardPage from './component';

export async function generateStaticParams() {
return [{ locale: APPLICATION_DEFAULT_LANGUAGE }];
}
// export async function generateStaticParams() {
// return [{ locale: APPLICATION_DEFAULT_LANGUAGE }];
// }

export default function Page() {
return <BoardPage />;
Expand Down
8 changes: 4 additions & 4 deletions apps/web/app/[locale]/integration/github/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants';
// import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants';
import GitHubPage from './component';

export async function generateStaticParams() {
return [{ locale: APPLICATION_DEFAULT_LANGUAGE }];
}
// export async function generateStaticParams() {
// return [{ locale: APPLICATION_DEFAULT_LANGUAGE }];
// }

export default function Page() {
return <GitHubPage />;
Expand Down
8 changes: 4 additions & 4 deletions apps/web/app/[locale]/meet/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants';
// import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants';
import MeetPage from './component';

export default function Page() {
return <MeetPage />;
}

export async function generateStaticParams() {
return [{ locale: APPLICATION_DEFAULT_LANGUAGE }];
}
// export async function generateStaticParams() {
// return [{ locale: APPLICATION_DEFAULT_LANGUAGE }];
// }
7 changes: 3 additions & 4 deletions apps/web/app/[locale]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants';
import MainPage from './page-component';

export async function generateStaticParams() {
return [{ locale: APPLICATION_DEFAULT_LANGUAGE }];
}
// export async function generateStaticParams() {
// return [{ locale: APPLICATION_DEFAULT_LANGUAGE }];
// }

export default function Page() {
return <MainPage />;
Expand Down
8 changes: 4 additions & 4 deletions apps/web/app/[locale]/permissions/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants';
// import { APPLICATION_DEFAULT_LANGUAGE } from '@app/constants';
import PermissionPage from './component';

export default function Page() {
return <PermissionPage />;
}

export async function generateStaticParams() {
return [{ locale: APPLICATION_DEFAULT_LANGUAGE }];
}
// export async function generateStaticParams() {
// return [{ locale: APPLICATION_DEFAULT_LANGUAGE }];
// }
29 changes: 25 additions & 4 deletions apps/web/app/api/daily-plan/[id]/route.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NextResponse } from 'next/server';
import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app';
import { getDayPlansByEmployee, updatePlanRequest } from '@app/services/server/requests';
import { ICreateDailyPlan, INextParams } from '@app/interfaces';
import { deleteDailyPlanRequest, getDayPlansByEmployee, updatePlanRequest } from '@app/services/server/requests';
import { INextParams, IUpdateDailyPlan } from '@app/interfaces';

export async function GET(req: Request, { params }: INextParams) {
const res = new NextResponse();
Expand Down Expand Up @@ -30,8 +30,11 @@ export async function PUT(req: Request, { params }: INextParams) {
return;
}

const { $res, access_token, tenantId } = await authenticatedGuard(req, res);
const body = (await req.json()) as unknown as Partial<ICreateDailyPlan>;
const { $res, user, access_token, tenantId } = await authenticatedGuard(req, res);

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

const body = (await req.json()) as unknown as IUpdateDailyPlan;

const response = await updatePlanRequest({
bearer_token: access_token,
Expand All @@ -42,3 +45,21 @@ export async function PUT(req: Request, { params }: INextParams) {

return $res(response.data);
}

export async function DELETE(req: Request, { params }: INextParams) {
const res = new NextResponse();
const { id } = params;
if (!id) {
return;
}

const { $res, user, access_token } = await authenticatedGuard(req, res);
if (!user) return $res('Unauthorized');

const response = await deleteDailyPlanRequest({
planId: id,
bearer_token: access_token
});

return $res(response.data);
}
34 changes: 28 additions & 6 deletions apps/web/app/api/daily-plan/plan/[planId]/route.ts
Original file line number Diff line number Diff line change
@@ -1,28 +1,50 @@
import { IEmployee, INextParams, ITeamTask } from '@app/interfaces';
import { IDailyPlanTasksUpdate, INextParams } from '@app/interfaces';
import { authenticatedGuard } from '@app/services/server/guards/authenticated-guard-app';
import { addTaskToDailyPlanRequest } from '@app/services/server/requests';
import { addTaskToDailyPlanRequest, removeTaskFromPlanRequest } from '@app/services/server/requests';
import { NextResponse } from 'next/server';

export async function PUT(req: Request, { params }: INextParams) {
export async function POST(req: Request, { params }: INextParams) {
const res = new NextResponse();

const { planId } = params;
if (!planId) {
return;
}

const { $res, user, tenantId, organizationId, access_token } = await authenticatedGuard(req, res);
const { $res, user, tenantId, access_token } = await authenticatedGuard(req, res);
if (!user) return $res('Unauthorized');

const body = (await req.json()) as unknown as { employeeId: IEmployee['id']; taskId: ITeamTask['id'] };
const body = (await req.json()) as unknown as IDailyPlanTasksUpdate;

const response = await addTaskToDailyPlanRequest({
bearer_token: access_token,
data: body,
organizationId,
planId,
tenantId
});

return $res(response.data);
}

export async function PUT(req: Request, { params }: INextParams) {
const res = new NextResponse();

const { planId } = params;
if (!planId) {
return;
}

const { $res, user, tenantId, access_token } = await authenticatedGuard(req, res);
if (!user) return $res('Unauthorized');

const body = (await req.json()) as unknown as IDailyPlanTasksUpdate;

const response = await removeTaskFromPlanRequest({
data: body,
planId,
tenantId,
bearer_token: access_token
});

return $res(response.data);
}
47 changes: 39 additions & 8 deletions apps/web/app/hooks/features/useDailyPlan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,14 @@ import {
import {
addTaskToPlanAPI,
createDailyPlanAPI,
deleteDailyPlanAPI,
getAllDayPlansAPI,
getDayPlansByEmployeeAPI,
getPlansByTaskAPI,
removeTaskFromPlanAPI,
updateDailyPlanAPI
} from '@app/services/client/api';
import { ICreateDailyPlan, IDailyPlan, IEmployee, ITeamTask } from '@app/interfaces';
import { ICreateDailyPlan, IDailyPlanTasksUpdate, IUpdateDailyPlan } from '@app/interfaces';
import { useFirstLoad } from '../useFirstLoad';

export function useDailyPlan() {
Expand All @@ -30,6 +32,9 @@ export function useDailyPlan() {
const { loading: updateDailyPlanLoading, queryCall: updateQueryCall } = useQuery(updateDailyPlanAPI);
const { loading: getPlansByTaskLoading, queryCall: getPlansByTaskQueryCall } = useQuery(getPlansByTaskAPI);
const { loading: addTaskToPlanLoading, queryCall: addTaskToPlanQueryCall } = useQuery(addTaskToPlanAPI);
const { loading: removeTaskFromPlanLoading, queryCall: removeTAskFromPlanQueryCall } =
useQuery(removeTaskFromPlanAPI);
const { loading: deleteDailyPlanLoading, queryCall: deleteDailyPlanQueryCall } = useQuery(deleteDailyPlanAPI);

const [dailyPlan, setDailyPlan] = useRecoilState(dailyPlanListState);
const [profileDailyPlans, setProfileDailyPlans] = useRecoilState(profileDailyPlanListState);
Expand Down Expand Up @@ -86,25 +91,45 @@ export function useDailyPlan() {
);

const updateDailyPlan = useCallback(
async (data: Partial<ICreateDailyPlan>, planId: IDailyPlan['id']) => {
const updated = dailyPlan.items.filter((plan) => plan.id != planId);
async (data: IUpdateDailyPlan, planId: string) => {
const res = await updateQueryCall(data, planId);
setDailyPlan({ total: dailyPlan.total, items: [...updated, res.data] });
const updated = profileDailyPlans.items.filter((plan) => plan.id != planId);
setProfileDailyPlans({ total: profileDailyPlans.total, items: [...updated, res.data] });
return res;
},
[dailyPlan.items, dailyPlan.total, setDailyPlan, updateQueryCall]
[profileDailyPlans.items, profileDailyPlans.total, setProfileDailyPlans, updateQueryCall]
);

const addTaskToPlan = useCallback(
async (data: { employeeId: IEmployee['id']; taskId: ITeamTask['id'] }, planId: IDailyPlan['id']) => {
const updated = profileDailyPlans.items.filter((plan) => plan.id != planId);
async (data: IDailyPlanTasksUpdate, planId: string) => {
const res = await addTaskToPlanQueryCall(data, planId);
const updated = profileDailyPlans.items.filter((plan) => plan.id != planId);
setProfileDailyPlans({ total: profileDailyPlans.total, items: [...updated, res.data] });
return res;
},
[addTaskToPlanQueryCall, profileDailyPlans.items, profileDailyPlans.total, setProfileDailyPlans]
);

const removeTaskFromPlan = useCallback(
async (data: IDailyPlanTasksUpdate, planId: string) => {
const res = await removeTAskFromPlanQueryCall(data, planId);
const updated = profileDailyPlans.items.filter((plan) => plan.id != planId);
setProfileDailyPlans({ total: profileDailyPlans.total, items: [...updated, res.data] });
return res;
},
[profileDailyPlans.items, profileDailyPlans.total, removeTAskFromPlanQueryCall, setProfileDailyPlans]
);

const deleteDailyPlan = useCallback(
async (planId: string) => {
const res = await deleteDailyPlanQueryCall(planId);
const updated = profileDailyPlans.items.filter((plan) => plan.id != planId);
setProfileDailyPlans({ total: updated.length, items: [...updated] });
return res;
},
[deleteDailyPlanQueryCall, profileDailyPlans.items, setProfileDailyPlans]
);

return {
dailyPlan,
profileDailyPlans,
Expand All @@ -131,6 +156,12 @@ export function useDailyPlan() {
updateDailyPlanLoading,

addTaskToPlan,
addTaskToPlanLoading
addTaskToPlanLoading,

removeTaskFromPlan,
removeTaskFromPlanLoading,

deleteDailyPlan,
deleteDailyPlanLoading
};
}
Loading

0 comments on commit f41b4cb

Please sign in to comment.