Skip to content

Commit

Permalink
Merge pull request #2774 from ever-co/feat/daily-plan-compare-estimated
Browse files Browse the repository at this point in the history
 [Feat] Daily plan | Compare estimated UI Only
  • Loading branch information
evereq authored Jul 20, 2024
2 parents a8637b9 + d13075d commit ad0a0cb
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 7 deletions.
9 changes: 7 additions & 2 deletions apps/web/app/[locale]/page-component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
'use client';

import React, { useEffect, useState } from 'react';
import { useOrganizationTeams } from '@app/hooks';
import { useDailyPlan, useOrganizationTeams, useUserProfilePage } from '@app/hooks';
import { clsxm } from '@app/utils';
import NoTeam from '@components/pages/main/no-team';
import { withAuthentication } from 'lib/app/authenticator';
Expand Down Expand Up @@ -31,10 +31,13 @@ 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(true)
const { todayPlan } = useDailyPlan();
const profile = useUserProfilePage();
const [headerSize, setHeaderSize] = useState(10);

const { isTeamMember, isTrackingEnabled, activeTeam } = useOrganizationTeams();
Expand Down Expand Up @@ -62,8 +65,10 @@ function MainPage() {
if (!online) {
return <Offline />;
}

return (
<>
<DailyPlanCompareEstimatedModal open={isOpen} closeModal={() => setIsOpen(prev => 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
5 changes: 2 additions & 3 deletions apps/web/lib/components/sidebar-accordian.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ export const SidebarAccordian = ({ children, title, className, wrapperClassName,
</Text>

<ChevronUpIcon
className={`${
open ? 'rotate-180 transform' : ''
} h-5 w-5 text-[#292D32] dark:text-white`}
className={`${open ? 'rotate-180 transform' : ''
} h-5 w-5 text-[#292D32] dark:text-white`}
/>
</Disclosure.Button>
{children && (
Expand Down
142 changes: 142 additions & 0 deletions apps/web/lib/features/daily-plan/daily-plan-compare-estimate-modal.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import { Card, Modal, Text, Button } from 'lib/components'
import { PiWarningCircleFill } from "react-icons/pi";
import React from 'react'
import Separator from '@components/ui/separator';
import { IDailyPlan, ITeamTask } from '@app/interfaces';
import { TaskNameInfoDisplay } from '../task/task-displays';
import { clsxm } from '@app/utils';
import { TaskEstimateInput } from '../team/user-team-card/task-estimate';
import { useTeamMemberCard, useTMCardTaskEdit } from '@app/hooks';


export function DailyPlanCompareEstimatedModal({
open,
closeModal,
todayPlan,
profile
}: { open: boolean, closeModal: () => void, todayPlan?: IDailyPlan[], profile: any }) {

return (
<Modal isOpen={open} closeModal={closeModal}>
<div className='w-[98%] md:w-[550px] relative '>
<Card className="w-full h-[620px] flex flex-col justify-start bg-gray-50" shadow='custom'>
<div className='flex flex-col items-center justify-between'>
<HeadTitle />
</div>
<div className='flex items-start flex-col justify-start w-full px-2'>
<InputTime />
</div>
<div className='flex h-full w-full p-2'>
{todayPlan?.map((plan, i) => {
return <div key={i}>
{plan.tasks?.map((data, index) => {
return <CardDailyPlan
key={index}
task={data}
profile={profile}
/>
})}
</div>
})}
</div>
<div className='flex flex-col'>
<div className='flex items-center pb-2 text-red-500 text-[12px]'>
<PiWarningCircleFill className='text-[14px]' />
<span>Please correct planned work hours or re-estimate task(s)</span>
</div>
<ButtonAction closeModal={closeModal} />
</div>
</Card>
</div>
</Modal>
)
}
export function CardDailyPlan({ task, profile }: { task?: ITeamTask, profile: any }) {
const taskEdition = useTMCardTaskEdit(task);
const member = task?.selectedTeam?.members.find((member) => {
return member?.employee?.user?.id === profile?.userProfile?.id
});

const memberInfo = useTeamMemberCard(member);
return (
<div className='flex items-center w-full bg-white border h-16 drop-shadow rounded-lg px-1 font-normal'>
<div className='flex items-center space-x-1'>
<TaskNameInfoDisplay
task={task}
className={clsxm("text-2xl")}
taskTitleClassName={clsxm('pr-1 w-full text-[12px] text-ellipsis text-inherit leading-4 capitalize font-medium')}
showSize={true}
dash={true}
/>
</div>
<Separator />
<div className='flex items-center pl-1 w-2/3 text-[12px]'>
<TaskEstimateInput
type='HORIZONTAL'
showTime={true}
memberInfo={memberInfo}
edition={taskEdition}
/>
</div>
</div>
);
}


export function ButtonAction({ closeModal, onClick }: { closeModal?: () => void, onClick?: () => void }) {
return (
<div className='flex items-center justify-between'>
<Button
onClick={closeModal}
variant='outline'
className='font-normal rounded-sm text-md h-9'>
Cancel
</Button>
<Button onClick={onClick} className='font-normal rounded-sm text-md h-9'>
Start working
</Button>
</div>
)
}


export function HeadTitle() {
return (
<>
<div >
<Text.Heading as='h3' className='mb-3 text-center font-bold'>
TODAY&apos;S PLAN
</Text.Heading>
</div>
<div className='flex items-center justify-start w-full px-2 mb-3'>
<div className='flex items-center space-x-1'>
<Text.Heading as='h4' className='mb-3 text-center text-gray-500 text-[12px]'>
Add planned working hours
</Text.Heading>
<Text.Heading as='h4' className='mb-3 text-center text-red-600'>*
</Text.Heading>
</div>
</div>
</>
)
}


export function InputTime({ onChange }: { onChange?: (_: any) => void }) {
return (
<>
<input
onChange={onChange}
className='custom-time-input mb-3 w-full p-1 focus:border-[#1B005D] border rounded-md border-[#D7E1EB] dark:focus:border-[#D7E1EB] bg-white pb-1 font-normal dark:text-white outline-none dark:bg-transparent text-[13px]'
type="time" />
<div className='flex items-center space-x-1 w-auto'>
<Text.Heading as='h4' className=' text-center text-gray-500 text-[12px]'>
Tasks with no time estimations
</Text.Heading>
<Text.Heading as='h4' className='text-center text-red-600'>
*
</Text.Heading>
</div>
</>
)
}
4 changes: 4 additions & 0 deletions apps/web/lib/features/daily-plan/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export * from './plans-work-time-and-estimate';
export * from './add-task-to-plan';
export * from './daily-plan-compare-estimate-modal'
export * from './create-daily-plan-form-modal'
2 changes: 0 additions & 2 deletions apps/web/lib/features/user-profile-plans.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,8 +180,6 @@ function AllPlans({ profile, currentTab = 'All Tasks' }: { profile: any; current
if (currentTab === 'Today Tasks') filteredPlans = todayPlan;

const canSeeActivity = useCanSeeActivityScreen();
// const { filteredAllPlanData: filterAllPlanData } = useFilterDateRange(filteredPlans, 'all');
// const filterPlans: IDailyPlan[] = currentTab === 'All Tasks' ? : filteredPlans;
const view = useRecoilValue(dailyPlanViewHeaderTabs);

const [plans, setPlans] = useState<IDailyPlan[]>(filteredPlans);
Expand Down

0 comments on commit ad0a0cb

Please sign in to comment.