hata ayıklama ve kod temizliği
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user