Skip to content

Commit

Permalink
fix: patched add outfit modal (#149)
Browse files Browse the repository at this point in the history
  • Loading branch information
rak3rman authored Jan 29, 2025
1 parent 227a7c4 commit 2a84dd1
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions next/src/components/AddOutfitModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useState, useEffect, useRef } from 'react'
import { Dialog, DialogContent, DialogClose, DialogTrigger, DialogTitle, DialogDescription } from "@/components/ui/dialog"
import { Button } from "@/components/ui/button"
import { Input } from "@/components/ui/input"
import { PlusCircle, X, CalendarIcon, Star, ChevronDown, Loader2, SearchIcon } from 'lucide-react'
import { PlusCircle, X, CalendarIcon, Loader2, SearchIcon } from 'lucide-react'
import { Popover, PopoverContent, PopoverTrigger } from "@/components/ui/popover"
import { cn } from "@/lib/utils"
import { format } from "date-fns"
Expand All @@ -15,6 +15,7 @@ import { Item, itemTypeIcons } from '@/components/Item'
import Rating from './ui/rating'
import { Tag } from "@/components/ui/tag"
import { client, useItems, useTags, useOutfits } from '@/lib/client'
import { useAuth } from '@clerk/nextjs'

interface AddOutfitModalProps {
open?: boolean
Expand All @@ -36,6 +37,8 @@ export function AddOutfitModal({
return today
}

const { getToken } = useAuth()

const [open, setOpen] = useState(false)
const [date, setDate] = useState<Date>(getStartOfToday)
const [searchTerm, setSearchTerm] = useState('')
Expand Down Expand Up @@ -98,10 +101,14 @@ export function AddOutfitModal({
}

try {
const response = await client.api.outfits.$post({
json: outfitData
const res = await client.api.outfits.$post({ json: outfitData }, {
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${await getToken()}`
}
})
if (response.ok) {

if (res.ok) {
// Refresh outfits data
await mutateOutfits()

Expand All @@ -115,7 +122,7 @@ export function AddOutfitModal({
onSuccess?.()
}
} catch (error) {
// Handle error silently
console.log(error)
} finally {
setIsSubmitting(false)
setSubmittingRating(null)
Expand Down

0 comments on commit 2a84dd1

Please sign in to comment.