Skip to content

Commit 72c29ac

Browse files
committed
refactor: gemini reccomendations
1 parent 6336da9 commit 72c29ac

File tree

6 files changed

+24
-89
lines changed

6 files changed

+24
-89
lines changed

apps/web/src/app/[locale]/(marketing)/meet-together/plans/[planId]/account-badge.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,9 @@ export default function AccountBadge({ type }: { type: 'GUEST' | 'PLATFORM' }) {
1717
: 'bg-linear-to-r from-pink-500/80 to-sky-600/80 dark:from-pink-300/70 dark:to-blue-300/70'
1818
} mt-2 rounded px-2 py-1 text-sm font-semibold`}
1919
>
20-
<span className={`bg-linear-to-r bg-clip-text text-white`}>
20+
<span
21+
className={`bg-linear-to-r bg-clip-text text-transparent text-white`}
22+
>
2123
{t(type === 'GUEST' ? 'guest_account' : 'tuturuuu_account')}
2224
</span>
2325
</div>

apps/web/src/app/[locale]/(marketing)/meet-together/plans/[planId]/day-planners.tsx

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import DayPlanner from './day-planner';
22
import { useTimeBlocking } from './time-blocking-provider';
33
import type { Timeblock } from '@tuturuuu/types/primitives/Timeblock';
4-
import { useEffect, useState } from 'react';
4+
import { useCallback, useEffect, useState } from 'react';
55

66
export default function DayPlanners({
77
timeblocks,
@@ -32,15 +32,17 @@ export default function DayPlanners({
3232
if (onBestTimesStatusByDateAction) {
3333
onBestTimesStatusByDateAction(bestTimesStatus);
3434
}
35-
// eslint-disable-next-line react-hooks/exhaustive-deps
36-
}, [JSON.stringify(bestTimesStatus)]);
35+
}, [bestTimesStatus, onBestTimesStatusByDateAction]);
3736

38-
function handleBestTimesStatus(date: string, hasBestTimes: boolean) {
39-
setBestTimesStatus((prev) => {
40-
if (prev[date] === hasBestTimes) return prev;
41-
return { ...prev, [date]: hasBestTimes };
42-
});
43-
}
37+
const handleBestTimesStatus = useCallback(
38+
(date: string, hasBestTimes: boolean) => {
39+
setBestTimesStatus((prev) => {
40+
if (prev[date] === hasBestTimes) return prev;
41+
return { ...prev, [date]: hasBestTimes };
42+
});
43+
},
44+
[]
45+
);
4446

4547
function preventScroll(e: any) {
4648
e.preventDefault();

apps/web/src/app/[locale]/(marketing)/meet-together/plans/[planId]/plan-details-client.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { Switch } from '@tuturuuu/ui/switch';
1515
import { Tooltip, TooltipContent, TooltipTrigger } from '@tuturuuu/ui/tooltip';
1616
import html2canvas from 'html2canvas-pro';
1717
import { useTheme } from 'next-themes';
18-
import React, { useCallback, useState } from 'react';
18+
import { useCallback, useEffect, useState } from 'react';
1919

2020
interface PlanDetailsClientProps {
2121
plan: MeetTogetherPlan;
@@ -50,9 +50,11 @@ export default function PlanDetailsClient({
5050

5151
// If user filter is active, force best times off
5252
const isUserFilterActive = filteredUserIds && filteredUserIds.length > 0;
53-
if (isUserFilterActive && showBestTimes) {
54-
setShowBestTimes(false);
55-
}
53+
useEffect(() => {
54+
if (isUserFilterActive && showBestTimes) {
55+
setShowBestTimes(false);
56+
}
57+
}, [isUserFilterActive, showBestTimes]);
5658

5759
// Best times status state
5860
const [bestTimesStatusByDate, setBestTimesStatusByDate] = useState<

apps/web/src/app/[locale]/(marketing)/meet-together/plans/[planId]/preview-day-time.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
TooltipTrigger,
1111
} from '@tuturuuu/ui/tooltip';
1212
import dayjs from 'dayjs';
13-
import React from 'react';
13+
import { useEffect } from 'react';
1414

1515
export default function PreviewDayTime({
1616
timeblocks: serverTimeblocks,
@@ -106,12 +106,11 @@ export default function PreviewDayTime({
106106
}
107107

108108
// Notify parent about best times status
109-
React.useEffect(() => {
109+
useEffect(() => {
110110
if (onBestTimesStatus) {
111111
onBestTimesStatus(bestBlockIndices.size > 0);
112112
}
113-
// eslint-disable-next-line react-hooks/exhaustive-deps
114-
}, [showBestTimes, bestBlockIndices.size]);
113+
}, [showBestTimes, bestBlockIndices.size, onBestTimesStatus]);
115114

116115
const isTimeBlockSelected = (i: number): 'local' | 'server' | 'none' => {
117116
// If the timeblock is pre-selected

apps/web/src/utils/timeblock-helper.ts

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -453,73 +453,3 @@ export function removeTimeblocks(
453453

454454
return filteredTimeblocks;
455455
}
456-
457-
// Returns an array of best time slots (date, start_time, end_time, availableUserIds)
458-
export function getBestMeetingTimes({
459-
timeblocks,
460-
users,
461-
dates,
462-
start,
463-
end,
464-
slotMinutes = 15,
465-
}: {
466-
timeblocks: Timeblock[];
467-
users: { id: string | null }[];
468-
dates: string[];
469-
start: string;
470-
end: string;
471-
slotMinutes?: number;
472-
}) {
473-
const userIds = users.map((u) => u.id).filter(Boolean);
474-
let bestSlots: {
475-
date: string;
476-
start_time: string;
477-
end_time: string;
478-
availableUserIds: string[];
479-
}[] = [];
480-
let maxAvailable = 0;
481-
482-
for (const date of dates) {
483-
// For each 15-min slot in the day
484-
let slot = dayjs(`${date} ${start}`);
485-
const endSlot = dayjs(`${date} ${end}`);
486-
while (slot.isBefore(endSlot)) {
487-
const slotStart = slot;
488-
const slotEnd = slot.add(slotMinutes, 'minute');
489-
// For this slot, count available users
490-
const availableUserIds = userIds
491-
.filter((userId) => {
492-
return timeblocks.some((tb) => {
493-
if (tb.user_id !== userId) return false;
494-
const tbStart = dayjs(`${tb.date} ${tb.start_time}`);
495-
const tbEnd = dayjs(`${tb.date} ${tb.end_time}`);
496-
// Slot must be fully within user's available block
497-
return (
498-
slotStart.isSameOrAfter(tbStart) && slotEnd.isSameOrBefore(tbEnd)
499-
);
500-
});
501-
})
502-
.filter((id): id is string => id !== null);
503-
if (availableUserIds.length > maxAvailable) {
504-
maxAvailable = availableUserIds.length;
505-
bestSlots = [
506-
{
507-
date,
508-
start_time: slotStart.format('HH:mm:ssZ'),
509-
end_time: slotEnd.format('HH:mm:ssZ'),
510-
availableUserIds,
511-
},
512-
];
513-
} else if (availableUserIds.length === maxAvailable && maxAvailable > 0) {
514-
bestSlots.push({
515-
date,
516-
start_time: slotStart.format('HH:mm:ssZ'),
517-
end_time: slotEnd.format('HH:mm:ssZ'),
518-
availableUserIds,
519-
});
520-
}
521-
slot = slot.add(slotMinutes, 'minute');
522-
}
523-
}
524-
return bestSlots;
525-
}

packages/ui/src/components/ui/legacy/tumeet/create-plan-dialog.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ import {
2121
} from '@tuturuuu/ui/form';
2222
import { useForm } from '@tuturuuu/ui/hooks/use-form';
2323
import { toast } from '@tuturuuu/ui/hooks/use-toast';
24+
import { MapPin, Sparkles } from '@tuturuuu/ui/icons';
2425
import { Input } from '@tuturuuu/ui/input';
2526
import { zodResolver } from '@tuturuuu/ui/resolvers';
2627
import { Separator } from '@tuturuuu/ui/separator';
2728
import { cn } from '@tuturuuu/utils/format';
2829
import dayjs from 'dayjs';
29-
import { MapPin, Sparkles } from 'lucide-react';
3030
import { useTranslations } from 'next-intl';
3131
import { useRouter } from 'next/navigation';
3232
import { useState } from 'react';

0 commit comments

Comments
 (0)