refactor: toast

This commit is contained in:
codytseng 2025-06-19 23:09:07 +08:00
parent 697b8e4663
commit ef2f8b357d
33 changed files with 127 additions and 477 deletions

View file

@ -1,6 +1,6 @@
import { useToast } from '@/hooks/use-toast'
import mediaUpload from '@/services/media-upload.service'
import { useRef } from 'react'
import { toast } from 'sonner'
export default function Uploader({
children,
@ -15,7 +15,6 @@ export default function Uploader({
className?: string
accept?: string
}) {
const { toast } = useToast()
const fileInputRef = useRef<HTMLInputElement>(null)
const handleFileChange = async (event: React.ChangeEvent<HTMLInputElement>) => {
@ -30,11 +29,7 @@ export default function Uploader({
}
} catch (error) {
console.error('Error uploading file', error)
toast({
variant: 'destructive',
title: 'Failed to upload file',
description: (error as Error).message
})
toast.error(`Failed to upload file: ${(error as Error).message}`)
if (fileInputRef.current) {
fileInputRef.current.value = ''
}