Skip to content

Commit

Permalink
Merge pull request #2929 from ever-co/fix/daily-plan-feature-add-team…
Browse files Browse the repository at this point in the history
…-field

[Improvement] Daily Plan organization team types
  • Loading branch information
evereq authored Aug 28, 2024
2 parents ff798c3 + 5b4c43a commit 35abf3c
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 13 deletions.
10 changes: 8 additions & 2 deletions apps/web/app/hooks/features/useDailyPlan.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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])
Expand Down Expand Up @@ -132,6 +137,7 @@ export function useDailyPlan() {
}
},
[
activeTeam?.id,
createQueryCall,
employeePlans,
getMyDailyPlans,
Expand Down
9 changes: 9 additions & 0 deletions apps/web/app/interfaces/IBaseModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
25 changes: 14 additions & 11 deletions apps/web/app/interfaces/IDailyPlan.ts
Original file line number Diff line number Diff line change
@@ -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 {
Expand All @@ -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<IDailyPlanBase>, Pick<ICreateDailyPlan, 'employeeId'> { }
export interface IUpdateDailyPlan
extends Partial<IDailyPlanBase>,
Pick<ICreateDailyPlan, 'employeeId'>,
Partial<Pick<IRelationalOrganizationTeam, 'organizationTeamId'>> {}

export interface IDailyPlanTasksUpdate
extends Pick<ICreateDailyPlan, 'taskId' | 'employeeId'>,
IBasePerTenantAndOrganizationEntity { }
IBasePerTenantAndOrganizationEntity {}

export enum DailyPlanStatusEnum {
OPEN = 'open',
Expand Down
5 changes: 5 additions & 0 deletions apps/web/app/interfaces/IOrganizationTeam.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 35abf3c

Please sign in to comment.