diff --git a/src/pages/master/device/component/DetailDevice.jsx b/src/pages/master/device/component/DetailDevice.jsx
index 1015e74..8ba0c7b 100644
--- a/src/pages/master/device/component/DetailDevice.jsx
+++ b/src/pages/master/device/component/DetailDevice.jsx
@@ -1,5 +1,15 @@
import React, { useEffect, useState } from 'react';
-import { Modal, Input, Divider, Typography, Switch, Button, ConfigProvider, Select, DatePicker } from 'antd';
+import {
+ Modal,
+ Input,
+ Divider,
+ Typography,
+ Switch,
+ Button,
+ ConfigProvider,
+ Select,
+ DatePicker,
+} from 'antd';
import { NotifAlert, NotifOk } from '../../../../components/Global/ToastNotif';
import { createDevice, updateDevice } from '../../../../api/master-device';
import { getAllBrands } from '../../../../api/master-brand';
@@ -14,8 +24,6 @@ const DetailDevice = (props) => {
const [confirmLoading, setConfirmLoading] = useState(false);
const [brands, setBrands] = useState([]);
const [loadingBrands, setLoadingBrands] = useState(false);
- const dateNow = dayjs();
- const [schedulerDate, setSchedulerDate] = useState(dateNow);
const defaultData = {
device_id: '',
@@ -27,7 +35,7 @@ const DetailDevice = (props) => {
device_location: '',
device_description: '',
ip_address: '',
- scheduler_date: '',
+ reminder_at: null,
listen_channel: '',
};
@@ -46,7 +54,6 @@ const DetailDevice = (props) => {
{ field: 'device_name', label: 'Device Name', required: true },
{ field: 'ip_address', label: 'Ip Address', required: true, ip: true },
{ field: 'brand_id', label: 'Brand Device', required: true },
- { field: 'scheduler_date', label: 'Tanggaln(Scheduler)', required: true },
];
if (
@@ -73,35 +80,36 @@ const DetailDevice = (props) => {
ip_address: formData.ip_address,
brand_id: formData.brand_id,
listen_channel: formData.listen_channel,
- scheduler_date: toApiDateFormatter(formData.scheduler_date)
+ listen_channel_reminder: formData.listen_channel_reminder,
+ reminder_at: formData.reminder_at,
};
console.log(payload);
- // const response = formData.device_id
- // ? await updateDevice(formData.device_id, payload)
- // : await createDevice(payload);
+ const response = formData.device_id
+ ? await updateDevice(formData.device_id, payload)
+ : await createDevice(payload);
- // // Check if response is successful
- // if (response && (response.statusCode === 200 || response.statusCode === 201)) {
- // const deviceName = response.data?.device_name || formData.device_name;
+ // Check if response is successful
+ if (response && (response.statusCode === 200 || response.statusCode === 201)) {
+ const deviceName = response.data?.device_name || formData.device_name;
- // NotifOk({
- // icon: 'success',
- // title: 'Berhasil',
- // message: `Data Device "${deviceName}" berhasil ${
- // formData.device_id ? 'diubah' : 'ditambahkan'
- // }.`,
- // });
+ NotifOk({
+ icon: 'success',
+ title: 'Berhasil',
+ message: `Data Device "${deviceName}" berhasil ${
+ formData.device_id ? 'diubah' : 'ditambahkan'
+ }.`,
+ });
- // props.setActionMode('list');
- // } else {
- // NotifAlert({
- // icon: 'error',
- // title: 'Gagal',
- // message: response?.message || 'Terjadi kesalahan saat menyimpan data.',
- // });
- // }
+ props.setActionMode('list');
+ } else {
+ NotifAlert({
+ icon: 'error',
+ title: 'Gagal',
+ message: response?.message || 'Terjadi kesalahan saat menyimpan data.',
+ });
+ }
} catch (error) {
console.error('Save Device Error:', error);
NotifAlert({
@@ -185,8 +193,8 @@ const DetailDevice = (props) => {
props.actionMode === 'add'
? 'Tambah'
: props.actionMode === 'preview'
- ? 'Preview'
- : 'Edit'
+ ? 'Preview'
+ : 'Edit'
} Device`}
open={props.showModal}
// open={true}
@@ -234,7 +242,7 @@ const DetailDevice = (props) => {
,
]}
>
-