-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
94 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
apps/web/app/[locale]/reports/weekly-limit/components/time-report-table.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { ITimeLimitReport } from '@/app/interfaces/ITimeLimits'; | ||
import { DataTableWeeklyLimits } from './data-table'; | ||
import moment from 'moment'; | ||
import { DEFAULT_WORK_HOURS_PER_DAY } from '@/app/constants'; | ||
|
||
interface IProps { | ||
report: ITimeLimitReport; | ||
displayMode: 'Week' | 'Day'; | ||
organizationLimits: { [key: string]: number }; | ||
} | ||
|
||
/** | ||
* Renders a time report table displaying employee time tracking data. | ||
* | ||
* @component | ||
* @param {IProps} props - The component props. | ||
* @param {ITimeLimitReport} props.report - Data for employees' time usage reports. | ||
* @param {'Week' | 'Day'} props.displayMode - Specifies whether to display data by week or day. | ||
* @param {{ [key: string]: number }} props.organizationLimits - Contains organizational limits for time usage, specified by mode. | ||
* | ||
* @returns {JSX.Element} A formatted report table showing time usage and limits. | ||
*/ | ||
export const TimeReportTable = ({ report, displayMode, organizationLimits }: IProps) => ( | ||
<div className="w-full p-1" key={report.date}> | ||
<div className="h-12 px-4 bg-slate-100 dark:bg-gray-800 dark:text-white rounded-md flex border items-center"> | ||
<h4 className="text-xs font-medium"> | ||
{displayMode === 'Week' ? ( | ||
<> | ||
<span>{report.date}</span> <span>-</span> | ||
<span>{moment(report.date).endOf('week').format('YYYY-MM-DD')}</span> | ||
</> | ||
) : ( | ||
report.date | ||
)} | ||
</h4> | ||
</div> | ||
<div> | ||
<DataTableWeeklyLimits | ||
data={report.employees?.map((item) => { | ||
const limit = item.limit || organizationLimits[displayMode] || DEFAULT_WORK_HOURS_PER_DAY; | ||
const percentageUsed = (item.duration / limit) * 100; | ||
const remaining = limit - item.duration; | ||
|
||
return { | ||
member: item.employee.fullName, | ||
limit, | ||
percentageUsed, | ||
timeSpent: item.duration, | ||
remaining | ||
}; | ||
})} | ||
/> | ||
</div> | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters