Skip to content

Commit

Permalink
Merge pull request #2816 from ever-co/develop
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
EverTechDevOps authored Aug 1, 2024
2 parents 4af6326 + e4e342b commit 0cdae7a
Show file tree
Hide file tree
Showing 66 changed files with 1,952 additions and 989 deletions.
4 changes: 3 additions & 1 deletion .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"caseSensitive": false,
"$schema": "https://raw.githubusercontent.com/streetsidesoftware/cspell/main/cspell.schema.json",
"words": [
"nivo",
"accepte",
"Accordian",
"adipiscing",
Expand Down Expand Up @@ -349,7 +350,8 @@
"Xlarge",
"xlcard",
"xlight",
"yellowbox"
"yellowbox",
"vhidden"
],
"useGitignore": true,
"ignorePaths": [
Expand Down
1 change: 1 addition & 0 deletions apps/mobile/app/helpers/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function addHours(numOfHours: number, date = new Date()) {
return date;
}


export function secondsToTime(secs: number) {
const hours = Math.floor(secs / (60 * 60));

Expand Down
6 changes: 3 additions & 3 deletions apps/mobile/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6915,9 +6915,9 @@ fast-loops@^1.1.3:
integrity sha512-8dbd3XWoKCTms18ize6JmQF1SFnnfj5s0B7rRry22EofgMu7B6LKHVh+XfFqFGsqnbH54xgeO83PzpKI+ODhlg==

fast-xml-parser@^4.0.12:
version "4.3.2"
resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-4.3.2.tgz#761e641260706d6e13251c4ef8e3f5694d4b0d79"
integrity sha512-rmrXUXwbJedoXkStenj1kkljNF7ugn5ZjR9FJcwmCfcCbtOMDghPajbc+Tck6vE6F5XsDmx+Pr2le9fw8+pXBg==
version "4.4.1"
resolved "https://registry.yarnpkg.com/fast-xml-parser/-/fast-xml-parser-4.4.1.tgz#86dbf3f18edf8739326447bcaac31b4ae7f6514f"
integrity sha512-xkjOecfnKGkSsOwtZ5Pz7Us/T6mrbPQrq0nh+aCO5V9nk5NLWmasAHumTKjiPJPWANe+kAZ84Jc8ooJkzZ88Sw==
dependencies:
strnum "^1.0.5"

Expand Down
4 changes: 2 additions & 2 deletions apps/web/app/[locale]/all-teams/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ function AllTeamsPage() {
];

/* If the user is not a manager in any team or if he's
manager in only one team, then redirect him to the home page
*/
manager in only one team, then redirect him to the home page
*/
if (userManagedTeams.length < 2) return <RedirectUser />;

return (
Expand Down
5 changes: 2 additions & 3 deletions apps/web/app/[locale]/auth/passcode/component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -423,9 +423,8 @@ export function WorkSpaceComponent(props: IWorkSpace) {
{props.workspaces?.map((worksace, index) => (
<div
key={index}
className={`w-full flex flex-col border border-[#0000001A] dark:border-[#34353D] ${
props.selectedWorkspace === index ? 'bg-[#FCFCFC] dark:bg-[#1F2024]' : ''
} hover:bg-[#FCFCFC] dark:hover:bg-[#1F2024] rounded-xl`}
className={`w-full flex flex-col border border-[#0000001A] dark:border-[#34353D] ${props.selectedWorkspace === index ? 'bg-[#FCFCFC] dark:bg-[#1F2024]' : ''
} hover:bg-[#FCFCFC] dark:hover:bg-[#1F2024] rounded-xl`}
>
<div className="text-base font-medium py-[1.25rem] px-4 flex flex-col gap-[1.0625rem]">
<div className="flex justify-between">
Expand Down
27 changes: 2 additions & 25 deletions apps/web/app/[locale]/page-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
'use client';

import React, { useEffect, useState } from 'react';
import { useDailyPlan, useOrganizationTeams, useUserProfilePage } from '@app/hooks';
import { useOrganizationTeams } from '@app/hooks';
import { clsxm } from '@app/utils';
import NoTeam from '@components/pages/main/no-team';
import { withAuthentication } from 'lib/app/authenticator';
import { Breadcrumb, Card } from 'lib/components';
import { AuthUserTaskInput, TeamInvitations, TeamMembers, Timer, UnverifiedEmail } from 'lib/features';
import { MainLayout } from 'lib/layout';
import { DAILY_PLAN_SHOW_MODAL, IssuesView } from '@app/constants';
import { IssuesView } from '@app/constants';
import { useNetworkState } from '@uidotdev/usehooks';
import Offline from '@components/pages/offline';
import { useTranslations } from 'next-intl';
Expand All @@ -31,21 +31,10 @@ import { PeoplesIcon } from 'assets/svg';
import TeamMemberHeader from 'lib/features/team-member-header';
import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@components/ui/resizable';
import { TeamOutstandingNotifications } from 'lib/features/team/team-outstanding-notifications';
import { DailyPlanCompareEstimatedModal } from 'lib/features/daily-plan';

function MainPage() {
const t = useTranslations();
const [isOpen, setIsOpen] = useState(false)
const { todayPlan } = useDailyPlan();
const profile = useUserProfilePage();
const [headerSize, setHeaderSize] = useState(10);
const plan = todayPlan.find((plan) => plan.date?.toString()?.startsWith(new Date()?.toISOString().split('T')[0]));

const defaultOpenPopup =
typeof window !== 'undefined'
? (window.localStorage.getItem(DAILY_PLAN_SHOW_MODAL)) || null
: new Date().toISOString().split('T')[0];

const { isTeamMember, isTrackingEnabled, activeTeam } = useOrganizationTeams();
const [fullWidth, setFullWidth] = useRecoilState(fullWidthState);
const [view, setView] = useRecoilState(headerTabs);
Expand All @@ -63,14 +52,6 @@ function MainPage() {
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [path, setView]);

useEffect(() => {
window.localStorage.setItem(DAILY_PLAN_SHOW_MODAL, new Date().toISOString().split('T')[0]);
if (defaultOpenPopup !== new Date().toISOString().split('T')[0] || defaultOpenPopup === null) {
setIsOpen(true)
}
}, [defaultOpenPopup, plan])


React.useEffect(() => {
window && window?.localStorage.getItem('conf-fullWidth-mode');
setFullWidth(JSON.parse(window?.localStorage.getItem('conf-fullWidth-mode') || 'true'));
Expand All @@ -81,10 +62,6 @@ function MainPage() {
}
return (
<>
<DailyPlanCompareEstimatedModal open={isOpen} closeModal={() => setIsOpen((prev) => {
window.localStorage.setItem(DAILY_PLAN_SHOW_MODAL, new Date().toISOString().split('T')[0]);
return !prev;
})} todayPlan={todayPlan} profile={profile} />
<div className="flex flex-col h-screen justify-between">
{/* <div className="flex-grow "> */}
<MainLayout className="h-full" footerClassName={clsxm('')}>
Expand Down
4 changes: 4 additions & 0 deletions apps/web/app/[locale]/profile/[memberId]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { AppsTab } from 'lib/features/activity/apps';
import { VisitedSitesTab } from 'lib/features/activity/visited-sites';
import { activityTypeState } from '@app/stores/activity-type';
import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from '@components/ui/resizable';
import { ActivityCalendar } from 'lib/features/activity/calendar';

export type FilterTab = 'Tasks' | 'Screenshots' | 'Apps' | 'Visited Sites';

Expand Down Expand Up @@ -136,6 +137,9 @@ const Profile = React.memo(function ProfilePage({ params }: { params: { memberId
{/* TaskFilter */}
<TaskFilter profile={profile} hook={hook} />
</MainHeader>
<div className="p-1">
<ActivityCalendar />
</div>
</ResizablePanel>
<ResizableHandle withHandle />
<ResizablePanel defaultSize={65} maxSize={95} className="!overflow-y-scroll custom-scrollbar">
Expand Down
19 changes: 15 additions & 4 deletions apps/web/app/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { JitsuOptions } from '@jitsu/jitsu-react/dist/useJitsu';
import { I_SMTPRequest } from './interfaces/ISmtp';
import { getNextPublicEnv } from './env';
import enLanguage from '../locales/en.json';
// import { } from 'country-flag-icons/react/3x2'
import { BG, CN, DE, ES, FR, IS, IT, NL, PL, PT, RU, SA, US } from 'country-flag-icons/react/1x1';
import { ManualTimeReasons } from './interfaces/timer/IManualTimeReasons';
export const API_BASE_URL = '/api';
export const DEFAULT_APP_PATH = '/auth/passcode';
export const DEFAULT_MAIN_PATH = '/';
Expand Down Expand Up @@ -266,9 +266,9 @@ export const languagesFlags = [
// Local storage keys
export const LAST_WORSPACE_AND_TEAM = 'last-workspace-and-team';
export const USER_SAW_OUTSTANDING_NOTIFICATION = 'user-saw-notif';
export const TODAY_PLAN_ALERT_SHOWN_DATE = 'last-today-plan-alert-date';
export const ESTIMATE_POPUP_SHOWN_DATE = 'last-estimate-popup-date';
export const DAILY_PLAN_SHOW_MODAL = 'daily-plan-modal';
export const DAILY_PLAN_SUGGESTION_MODAL_DATE = 'daily-plan-suggestion-modal-date';
export const TASKS_ESTIMATE_HOURS_MODAL_DATE = 'tasks-estimate-hours-modal-date';
export const DAILY_PLAN_ESTIMATE_HOURS_MODAL_DATE = 'daily-plan-estimate-hours-modal';

// OAuth providers keys

Expand Down Expand Up @@ -298,3 +298,14 @@ export const SLACK_CLIENT_SECRET = process.env.SLACK_CLIENT_SECRET;

export const TWITTER_CLIENT_ID = process.env.TWITTER_CLIENT_ID;
export const TWITTER_CLIENT_SECRET = process.env.TWITTER_CLIENT_SECRET;

// Add manual timer reason

export const manualTimeReasons: ManualTimeReasons[] = [
'LOST_ELECTRICITY',
'LOST_INTERNET',
'FORGOT_TO_START_TIMER',
'ERROR',
'UNPLANNED_WORK',
'TESTED_TIMER'
];
57 changes: 38 additions & 19 deletions apps/web/app/helpers/daily-plan-estimated.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,48 @@
"use client"

import { IDailyPlan } from "@app/interfaces";
import { convertHourToSeconds } from "./date";

export const dailyPlanCompareEstimated = (plans: IDailyPlan[]) => {

const plan = plans.find((plan) => plan.date?.toString()?.startsWith(new Date()?.toISOString().split('T')[0]));
export interface IDailyPlanCompareEstimated {
difference: boolean,
workTimePlanned?: number,
estimated?: boolean[] | undefined,
plan?: IDailyPlan | undefined
}

const times = plan?.tasks?.map((task) => task?.estimate).filter((time): time is number => typeof time === 'number') ?? [];
const estimated = plan?.tasks?.map((task) => task.estimate! > 0);
export const dailyPlanCompareEstimated = (plans: IDailyPlan[]): IDailyPlanCompareEstimated => {
const plan = plans.find((plan) => plan.date?.toString()?.startsWith(new Date().toISOString().split('T')[0]));

let estimatedTime = 0;
if (times.length > 0) estimatedTime = times.reduce((acc, cur) => acc + cur, 0) ?? 0;
if (!plan) {
return {
difference: false,
workTimePlanned: 0,
estimated: [],
plan: undefined
};
}

const workedTimes =
plan?.tasks?.map((task) => task.totalWorkedTime).filter((time): time is number => typeof time === 'number') ??
[];
const workTimePlanned = convertHourToSeconds(plan.workTimePlanned!);
const times = plan.tasks?.map((task) => task.estimate).filter((time): time is number => typeof time === 'number') ?? [];
const estimated = plan.tasks?.map((task) => task.estimate! > 0);

let totalWorkTime = 0;
if (workedTimes?.length > 0) totalWorkTime = workedTimes.reduce((acc, cur) => acc + cur, 0) ?? 0;
let estimatedTime = 0;
if (times.length > 0) {
estimatedTime = times.reduce((acc, cur) => acc + cur, 0) ?? 0;
}

const result = estimated?.every(Boolean) ? estimatedTime - totalWorkTime : null;
const difference = dailyPlanSubtraction(estimatedTime, workTimePlanned);

return {
result,
totalWorkTime,
estimatedTime
}
workTimePlanned,
estimated,
difference,
plan
};
}

export function dailyPlanSubtraction(
estimatedTime: number,
workTimePlanned: number
): boolean {
const difference = Math.abs(estimatedTime - workTimePlanned) / (60 * 2);
return difference >= -1 && difference <= 1;
}
5 changes: 5 additions & 0 deletions apps/web/app/helpers/date.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,3 +163,8 @@ export const isTestDateRange = (itemDate: Date, from?: Date, to?: Date) => {
return true; // or false, depending on your default logic
}
}


export function convertHourToSeconds(hours: number) {
return hours * 60 * 60;
}
24 changes: 24 additions & 0 deletions apps/web/app/helpers/plan-day-badge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,27 @@ export const planBadgeContent = (
return null;
}
};


export const planBadgeContPast = (
dailyPlan: IDailyPlan[],
taskId: ITeamTask['id']
): string | null => {
const today = new Date().toISOString().split('T')[0];
const dailyPlanDataPast = dailyPlan.filter(plan => new Date(plan.date) < new Date(today));
const allTasks = dailyPlanDataPast.flatMap(plan => plan.tasks);
const taskCount: { [key: string]: number } = allTasks?.reduce((acc, task) => {
if (task && task.id) { acc[task.id] = (acc[task.id] || 0) + 1; }
return acc;
}, {} as { [key: string]: number });

const dailyPlanPast = allTasks?.filter(task => task && taskCount[task.id] === 1);
const filterDailyPlan = dailyPlanPast.filter((plan) => plan?.id === taskId);
if (filterDailyPlan.length > 0) {
return 'Planned';
} else {
return null;
}


}
11 changes: 6 additions & 5 deletions apps/web/app/hooks/auth/useAuthenticationPasscode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,13 +244,14 @@ export function useAuthenticationPasscode() {
useEffect(() => {
if (queryEmail && queryCode && !loginFromQuery.current) {
setScreen('passcode');
verifyPasscodeRequest({
email: queryEmail as string,
code: queryCode as string
});
verifySignInEmailConfirmRequest({ email: queryEmail, code: queryCode });
// verifyPasscodeRequest({
// email: queryEmail as string,
// code: queryCode as string
// });
loginFromQuery.current = true;
}
}, [query, verifyPasscodeRequest, queryEmail, queryCode]);
}, [query, verifySignInEmailConfirmRequest, queryEmail, queryCode]); // deepscan-disable-line

/**
* send a fresh auth request handler
Expand Down
Loading

0 comments on commit 0cdae7a

Please sign in to comment.