From 3668d02f3a59b219667800852f11eb7990e6b099 Mon Sep 17 00:00:00 2001 From: Wikzyy Date: Wed, 16 Apr 2025 19:28:43 +0700 Subject: [PATCH] remove search dialog on sucos --- .../master/sucos/blocks/SearchDialog.tsx | 177 ------------------ 1 file changed, 177 deletions(-) delete mode 100644 src/pages/master/sucos/blocks/SearchDialog.tsx diff --git a/src/pages/master/sucos/blocks/SearchDialog.tsx b/src/pages/master/sucos/blocks/SearchDialog.tsx deleted file mode 100644 index e744347..0000000 --- a/src/pages/master/sucos/blocks/SearchDialog.tsx +++ /dev/null @@ -1,177 +0,0 @@ -import { useRef, useState } from 'react'; -import { - Dialog, - DialogBody, - DialogContent, - DialogDescription, - DialogHeader, - DialogTitle -} from '@/components/ui/dialog'; -import { Alert, KeenIcon } from '@/components'; -import { Button } from '@/components/ui/button'; -import { apiConfig } from '@/config/api.config'; -import axios from 'axios'; -import { useManageSucosContext } from '../hooks/useManageSucosContext'; -import { - Command, - CommandEmpty, - CommandGroup, - CommandInput, - CommandItem, - CommandList -} from '@/components/ui/command'; -import { Popover, PopoverContent, PopoverTrigger } from '@/components/ui/popover'; - -interface AldeiasProps { - id: number; - name: string; -} - -const API_URL = apiConfig.service_master_data; - -const SearchDialog = () => { - const parentRef = useRef(null); - const [open, setOpen] = useState(false); - const { showSearchDialog, handleSearchDialog, sucos } = useManageSucosContext(); - const [alert, setAlert] = useState({ - show: false, - message: '' - }); - const initialState = { - id: 0, - name: '' - }; - - const [formField, setFormField] = useState(initialState); - const resetForm = () => { - setFormField(initialState); - }; - const [aldeia, setAldeia] = useState([]); - const [isFound, setIsFound] = useState(false); - - const handleSubmit = async (e: React.FormEvent) => { - e.preventDefault(); - const id = Number(formField.id); - - if (formField.id === 0) { - setAlert({ show: true, message: 'Please fill name field.' }); - return; - } - - try { - const response = await axios.get(`${API_URL}/postoadms/sucos/${id}`); - - if (response.data.status) { - setAldeia(response.data.data); - console.log(aldeia); - setIsFound(true); - console.log('Found Sucos: ', response.data.data); - } else { - setAldeia([]); - setIsFound(false); - setAlert({ show: true, message: 'No sucos found.' }); - } - } catch (error) { - console.error('Error fetching sucos', error); - setAlert({ show: true, message: 'Failed to fetch sucos. Please try again.' }); - } - setAlert({ show: false, message: '' }); - }; - - const handleReset = () => { - setFormField(initialState); - setIsFound(false); - setAldeia([]); - }; - - return ( - - - - - -
-
-

Search Aldeias

-
-
{ - handleSearchDialog(false); - handleReset(); - }} - > - -
-
-
- -
- {alert.show && {alert.message}} - -
- - - - - - - - - - - No PostoAdms found. - - {sucos.map((suco) => ( - { - setFormField({ - id: suco.sucos_id, - name: suco.sucos_name - }); - setOpen(false); - }} - > - {suco.sucos_name} - - ))} - - - - - -
- - {isFound && sucos.length > 0 && ( -
-

Aldeias:

-
- - {aldeia.map((aldeias) => aldeias.name).join(', ')} - -
-
- )} - -
- - -
-
-
-
-
- ); -}; - -export default SearchDialog;