From 74ba2641ca01d80b039de37b2f33dfeb85f89e9f Mon Sep 17 00:00:00 2001 From: amaliadwiy Date: Mon, 27 Oct 2025 11:31:47 +0800 Subject: [PATCH] upd: tolak nama divisi yg sama Deskripsi: - akan ditolak jika input nama divisi udah ada - alert konfirmasi custom 1 tombol No Issues --- app/(application)/division/create.tsx | 7 +++--- components/alertKonfirmasi.ts | 32 ++++++++++++++++++--------- 2 files changed, 24 insertions(+), 15 deletions(-) diff --git a/app/(application)/division/create.tsx b/app/(application)/division/create.tsx index a0a69eb..6eaf255 100644 --- a/app/(application)/division/create.tsx +++ b/app/(application)/division/create.tsx @@ -69,10 +69,9 @@ export default function CreateDivision() { if (!response.available) { AlertKonfirmasi({ title: 'Peringatan', - desc: 'Nama divisi sudah ada. Apakah anda yakin ingin membuat divisi dengan nama yang sama?', - onPress: () => { - handleSetData() - } + category: 'warning', + desc: 'Nama divisi sudah ada. Tidak dapat membuat divisi dengan nama yang sama', + onPress: () => { } }) } else { handleSetData() diff --git a/components/alertKonfirmasi.ts b/components/alertKonfirmasi.ts index 8424874..cc1790a 100644 --- a/components/alertKonfirmasi.ts +++ b/components/alertKonfirmasi.ts @@ -5,17 +5,27 @@ type Props = { title: string, desc: string onPress: () => void + category?: string } -export default function AlertKonfirmasi({ title, desc, onPress }: Props) { - Alert.alert(title, desc, [ - { - text: 'Tidak', - style: 'cancel', - }, - { - text: 'Ya', - onPress: () => { onPress() } - }, - ]); +export default function AlertKonfirmasi({ title, desc, onPress, category }: Props) { + if (category == "warning") { + Alert.alert(title, desc, [ + { + text: 'Oke', + style: 'cancel', + }, + ]); + } else { + Alert.alert(title, desc, [ + { + text: 'Tidak', + style: 'cancel', + }, + { + text: 'Ya', + onPress: () => { onPress() } + }, + ]); + } } \ No newline at end of file -- 2.49.1