Skip to content

Commit d61ac32

Browse files
committed
resolve some linting errors
1 parent c52be05 commit d61ac32

5 files changed

Lines changed: 37 additions & 25 deletions

File tree

src/components/calendar-overview.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ import slotifyClient from '@/hooks/fetch'
4545
import { errorToast, toast } from '@/hooks/use-toast'
4646
import { CreateManualEventDialog } from '@/components/calendar/create-manual-event-dialog'
4747
import { CreateEvent } from '@/components/calendar/create-event'
48-
import { get } from 'http'
4948

5049
export function CalendarOverview() {
5150
const [isDayEventsDialogOpen, setIsDayEventsDialogOpen] = useState(false)

src/components/calendar/create-event.tsx

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { WeeklyCalendar } from './weekly-calendar'
1616
import slotifyClient from '@/hooks/fetch'
1717
import { toast } from '@/hooks/use-toast'
1818
import * as ScrollArea from '@radix-ui/react-scroll-area'
19+
import { User, AttendeeBase, CalendarEvent } from '@/types/types'
1920

2021
interface CreateEventProps {
2122
open: boolean
@@ -33,28 +34,23 @@ export function CreateEvent({ open, onOpenChangeAction }: CreateEventProps) {
3334
// Create a local open state so that child components can update it.
3435
const [isOpen, setIsOpen] = useState(open)
3536

36-
// Sync local state if prop changes.
37-
useEffect(() => {
38-
setIsOpen(open)
39-
}, [open])
40-
4137
// Callback to update open in both local state and parent state.
4238
const handleUpdateOpen = useCallback(
4339
(newOpen: boolean) => {
4440
setIsOpen(newOpen)
45-
onOpenChangeAction(newOpen)
41+
onOpenChangeAction(isOpen)
4642
},
4743
[onOpenChangeAction],
4844
)
4945

50-
const [myEvents, setMyEvents] = useState<any[]>([])
46+
const [myEvents, setMyEvents] = useState<CalendarEvent[]>([])
5147
const [title, setTitle] = useState('')
5248
const [location, setLocation] = useState('')
5349
const [duration, setDuration] = useState('1hr')
5450

5551
const [userSearchQuery, setUserSearchQuery] = useState('')
56-
const [searchResults, setSearchResults] = useState<any[]>([])
57-
const [selectedParticipants, setSelectedParticipants] = useState<any[]>([])
52+
const [searchResults, setSearchResults] = useState<User[]>([])
53+
const [selectedParticipants, setSelectedParticipants] = useState<User[]>([])
5854

5955
const [selectedDate, setSelectedDate] = useState<Date | null>(null)
6056
const [selectedRange, setSelectedRange] = useState<{
@@ -144,7 +140,7 @@ export function CreateEvent({ open, onOpenChangeAction }: CreateEventProps) {
144140
}, [userSearchQuery])
145141

146142
// Add a user from search results to selected participants
147-
const handleAddParticipant = (user: any) => {
143+
const handleAddParticipant = (user: User) => {
148144
if (
149145
currentUser &&
150146
user.email.toLowerCase() === currentUser.email.toLowerCase()
@@ -164,7 +160,7 @@ export function CreateEvent({ open, onOpenChangeAction }: CreateEventProps) {
164160
}
165161

166162
// Remove a selected participant
167-
const handleRemoveParticipant = (userId: string) => {
163+
const handleRemoveParticipant = (userId: number) => {
168164
setSelectedParticipants(selectedParticipants.filter(u => u.id !== userId))
169165
}
170166

@@ -212,13 +208,19 @@ export function CreateEvent({ open, onOpenChangeAction }: CreateEventProps) {
212208
setIsLoading(true)
213209
try {
214210
// Build attendees array from selected participants for scheduling suggestions
215-
const attendees = selectedParticipants.map(user => ({
216-
emailAddress: {
217-
address: user.email,
218-
name: user.name || user.email,
219-
},
220-
attendeeType: 'required' as const,
221-
}))
211+
212+
let attendees : AttendeeBase[] = []
213+
214+
for (const user of selectedParticipants) {
215+
attendees.push({
216+
emailAddress: {
217+
address: user.email,
218+
name: user.firstName + ' ' + user.lastName,
219+
},
220+
attendeeType: 'required' as const,
221+
})
222+
}
223+
222224
console.log('Attendees:', attendees)
223225

224226
const durationInMinutes = durationMapping[duration] || 60
@@ -387,7 +389,7 @@ export function CreateEvent({ open, onOpenChangeAction }: CreateEventProps) {
387389
key={user.id}
388390
className='flex items-center gap-1 bg-blue-100 text-blue-800 rounded px-2 py-1'
389391
>
390-
<span>{user.name ? user.name : user.email}</span>
392+
<span>{user.firstName ? user.firstName : user.email}</span>
391393
<button
392394
onClick={() => handleRemoveParticipant(user.id)}
393395
className='text-blue-500 hover:text-blue-700'

src/components/calendar/weekly-calendar.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,15 @@ import {
2525
} from '@/components/ui/dialog'
2626
import slotifyClient from '@/hooks/fetch'
2727
import { errorToast, toast } from '@/hooks/use-toast'
28+
import { CalendarEvent } from '@/types/types'
2829

2930
interface WeeklyCalendarProps {
3031
availabilityData: any
3132
conflictEvents: any[]
3233
myEvents: any[]
3334
isLoading: boolean
34-
currentUser: { email: any; name: any }
35-
participants: { email: any; name: any }[]
35+
currentUser: { email: string; name: string }
36+
participants: { email: string; firstName: string }[]
3637
location: string
3738
eventTitle: string
3839
handleUpdateOpen: (newOpen: boolean) => void
@@ -140,7 +141,7 @@ export function WeeklyCalendar({
140141
responseStatus: 'none' as 'none',
141142
}))
142143

143-
const calendarEvent = {
144+
const calendarEvent : CalendarEvent = {
144145
attendees,
145146
locations: [],
146147
subject: eventTitle ? eventTitle : 'My New Meeting',

src/components/reschedule-requests.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Button } from '@/components/ui/button'
77
import { ScrollArea } from '@/components/ui/scroll-area'
88
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card'
99
import { Badge } from '@/components/ui/badge'
10+
import { toast } from '@/hooks/use-toast'
1011

1112
const initialRequests = [
1213
{
@@ -44,8 +45,16 @@ export function RescheduleRequests() {
4445
const handleAction = (id: number, action: 'accept' | 'ignore') => {
4546
console.log(`Action: ${action} for request with ID: ${id}`)
4647
// setRequests(requests.filter(request => request.id !== id))
47-
window.history.pushState(null, '', 'dashboard/calendar#show')
48-
window.location.reload();
48+
if (action === 'accept') {
49+
window.history.pushState(null, '', 'dashboard/calendar#show')
50+
window.location.reload()
51+
} else {
52+
toast({
53+
title: 'Request ignored',
54+
description: `Request has been ignored`,
55+
})
56+
setRequests(requests.filter(request => request.id !== id))
57+
}
4958
}
5059

5160
return (

src/types/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { schemas } from '@/types/client'
22
import { z } from 'zod'
33

44
export type Attendee = z.infer<typeof schemas.Attendee>
5+
export type AttendeeBase = z.infer<typeof schemas.AttendeeBase>
56
export type User = z.infer<typeof schemas.User>
67
export type CalendarEvent = z.infer<typeof schemas.CalendarEvent>
78
export type SlotifyGroup = z.infer<typeof schemas.SlotifyGroup>

0 commit comments

Comments
 (0)