Compare commits
59 Commits
lavoce
...
60927e045e
| Author | SHA1 | Date | |
|---|---|---|---|
| 60927e045e | |||
| 7063865a7b | |||
| 0fa282c4db | |||
| c79a5fc361 | |||
| 3ae2d84378 | |||
| f3faf41308 | |||
| 8220554a5e | |||
| 5a740e6ef1 | |||
| 46e922a33d | |||
| bad5da5e11 | |||
| c92e1ef0ec | |||
| ce55126bf8 | |||
| 11ac6ad9ba | |||
| d02d7d87da | |||
| 255c1e64c7 | |||
| 90b882daf3 | |||
| cc6a52ccbf | |||
| 03d5646565 | |||
| 4d8af01316 | |||
| 8f32f29c03 | |||
| 5a7d64a05b | |||
| e74b802a60 | |||
| f436865b7f | |||
| 48437c3c50 | |||
| a33c9b3b92 | |||
| 58d1f5c7ab | |||
| c10a5bf62d | |||
| 6cc5042956 | |||
| 5079f8d316 | |||
| 7073390de7 | |||
| 4226a24e79 | |||
| 038009433f | |||
| 64ba51b17c | |||
| 47d0638a42 | |||
| d8c5f3ed44 | |||
| affd9146bb | |||
| 4022b3f8f4 | |||
| 446a4e2b95 | |||
| 83a475c708 | |||
| ab1c510a77 | |||
| 59859c6d18 | |||
| 2bd27937dc | |||
| 1058c660d6 | |||
| 35b2167791 | |||
| ec676983d0 | |||
| c07c5f8235 | |||
| b32ad97034 | |||
| 76244f6f6e | |||
| 0a128cbb3c | |||
| bd4ab26680 | |||
| 3e728a1ff5 | |||
| 9db143972e | |||
| 029ea269a7 | |||
| 4cdaa042da | |||
| 56af2a16c0 | |||
| deadf2ffb4 | |||
| 4da80c7089 | |||
| 56e3ce78a6 | |||
| 7c2a019dd2 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,6 +6,7 @@ yarn-debug.log*
|
||||
yarn-error.log*
|
||||
pnpm-debug.log*
|
||||
lerna-debug.log*
|
||||
*.config
|
||||
|
||||
node_modules
|
||||
dist
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<system.webServer>
|
||||
<rewrite>
|
||||
<rules>
|
||||
<rule name="reactViteSypiu">
|
||||
<rule name="CallOfDuty">
|
||||
<match url=".*" />
|
||||
<conditions logicalGrouping="MatchAll">
|
||||
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
|
||||
|
||||
@@ -91,25 +91,6 @@ const searchData = async (queryParams) => {
|
||||
return response.data;
|
||||
};
|
||||
|
||||
// Reminder Monthly
|
||||
const reminderMonthly = async (id, queryParams) => {
|
||||
const response = await SendRequest({
|
||||
method: 'post',
|
||||
prefix: `notifikasi-wa/reminder-monthly/${id}`,
|
||||
params: queryParams,
|
||||
});
|
||||
return response.data;
|
||||
};
|
||||
|
||||
const reminderCustom= async (id, queryParams) => {
|
||||
const response = await SendRequest({
|
||||
method: 'post',
|
||||
prefix: `notifikasi-wa/reminder-custom/${id}`,
|
||||
params: queryParams,
|
||||
});
|
||||
return response.data;
|
||||
};
|
||||
|
||||
export {
|
||||
getAllNotification,
|
||||
getNotificationById,
|
||||
@@ -121,6 +102,4 @@ export {
|
||||
resendChatByUser,
|
||||
resendChatAllUser,
|
||||
searchData,
|
||||
reminderMonthly,
|
||||
reminderCustom,
|
||||
};
|
||||
|
||||
@@ -20,19 +20,6 @@ const NotifOk = ({ icon, title, message }) => {
|
||||
});
|
||||
};
|
||||
|
||||
const NotifSmall = ({ icon, title, message }) => {
|
||||
Swal.fire({
|
||||
toast: true,
|
||||
position: 'top-end',
|
||||
icon: icon,
|
||||
title: title,
|
||||
text: message,
|
||||
showConfirmButton: false,
|
||||
timer: 2000,
|
||||
timerProgressBar: true,
|
||||
});
|
||||
};
|
||||
|
||||
const NotifConfirmDialog = ({
|
||||
icon,
|
||||
title,
|
||||
@@ -80,4 +67,4 @@ const QuestionConfirmSubmit = ({ icon, title, message, onConfirm, onCancel }) =>
|
||||
});
|
||||
};
|
||||
|
||||
export { NotifAlert, NotifOk, NotifSmall, NotifConfirmDialog, QuestionConfirmSubmit };
|
||||
export { NotifAlert, NotifOk, NotifConfirmDialog, QuestionConfirmSubmit };
|
||||
|
||||
@@ -10,9 +10,8 @@ import {
|
||||
Select,
|
||||
DatePicker,
|
||||
} from 'antd';
|
||||
import { NotifAlert, NotifOk, NotifSmall } from '../../../../components/Global/ToastNotif';
|
||||
import { NotifAlert, NotifOk } from '../../../../components/Global/ToastNotif';
|
||||
import { createDevice, updateDevice } from '../../../../api/master-device';
|
||||
import { reminderMonthly, reminderCustom } from '../../../../api/notification';
|
||||
import { getAllBrands } from '../../../../api/master-brand';
|
||||
import { validateRun } from '../../../../Utils/validate';
|
||||
import { toApiDateFormatter } from '../../../../components/Global/Formatter';
|
||||
@@ -36,12 +35,8 @@ const DetailDevice = (props) => {
|
||||
device_location: '',
|
||||
device_description: '',
|
||||
ip_address: '',
|
||||
listen_channel: null,
|
||||
reminder_at: null,
|
||||
reminder_at_monthly: null,
|
||||
start_date: null,
|
||||
end_date: null,
|
||||
period: null,
|
||||
listen_channel: null,
|
||||
};
|
||||
|
||||
const [formData, setFormData] = useState(defaultData);
|
||||
@@ -87,9 +82,6 @@ const DetailDevice = (props) => {
|
||||
listen_channel: formData.listen_channel,
|
||||
listen_channel_reminder: formData.listen_channel_reminder,
|
||||
reminder_at: formData.reminder_at,
|
||||
reminder_at_monthly: formData.period !== 'custom' ? formData.reminder_at_monthly : null,
|
||||
start_date: formData.start_date,
|
||||
end_date: formData.end_date,
|
||||
};
|
||||
|
||||
console.log(payload);
|
||||
@@ -98,13 +90,6 @@ const DetailDevice = (props) => {
|
||||
? await updateDevice(formData.device_id, payload)
|
||||
: await createDevice(payload);
|
||||
|
||||
const response2 = formData.period !== 'custom'
|
||||
? await updateDevice(formData.device_id, { reminder_at_monthly: formData.reminder_at_monthly,})
|
||||
: await updateDevice(formData.device_id, {
|
||||
start_date: formData.start_date,
|
||||
end_date: formData.end_date,
|
||||
});
|
||||
|
||||
// Check if response is successful
|
||||
if (response && (response.statusCode === 200 || response.statusCode === 201)) {
|
||||
const deviceName = response.data?.device_name || formData.device_name;
|
||||
@@ -125,25 +110,6 @@ const DetailDevice = (props) => {
|
||||
message: response?.message || 'Terjadi kesalahan saat menyimpan data.',
|
||||
});
|
||||
}
|
||||
|
||||
// Check if response Reminder At(Monthly) or Period are successful
|
||||
const tipe = formData.period !== 'custom' ? 'Reminder At(Monthly)' : 'Period';
|
||||
if (response2 && (response2.statusCode === 200 || response2.statusCode === 201)) {
|
||||
NotifSmall({
|
||||
icon: 'success',
|
||||
title: 'Berhasil',
|
||||
message: `${tipe} berhasil disimpan`,
|
||||
});
|
||||
} else {
|
||||
NotifSmall({
|
||||
icon: 'error',
|
||||
title: 'Gagal',
|
||||
message:
|
||||
response?.message ||
|
||||
`Terjadi kesalahan saat menyimpan ${tipe}`,
|
||||
});
|
||||
}
|
||||
|
||||
} catch (error) {
|
||||
console.error('Save Device Error:', error);
|
||||
NotifAlert({
|
||||
@@ -206,56 +172,19 @@ const DetailDevice = (props) => {
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (formData.start_date && formData.end_date) {
|
||||
const start = dayjs(formData.start_date);
|
||||
const end = dayjs(formData.end_date);
|
||||
|
||||
let periodValue = 'custom';
|
||||
|
||||
if (end.isSame(start.add(1, 'month').subtract(1, 'day'), 'day')) {
|
||||
periodValue = '1';
|
||||
} else if (end.isSame(start.add(3, 'month').subtract(1, 'day'), 'day')) {
|
||||
periodValue = '3';
|
||||
} else if (end.isSame(start.add(6, 'month').subtract(1, 'day'), 'day')) {
|
||||
periodValue = '6';
|
||||
}
|
||||
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
period: periodValue,
|
||||
}));
|
||||
}
|
||||
}, [formData.start_date, formData.end_date]);
|
||||
const [period, setPeriod] = useState({
|
||||
period: undefined,
|
||||
start_date: null,
|
||||
end_date: null,
|
||||
});
|
||||
|
||||
const handleMonthly = (field, value) => {
|
||||
setFormData((prev) => {
|
||||
const data = {
|
||||
setPeriod((prev) => ({
|
||||
...prev,
|
||||
[field]: value,
|
||||
}));
|
||||
};
|
||||
|
||||
if (value !== 'custom') {
|
||||
const months = Number(value);
|
||||
|
||||
const startDate = dayjs().startOf('day');
|
||||
const endDate = startDate
|
||||
.add(months, 'month')
|
||||
.subtract(1, 'day')
|
||||
.endOf('day');
|
||||
|
||||
data.start_date = startDate.toISOString();
|
||||
data.end_date = endDate.toISOString();
|
||||
data.reminder_at_monthly = null;
|
||||
} else {
|
||||
data.start_date = null;
|
||||
data.end_date = null;
|
||||
}
|
||||
|
||||
return data;
|
||||
});
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (props.showModal && (props.actionMode === 'add' || props.actionMode === 'edit')) {
|
||||
fetchBrands();
|
||||
@@ -502,7 +431,7 @@ const DetailDevice = (props) => {
|
||||
<Text style={{ color: 'red' }}> *</Text>
|
||||
|
||||
<Select
|
||||
value={formData.period}
|
||||
value={period.period}
|
||||
onChange={(value) => handleMonthly('period', value)}
|
||||
placeholder="Select Period"
|
||||
style={{ width: '100%' }}
|
||||
@@ -513,37 +442,29 @@ const DetailDevice = (props) => {
|
||||
<Select.Option value="custom">Custom</Select.Option>
|
||||
</Select>
|
||||
</div>
|
||||
{formData.period === 'custom' && (
|
||||
{period.period === 'custom' && (
|
||||
<div style={{ display: 'flex', gap: 8, marginBottom: 12 }}>
|
||||
<DatePicker
|
||||
placeholder="Start Date"
|
||||
value={formData.start_date ? dayjs(formData.start_date) : null}
|
||||
value={period.start_date ? dayjs(period.start_date) : null}
|
||||
onChange={(date) =>
|
||||
handleDateChange('start_date', date ? date.toISOString() : null)
|
||||
setPeriod((prev) => ({
|
||||
...prev,
|
||||
start_date: date ? date.toISOString() : null,
|
||||
}))
|
||||
}
|
||||
disabledDate={(current) =>
|
||||
formData.end_date &&
|
||||
current &&
|
||||
current.isAfter(dayjs(formData.end_date), 'day')
|
||||
}
|
||||
format="DD-MM-YYYY HH:mm"
|
||||
showTime={{ format: 'HH:mm' }}
|
||||
style={{ flex: 1 }}
|
||||
/>
|
||||
|
||||
<DatePicker
|
||||
placeholder="End Date"
|
||||
value={formData.end_date ? dayjs(formData.end_date) : null}
|
||||
value={period.end_date ? dayjs(period.end_date) : null}
|
||||
onChange={(date) =>
|
||||
handleDateChange('end_date', date ? date.toISOString() : null)
|
||||
setPeriod((prev) => ({
|
||||
...prev,
|
||||
end_date: date ? date.toISOString() : null,
|
||||
}))
|
||||
}
|
||||
disabledDate={(current) =>
|
||||
formData.start_date &&
|
||||
current &&
|
||||
current.isBefore(dayjs(formData.start_date), 'day')
|
||||
}
|
||||
format="DD-MM-YYYY HH:mm"
|
||||
showTime={{ format: 'HH:mm' }}
|
||||
style={{ flex: 1 }}
|
||||
/>
|
||||
</div>
|
||||
@@ -552,15 +473,15 @@ const DetailDevice = (props) => {
|
||||
<Text strong>Reminder At(Monthly)</Text>
|
||||
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
||||
<DatePicker
|
||||
disabled={formData.period === 'custom'}
|
||||
disabled={period.period === 'custom'}
|
||||
value={
|
||||
formData.reminder_at_monthly
|
||||
? dayjs(formData.reminder_at_monthly) // ✅ langsung parse ISO
|
||||
formData.reminder_at
|
||||
? dayjs(formData.reminder_at) // ✅ langsung parse ISO
|
||||
: null
|
||||
}
|
||||
onChange={(date) =>
|
||||
handleDateChange(
|
||||
'reminder_at_monthly',
|
||||
'reminder_at',
|
||||
date ? date.toISOString() : null
|
||||
)
|
||||
}
|
||||
@@ -570,12 +491,12 @@ const DetailDevice = (props) => {
|
||||
/>
|
||||
|
||||
<Button
|
||||
disabled={formData.period === 'custom'}
|
||||
disabled={period.period === 'custom'}
|
||||
danger
|
||||
onClick={() =>
|
||||
setFormData((prev) => ({
|
||||
...prev,
|
||||
reminder_at_monthly: null,
|
||||
reminder_at: null,
|
||||
}))
|
||||
}
|
||||
>
|
||||
|
||||
Reference in New Issue
Block a user