hata ayıklama ve kod temizliği

This commit is contained in:
2026-01-11 23:58:09 +03:00
parent b2a915240f
commit 32009b4886
22 changed files with 117 additions and 92 deletions

View File

@@ -62,8 +62,8 @@ export function CategoryForm({ initialData }: CategoryFormProps) {
try {
if (initialData) {
const result = await updateCategory(initialData.id, data)
if ((result as any).error) {
toast.error((result as any).error)
if ('error' in result) {
toast.error(result.error)
} else {
toast.success(toastMessage)
router.push(`/dashboard/categories`)
@@ -71,15 +71,15 @@ export function CategoryForm({ initialData }: CategoryFormProps) {
}
} else {
const result = await createCategory(data)
if ((result as any).error) {
toast.error((result as any).error)
if ('error' in result) {
toast.error(result.error)
} else {
toast.success(toastMessage)
router.push(`/dashboard/categories`)
router.refresh()
}
}
} catch (error) {
} catch {
toast.error("Bir hata oluştu.")
} finally {
setLoading(false)
@@ -90,14 +90,14 @@ export function CategoryForm({ initialData }: CategoryFormProps) {
setLoading(true)
try {
const result = await deleteCategory(initialData!.id)
if ((result as any).error) {
toast.error((result as any).error)
if ('error' in result) {
toast.error(result.error)
} else {
toast.success("Kategori silindi.")
router.push(`/dashboard/categories`)
router.refresh()
}
} catch (error) {
} catch {
toast.error("Silme işlemi başarısız.")
} finally {
setLoading(false)