Skip to content

Commit

Permalink
Merge pull request #2832 from ever-co/stage
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
evereq authored Aug 4, 2024
2 parents e6fdba1 + 97d22dc commit 162072f
Show file tree
Hide file tree
Showing 20 changed files with 523 additions and 143 deletions.
3 changes: 3 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@
"Kolkata",
"Kosrae",
"Koyeb",
"Krisp",
"krisp",
"labore",
"Lask",
"lastest",
Expand Down Expand Up @@ -271,6 +273,7 @@
"sentryclirc",
"setrole",
"Settingfilter",
"settingsCloseButton",
"setuptools",
"setwin",
"setwork",
Expand Down
6 changes: 4 additions & 2 deletions apps/web/app/[locale]/meet/livekit/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ function LiveKitPage() {
const params = useSearchParams();

const onLeave = useCallback(() => {
window.localStorage.removeItem('current-room-live-kit');
router.push('/');
}, [router]);

useEffect(() => {
const room = params.get("roomName");
if (room) {
setRoomName(room);
window.localStorage.setItem('current-room-live-kit', room);
}
}, [params]);

Expand All @@ -36,7 +38,7 @@ function LiveKitPage() {
});

return (
<>
<div >
<Meta title="Meet" />
{token && roomName && <LiveKit
token={token!}
Expand All @@ -51,7 +53,7 @@ function LiveKitPage() {
videoDeviceId: ''
}}
/>}
</>
</div>
);
}

Expand Down
38 changes: 38 additions & 0 deletions apps/web/app/hooks/features/useManualTime.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
import { useCallback, useState } from 'react';
import { useQuery } from '../useQuery';
import { useAuthenticateUser } from './useAuthenticateUser';
import { addManualTimeRequestAPI } from '@app/services/client/api/timer/manual-time';
import { IAddManualTimeRequest, ITimeLog } from '@app/interfaces/timer/ITimerLogs';
import { TimeLogType, TimerSource } from '@app/interfaces';

export function useManualTime() {
const { user } = useAuthenticateUser();

const { loading: addManualTimeLoading, queryCall: queryAddManualTime } = useQuery(addManualTimeRequestAPI);
const [timeLog, setTimeLog] = useState<ITimeLog>();

const addManualTime = useCallback(
(data: Omit<IAddManualTimeRequest, 'tenantId' | 'employeeId' | 'logType' | 'source'>) => {
queryAddManualTime({
tenantId: user?.tenantId ?? '',
employeeId: user?.employee.id ?? '',
logType: TimeLogType.MANUAL,
source: TimerSource.BROWSER,
...data
})
.then((response) => {
setTimeLog(response.data);
})
.catch((error) => {
console.log(error);
});
},
[queryAddManualTime, user?.employee.id, user?.tenantId]
);

return {
addManualTimeLoading,
addManualTime,
timeLog
};
}
48 changes: 36 additions & 12 deletions apps/web/app/hooks/features/useStartStopTimerHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,34 @@ export function useStartStopTimerHandler() {
window && window?.localStorage.getItem(DAILY_PLAN_ESTIMATE_HOURS_MODAL_DATE);

/**
* Handle missing working hour for a daily plN
* Handle missing working hour for a daily plan
*/
const handleMissingDailyPlanWorkHour = () => {
if (!hasWorkedHours) {
openAddDailyPlanWorkHoursModal();
if (hasPlan) {
if (!hasWorkedHours) {
openAddDailyPlanWorkHoursModal();
} else {
startTimer();
}
} else {
startTimer();
}
};

/**
* Handle missing estimation hours for tasks
*/
const handleMissingTasksEstimationHours = () => {
if (hasPlan) {
if (areAllTasksEstimated) {
if (dailyPlanEstimateHoursModalDate != currentDate) {
handleMissingDailyPlanWorkHour();
} else {
startTimer();
}
} else {
openAddTasksEstimationHoursModal();
}
} else {
startTimer();
}
Expand All @@ -90,20 +113,20 @@ export function useStartStopTimerHandler() {
startTimer();
} else {
if (dailyPlanSuggestionModalDate != currentDate) {
openSuggestDailyPlanModal();
if (!hasPlan) {
openSuggestDailyPlanModal();
} else {
handleMissingTasksEstimationHours();
}
} else if (tasksEstimateHoursModalDate != currentDate) {
if (areAllTasksEstimated) {
if (dailyPlanEstimateHoursModalDate != currentDate) {
handleMissingTasksEstimationHours();
} else if (dailyPlanEstimateHoursModalDate != currentDate) {
if (hasPlan) {
if (areAllTasksEstimated) {
handleMissingDailyPlanWorkHour();
} else {
startTimer();
}
} else {
openAddTasksEstimationHoursModal();
}
} else if (dailyPlanEstimateHoursModalDate != currentDate) {
if (areAllTasksEstimated) {
handleMissingDailyPlanWorkHour();
} else {
startTimer();
}
Expand All @@ -116,6 +139,7 @@ export function useStartStopTimerHandler() {
}, [
areAllTasksEstimated,
canRunTimer,
hasPlan,
hasWorkedHours,
isActiveTaskPlaned,
openAddDailyPlanWorkHoursModal,
Expand Down
7 changes: 7 additions & 0 deletions apps/web/app/interfaces/ITimer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ export enum TimerSource {
'TEAMS' = 'TEAMS'
}

export enum TimeLogType {
TRACKED = 'TRACKED',
MANUAL = 'MANUAL',
IDLE = 'IDLE',
RESUMED = 'RESUMED'
}

export interface ITimerStatus {
duration: number;
lastLog?: ITimer;
Expand Down
46 changes: 46 additions & 0 deletions apps/web/app/interfaces/timer/ITimerLogs.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import { IEmployee } from '../IEmployee';
import { IOrganization } from '../IOrganization';
import { ITeamTask } from '../ITask';
import { TimeLogType, TimerSource } from '../ITimer';
import { ITimerSlot } from './ITimerSlot';

export interface ITimerLogsDailyReportRequest {
tenantId: string;
organizationId: string;
Expand All @@ -11,3 +17,43 @@ export interface ITimerLogsDailyReport {
date: string; // '2024-07-19'
sum: number; // in seconds
}

export interface IAddManualTimeRequest {
employeeId: string;
projectId?: string;
taskId?: string;
organizationContactId?: string;
description?: string;
reason?: string;
startedAt: Date;
stoppedAt: Date;
editedAt?: Date;
tags?: string[];
isBillable?: boolean;
organizationId?: string;
organization?: Pick<IOrganization, 'id'>;
tenantId?: string;
logType: TimeLogType;
source: TimerSource.BROWSER;
}

export interface ITimeLog {
employee: IEmployee;
employeeId: string;
timesheetId?: string;
task?: ITeamTask;
taskId?: string;
timeSlots?: ITimerSlot[];
projectId?: string;
startedAt?: Date;
stoppedAt?: Date;
/** Edited At* */
editedAt?: Date;
description?: string;
reason?: string;
duration: number;
isBillable: boolean;
tags?: string[];
isRunning?: boolean;
isEdited?: boolean;
}
13 changes: 13 additions & 0 deletions apps/web/app/services/client/api/timer/manual-time.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { post } from '@app/services/client/axios';
import { IAddManualTimeRequest, ITimeLog } from '@app/interfaces/timer/ITimerLogs';

export async function addManualTimeRequestAPI(request: IAddManualTimeRequest) {
const { startedAt, stoppedAt, ...rest } = request;
const data = {
...rest,
startedAt: startedAt.toISOString(),
stoppedAt: stoppedAt.toISOString()
};

return post<ITimeLog>(`/timesheet/time-log`, data);
}
19 changes: 11 additions & 8 deletions apps/web/components/shared/collaborate/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ const Collaborate = () => {
[collaborativeMembers, members, setCollaborativeMembers]
);

const handleAction = (actionCallback: () => void) => () => {
closeModal();
actionCallback();
};

const handleMeetClick = handleAction(onMeetClick);
const handleBoardClick = handleAction(onBoardClick);


return (
<div>
<JitsuAnalytics user={user} />
Expand Down Expand Up @@ -197,10 +206,7 @@ const Collaborate = () => {

<div className="flex space-x-3 ">
<Button
onClick={() => {
closeModal();
onMeetClick();
}}
onClick={handleMeetClick}
className={clsxm('rounded-xl flex min-w-0 w-28 h-12', 'gap-1 items-center')}
variant="outline"
>
Expand All @@ -209,10 +215,7 @@ const Collaborate = () => {
</Button>

<Button
onClick={() => {
closeModal();
onBoardClick();
}}
onClick={handleBoardClick}
className={clsxm('rounded-xl flex min-w-0 w-28 h-12', 'gap-1 items-center')}
>
<BrushSquareIcon className="w-4 h-4" />
Expand Down
Loading

0 comments on commit 162072f

Please sign in to comment.