From 2a84dd16ed9e136ce551d32c31d6859bab35281b Mon Sep 17 00:00:00 2001 From: Radison Akerman <29184717+rak3rman@users.noreply.github.com> Date: Wed, 29 Jan 2025 13:20:31 -0800 Subject: [PATCH] fix: patched add outfit modal (#149) --- next/src/components/AddOutfitModal.tsx | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/next/src/components/AddOutfitModal.tsx b/next/src/components/AddOutfitModal.tsx index d0c4658..cbefbce 100644 --- a/next/src/components/AddOutfitModal.tsx +++ b/next/src/components/AddOutfitModal.tsx @@ -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" @@ -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 @@ -36,6 +37,8 @@ export function AddOutfitModal({ return today } + const { getToken } = useAuth() + const [open, setOpen] = useState(false) const [date, setDate] = useState(getStartOfToday) const [searchTerm, setSearchTerm] = useState('') @@ -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() @@ -115,7 +122,7 @@ export function AddOutfitModal({ onSuccess?.() } } catch (error) { - // Handle error silently + console.log(error) } finally { setIsSubmitting(false) setSubmittingRating(null)