Skip to content

Commit

Permalink
refact: coderabbitai
Browse files Browse the repository at this point in the history
  • Loading branch information
Innocent-Akim committed Nov 5, 2024
1 parent 82596e8 commit 9f78cac
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,11 @@ export function FilterWithStatus({
activeStatus === label && 'text-primary bg-white shadow-2xl dark:text-primary-light font-bold border'
)}
onClick={() => onToggle(label)}>
<span className={clsxm('font-medium ml-1 text-[#7E7991] dark:text-gray-200', `${activeStatus === label ? "text-primary font-bold dark:text-primary-light" : ""}`)}>{label}</span>
<span className='font-medium ml-1 text-[#71717A] dark:text-gray-400'>{count}</span>
<span className={clsxm(
'font-medium ml-1 text-gray-500 dark:text-gray-200',
activeStatus === label && 'text-primary font-bold dark:text-primary-light'
)}>{label}</span>
<span className='font-medium ml-1 text-gray-500 dark:text-gray-400'>{count}</span>
</Button>
))}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function TimesheetFilter({ closeModal, isOpen, openModal }: ITimesheetFil
<FilterWithStatus
activeStatus="Rejected"
onToggle={(label) => {
console.log(label);
// If logging is needed, use proper logging service
}}
/>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ export function TimesheetFilterDate({
}
};

const actionButtonClass = "h-4 border-none dark:bg-dark-theme-light text-primary hover:bg-transparent hover:underline"

return (<>
<Popover>
Expand All @@ -92,7 +93,7 @@ export function TimesheetFilterDate({
aria-label="Select date range"
aria-expanded="false"
className={cn(
"w-44 justify-start dark:dark:bg-dark--theme-light h-[2.2rem] items-center gap-x-2 text-left font-normal overflow-hidden text-clip dark:bg-dark--theme",
"w-44 justify-start dark:bg-dark-theme h-[2.2rem] items-center gap-x-2 text-left font-normal overflow-hidden text-clip dark:bg-dark-theme-light",
!dateRange.from && "text-muted-foreground"
)}>
<CalendarIcon />
Expand All @@ -109,7 +110,7 @@ export function TimesheetFilterDate({
)}
</Button>
</PopoverTrigger>
<PopoverContent className="w-auto p-0 flex dark:bg-dark--theme-light">
<PopoverContent className="w-auto p-0 flex dark:bg-dark-theme-light">
{isVisible && (
<div className="flex flex-col p-2 gap-2 translate-x-0 justify-between">
<div className="flex flex-col gap-2">
Expand All @@ -126,8 +127,8 @@ export function TimesheetFilterDate({
/>
</div>
<div className="flex w-full justify-end items-end">
<Button variant={'outline'} className="h-4 border-none hover:dark:dark:bg-dark--theme-light dark:dark:bg-dark--theme-light text-primary hover:bg-transparent hover:text-primary hover:underline">Cancel</Button>
<Button variant={'outline'} className="h-4 border-none hover:dark:dark:bg-dark--theme-light dark:dark:bg-dark--theme-light text-primary hover:bg-transparent hover:text-primary hover:underline">Apply</Button>
<Button variant={'outline'} className={`${actionButtonClass} hover:text-gray-500`}>Cancel</Button>
<Button variant={'outline'} className={`${actionButtonClass} hover:text-primary-dark`}>Apply</Button>
</div>
</div>
)
Expand All @@ -138,7 +139,7 @@ export function TimesheetFilterDate({
<Button
key={index}
variant="outline"
className="h-7 flex items-center justify-between border-none text-[12px] text-gray-700 dark:dark:bg-dark--theme-light "
className="h-7 flex items-center justify-between border-none text-[12px] text-gray-700 dark:dark:bg-dark--theme-light"
onClick={() => {
label === 'Custom Date Range' && setIsVisible((prev) => !prev)
handlePresetClick(label)
Expand Down
40 changes: 34 additions & 6 deletions apps/web/app/api/timer/timesheet/daily/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,41 @@ import { NextResponse } from "next/server";

export async function GET(req: Request) {
const res = new NextResponse();
const { searchParams } = new URL(req.url);

const startDate = searchParams.get('startDate');
const endDate = searchParams.get('endDate');
if (!startDate || !endDate) {
return NextResponse.json(
{ error: 'startDate and endDate are required' },
{ status: 400 }
);
}
const { $res, user, tenantId, organizationId, access_token } = await authenticatedGuard(req, res);
if (!user) return $res('Unauthorized');
const { data } = await getTaskTimesheetRequest({
tenantId,
organizationId,
employeeIds: []
}, access_token)
try {
const { data } = await getTaskTimesheetRequest({
tenantId,
organizationId,
employeeIds: [],
startDate,
endDate
}, access_token);

if (!data) {
return NextResponse.json(
{ error: 'No data found' },
{ status: 404 }
);
}

return NextResponse.json(data);
} catch (error) {
console.error('Error fetching timesheet:', error);
return NextResponse.json(
{ error: 'Failed to fetch timesheet data' },
{ status: 500 }
);
}

return $res(data)
}
Original file line number Diff line number Diff line change
Expand Up @@ -207,10 +207,10 @@ export function DataTableTimeSheet({ data }: { data?: IDailyPlan[] }) {


return (
<div className="w-full dark:dark:bg-dark--theme">
<div className="w-full dark:bg-dark--theme">
<div className="rounded-md">
<Table className="border rounded-md dark:bg-dark--theme-light">
<TableBody className="w-full rounded-md h-[400px] overflow-y-auto dark:dark:bg-dark--theme">
<Table className="order rounded-md dark:bg-dark--theme-light">
<TableBody className="w-full rounded-md h-[400px] overflow-y-auto dark:bg-dark--theme">
{data?.map((plan, index) => (
<div key={index}>
<div className="h-10 flex justify-between items-center w-full bg-[#eeeef1cc] dark:bg-dark--theme rounded-md border-1 border-gray-400 px-5 text-[#71717A] font-medium">
Expand Down

0 comments on commit 9f78cac

Please sign in to comment.