Skip to content

Improve scheduling algorithm #3126

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
AlertTriangleIcon,
CalendarIcon,
ClockIcon,
LockIcon,
SparklesIcon,
TrendingUpIcon,
} from '@tuturuuu/ui/icons';
Expand Down Expand Up @@ -225,15 +226,29 @@ export function ScheduleDisplay({ events }: ScheduleDisplayProps) {
{/* Event Card */}
<div
className={`group relative rounded-lg border p-4 transition-all hover:shadow-sm ${
event.isPastDeadline
? 'border-destructive/30 bg-destructive/5'
: 'hover:bg-accent/5'
event.locked
? 'border-dynamic-blue/30 bg-dynamic-blue/10'
: event.isPastDeadline
? 'border-destructive/30 bg-destructive/5'
: 'hover:bg-accent/5'
Comment on lines +229 to +233

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The conditional logic for className is becoming complex. Consider extracting this logic into a helper function or using a utility like clsx to improve readability.

}`}
>
<div className="flex items-start justify-between gap-4">
<div className="flex-1 space-y-2">
{/* Event Header */}
<div className="flex items-center gap-3">
{event.locked && (
<Tooltip>
<TooltipTrigger>
<LockIcon className="h-5 w-5 shrink-0 text-dynamic-blue" />
</TooltipTrigger>
<TooltipContent>
<p>
Locked event: this time is blocked
</p>
</TooltipContent>
</Tooltip>
)}
{event.isPastDeadline && (
<Tooltip>
<TooltipTrigger>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
Trash2Icon,
ZapIcon,
} from '@tuturuuu/ui/icons';
import { SplitIcon } from '@tuturuuu/ui/icons';
import { Input } from '@tuturuuu/ui/input';
import { Label } from '@tuturuuu/ui/label';
import { Progress } from '@tuturuuu/ui/progress';
Expand All @@ -28,6 +29,7 @@ import {
SelectTrigger,
SelectValue,
} from '@tuturuuu/ui/select';
import { Switch } from '@tuturuuu/ui/switch';
import { Tooltip, TooltipContent, TooltipTrigger } from '@tuturuuu/ui/tooltip';
import dayjs from 'dayjs';
import { useMemo } from 'react';
Expand Down Expand Up @@ -245,6 +247,29 @@ export function TaskList({
: ''
}`}
/>
{/* Split Toggle Button */}
<div className="ml-2 flex items-center gap-1">
<Tooltip>
<TooltipTrigger asChild>
<div className="flex items-center gap-1">
<SplitIcon className="h-4 w-4 text-primary" />
<Switch
id={`split-toggle-${task.id}`}
checked={task.allowSplit ?? true}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The default value for task.allowSplit is true using the nullish coalescing operator (??). This is a good default, making tasks splittable unless explicitly set otherwise.

onCheckedChange={(checked) =>
onUpdateTask(task.id, {
allowSplit: checked,
})
}
className="scale-90"
/>
</div>
</TooltipTrigger>
<TooltipContent>
Allow this task to be split into sessions
</TooltipContent>
</Tooltip>
</div>
{isCompleted && (
<CheckCircleIcon className="h-5 w-5 text-dynamic-green" />
)}
Expand Down
Loading
Loading