diff --git a/apps/web/app/hooks/features/useDailyPlan.ts b/apps/web/app/hooks/features/useDailyPlan.ts index 6e849626f..b3586b402 100644 --- a/apps/web/app/hooks/features/useDailyPlan.ts +++ b/apps/web/app/hooks/features/useDailyPlan.ts @@ -1,9 +1,10 @@ 'use client'; -import { useRecoilState } from 'recoil'; +import { useRecoilState, useRecoilValue } from 'recoil'; import { useCallback, useEffect } from 'react'; import { useQuery } from '../useQuery'; import { + activeTeamState, dailyPlanFetchingState, dailyPlanListState, employeePlansListState, @@ -31,6 +32,7 @@ export type FilterTabs = 'Today Tasks' | 'Future Tasks' | 'Past Tasks' | 'All Ta export function useDailyPlan() { const { user } = useAuthenticateUser(); + const activeTeam = useRecoilValue(activeTeamState); const { loading, queryCall } = useQuery(getDayPlansByEmployeeAPI); const { loading: getAllDayPlansLoading, queryCall: getAllQueryCall } = useQuery(getAllDayPlansAPI); @@ -101,7 +103,10 @@ export function useDailyPlan() { const createDailyPlan = useCallback( async (data: ICreateDailyPlan) => { if (user?.tenantId) { - const res = await createQueryCall(data, user?.tenantId || ''); + const res = await createQueryCall( + { ...data, organizationTeamId: activeTeam?.id }, + user?.tenantId || '' + ); //Check if there is an existing plan const isPlanExist = profileDailyPlans.items.find((plan) => plan.date?.toString()?.startsWith(new Date(data.date)?.toISOString().split('T')[0]) @@ -132,6 +137,7 @@ export function useDailyPlan() { } }, [ + activeTeam?.id, createQueryCall, employeePlans, getMyDailyPlans, diff --git a/apps/web/app/interfaces/IBaseModel.ts b/apps/web/app/interfaces/IBaseModel.ts index 5adf49218..debe7f323 100644 --- a/apps/web/app/interfaces/IBaseModel.ts +++ b/apps/web/app/interfaces/IBaseModel.ts @@ -5,6 +5,15 @@ export interface IBaseDelete { deletedAt?: Date; } +/** + * @description + * An entity ID. Represents a unique identifier as a string. + * + * @docsCategory Type Definitions + * @docsSubcategory Identifiers + */ +export type ID = string; + export interface IBaseEntity extends IBaseDelete { id?: string; readonly createdAt?: Date; diff --git a/apps/web/app/interfaces/IDailyPlan.ts b/apps/web/app/interfaces/IDailyPlan.ts index 2af0ea650..8eba961df 100644 --- a/apps/web/app/interfaces/IDailyPlan.ts +++ b/apps/web/app/interfaces/IDailyPlan.ts @@ -1,6 +1,6 @@ -import { IBasePerTenantAndOrganizationEntity } from './IBaseModel'; -import { IEmployee, IRelationnalEmployee } from './IEmployee'; -import { IOrganization } from './IOrganization'; +import { IBasePerTenantAndOrganizationEntity, ID } from './IBaseModel'; +import { IRelationnalEmployee } from './IEmployee'; +import { IRelationalOrganizationTeam } from './IOrganizationTeam'; import { ITeamTask } from './ITask'; export interface IDailyPlanBase extends IBasePerTenantAndOrganizationEntity { @@ -10,24 +10,27 @@ export interface IDailyPlanBase extends IBasePerTenantAndOrganizationEntity { } export interface IRemoveTaskFromManyPlans { - employeeId?: IEmployee['id']; - plansIds?: IDailyPlan['id'][]; - organizationId?: IOrganization['id']; + employeeId?: ID; + plansIds?: ID[]; + organizationId?: ID; } -export interface IDailyPlan extends IDailyPlanBase, IRelationnalEmployee { +export interface IDailyPlan extends IDailyPlanBase, IRelationnalEmployee, IRelationalOrganizationTeam { tasks?: ITeamTask[]; } -export interface ICreateDailyPlan extends IDailyPlanBase, IRelationnalEmployee { - taskId?: ITeamTask['id']; +export interface ICreateDailyPlan extends IDailyPlanBase, IRelationnalEmployee, IRelationalOrganizationTeam { + taskId?: ID; } -export interface IUpdateDailyPlan extends Partial, Pick { } +export interface IUpdateDailyPlan + extends Partial, + Pick, + Partial> {} export interface IDailyPlanTasksUpdate extends Pick, - IBasePerTenantAndOrganizationEntity { } + IBasePerTenantAndOrganizationEntity {} export enum DailyPlanStatusEnum { OPEN = 'open', diff --git a/apps/web/app/interfaces/IOrganizationTeam.ts b/apps/web/app/interfaces/IOrganizationTeam.ts index fdb5e455a..42256c24f 100644 --- a/apps/web/app/interfaces/IOrganizationTeam.ts +++ b/apps/web/app/interfaces/IOrganizationTeam.ts @@ -74,6 +74,11 @@ export interface IOrganizationTeamList { projects?: IProject[]; } +export interface IRelationalOrganizationTeam { + organizationTeam?: IOrganizationTeam; + organizationTeamId?: IOrganizationTeam['id']; +} + export type IOrganizationTeamWithMStatus = IOrganizationTeamList; export interface OT_Member {