Compare commits
60 Commits
lavoce
...
dc4c975df2
| Author | SHA1 | Date | |
|---|---|---|---|
| dc4c975df2 | |||
| 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*
|
yarn-error.log*
|
||||||
pnpm-debug.log*
|
pnpm-debug.log*
|
||||||
lerna-debug.log*
|
lerna-debug.log*
|
||||||
|
*.config
|
||||||
|
|
||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
<system.webServer>
|
<system.webServer>
|
||||||
<rewrite>
|
<rewrite>
|
||||||
<rules>
|
<rules>
|
||||||
<rule name="reactViteSypiu">
|
<rule name="CallOfDuty">
|
||||||
<match url=".*" />
|
<match url=".*" />
|
||||||
<conditions logicalGrouping="MatchAll">
|
<conditions logicalGrouping="MatchAll">
|
||||||
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
|
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
|
||||||
|
|||||||
@@ -91,25 +91,6 @@ const searchData = async (queryParams) => {
|
|||||||
return response.data;
|
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 {
|
export {
|
||||||
getAllNotification,
|
getAllNotification,
|
||||||
getNotificationById,
|
getNotificationById,
|
||||||
@@ -121,6 +102,4 @@ export {
|
|||||||
resendChatByUser,
|
resendChatByUser,
|
||||||
resendChatAllUser,
|
resendChatAllUser,
|
||||||
searchData,
|
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 = ({
|
const NotifConfirmDialog = ({
|
||||||
icon,
|
icon,
|
||||||
title,
|
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,
|
Select,
|
||||||
DatePicker,
|
DatePicker,
|
||||||
} from 'antd';
|
} 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 { createDevice, updateDevice } from '../../../../api/master-device';
|
||||||
import { reminderMonthly, reminderCustom } from '../../../../api/notification';
|
|
||||||
import { getAllBrands } from '../../../../api/master-brand';
|
import { getAllBrands } from '../../../../api/master-brand';
|
||||||
import { validateRun } from '../../../../Utils/validate';
|
import { validateRun } from '../../../../Utils/validate';
|
||||||
import { toApiDateFormatter } from '../../../../components/Global/Formatter';
|
import { toApiDateFormatter } from '../../../../components/Global/Formatter';
|
||||||
@@ -41,7 +40,6 @@ const DetailDevice = (props) => {
|
|||||||
reminder_at_monthly: null,
|
reminder_at_monthly: null,
|
||||||
start_date: null,
|
start_date: null,
|
||||||
end_date: null,
|
end_date: null,
|
||||||
period: null,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const [formData, setFormData] = useState(defaultData);
|
const [formData, setFormData] = useState(defaultData);
|
||||||
@@ -87,7 +85,7 @@ const DetailDevice = (props) => {
|
|||||||
listen_channel: formData.listen_channel,
|
listen_channel: formData.listen_channel,
|
||||||
listen_channel_reminder: formData.listen_channel_reminder,
|
listen_channel_reminder: formData.listen_channel_reminder,
|
||||||
reminder_at: formData.reminder_at,
|
reminder_at: formData.reminder_at,
|
||||||
reminder_at_monthly: formData.period !== 'custom' ? formData.reminder_at_monthly : null,
|
reminder_at_monthly: formData.reminder_at_monthly,
|
||||||
start_date: formData.start_date,
|
start_date: formData.start_date,
|
||||||
end_date: formData.end_date,
|
end_date: formData.end_date,
|
||||||
};
|
};
|
||||||
@@ -98,13 +96,6 @@ const DetailDevice = (props) => {
|
|||||||
? await updateDevice(formData.device_id, payload)
|
? await updateDevice(formData.device_id, payload)
|
||||||
: await createDevice(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
|
// Check if response is successful
|
||||||
if (response && (response.statusCode === 200 || response.statusCode === 201)) {
|
if (response && (response.statusCode === 200 || response.statusCode === 201)) {
|
||||||
const deviceName = response.data?.device_name || formData.device_name;
|
const deviceName = response.data?.device_name || formData.device_name;
|
||||||
@@ -125,25 +116,6 @@ const DetailDevice = (props) => {
|
|||||||
message: response?.message || 'Terjadi kesalahan saat menyimpan data.',
|
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) {
|
} catch (error) {
|
||||||
console.error('Save Device Error:', error);
|
console.error('Save Device Error:', error);
|
||||||
NotifAlert({
|
NotifAlert({
|
||||||
@@ -206,6 +178,10 @@ const DetailDevice = (props) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const [period, setPeriod] = useState({
|
||||||
|
period: undefined,
|
||||||
|
});
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (formData.start_date && formData.end_date) {
|
if (formData.start_date && formData.end_date) {
|
||||||
const start = dayjs(formData.start_date);
|
const start = dayjs(formData.start_date);
|
||||||
@@ -221,39 +197,36 @@ const DetailDevice = (props) => {
|
|||||||
periodValue = '6';
|
periodValue = '6';
|
||||||
}
|
}
|
||||||
|
|
||||||
setFormData((prev) => ({
|
setPeriod({
|
||||||
...prev,
|
|
||||||
period: periodValue,
|
period: periodValue,
|
||||||
}));
|
});
|
||||||
}
|
}
|
||||||
}, [formData.start_date, formData.end_date]);
|
}, [formData.start_date, formData.end_date]);
|
||||||
|
|
||||||
const handleMonthly = (field, value) => {
|
const handleMonthly = (field, value) => {
|
||||||
setFormData((prev) => {
|
setPeriod((prev) => ({
|
||||||
const data = {
|
|
||||||
...prev,
|
...prev,
|
||||||
[field]: value,
|
[field]: value,
|
||||||
};
|
}));
|
||||||
|
|
||||||
if (value !== 'custom') {
|
if (value !== 'custom') {
|
||||||
const months = Number(value);
|
const months = Number(value);
|
||||||
|
|
||||||
const startDate = dayjs().startOf('day');
|
const startDate = dayjs().startOf('day');
|
||||||
const endDate = startDate
|
const endDate = startDate.add(months, 'month').subtract(1, 'day').endOf('day');
|
||||||
.add(months, 'month')
|
|
||||||
.subtract(1, 'day')
|
|
||||||
.endOf('day');
|
|
||||||
|
|
||||||
data.start_date = startDate.toISOString();
|
setFormData((prev) => ({
|
||||||
data.end_date = endDate.toISOString();
|
...prev,
|
||||||
data.reminder_at_monthly = null;
|
start_date: startDate.toISOString(),
|
||||||
|
end_date: endDate.toISOString(),
|
||||||
|
}));
|
||||||
} else {
|
} else {
|
||||||
data.start_date = null;
|
setFormData((prev) => ({
|
||||||
data.end_date = null;
|
...prev,
|
||||||
|
start_date: null,
|
||||||
|
end_date: null,
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
return data;
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -502,7 +475,7 @@ const DetailDevice = (props) => {
|
|||||||
<Text style={{ color: 'red' }}> *</Text>
|
<Text style={{ color: 'red' }}> *</Text>
|
||||||
|
|
||||||
<Select
|
<Select
|
||||||
value={formData.period}
|
value={period.period}
|
||||||
onChange={(value) => handleMonthly('period', value)}
|
onChange={(value) => handleMonthly('period', value)}
|
||||||
placeholder="Select Period"
|
placeholder="Select Period"
|
||||||
style={{ width: '100%' }}
|
style={{ width: '100%' }}
|
||||||
@@ -513,7 +486,7 @@ const DetailDevice = (props) => {
|
|||||||
<Select.Option value="custom">Custom</Select.Option>
|
<Select.Option value="custom">Custom</Select.Option>
|
||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
{formData.period === 'custom' && (
|
{period.period === 'custom' && (
|
||||||
<div style={{ display: 'flex', gap: 8, marginBottom: 12 }}>
|
<div style={{ display: 'flex', gap: 8, marginBottom: 12 }}>
|
||||||
<DatePicker
|
<DatePicker
|
||||||
placeholder="Start Date"
|
placeholder="Start Date"
|
||||||
@@ -526,8 +499,6 @@ const DetailDevice = (props) => {
|
|||||||
current &&
|
current &&
|
||||||
current.isAfter(dayjs(formData.end_date), 'day')
|
current.isAfter(dayjs(formData.end_date), 'day')
|
||||||
}
|
}
|
||||||
format="DD-MM-YYYY HH:mm"
|
|
||||||
showTime={{ format: 'HH:mm' }}
|
|
||||||
style={{ flex: 1 }}
|
style={{ flex: 1 }}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
@@ -542,8 +513,6 @@ const DetailDevice = (props) => {
|
|||||||
current &&
|
current &&
|
||||||
current.isBefore(dayjs(formData.start_date), 'day')
|
current.isBefore(dayjs(formData.start_date), 'day')
|
||||||
}
|
}
|
||||||
format="DD-MM-YYYY HH:mm"
|
|
||||||
showTime={{ format: 'HH:mm' }}
|
|
||||||
style={{ flex: 1 }}
|
style={{ flex: 1 }}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
@@ -552,7 +521,7 @@ const DetailDevice = (props) => {
|
|||||||
<Text strong>Reminder At(Monthly)</Text>
|
<Text strong>Reminder At(Monthly)</Text>
|
||||||
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
<div style={{ display: 'flex', gap: 8, alignItems: 'center' }}>
|
||||||
<DatePicker
|
<DatePicker
|
||||||
disabled={formData.period === 'custom'}
|
disabled={period.period === 'custom'}
|
||||||
value={
|
value={
|
||||||
formData.reminder_at_monthly
|
formData.reminder_at_monthly
|
||||||
? dayjs(formData.reminder_at_monthly) // ✅ langsung parse ISO
|
? dayjs(formData.reminder_at_monthly) // ✅ langsung parse ISO
|
||||||
@@ -570,7 +539,7 @@ const DetailDevice = (props) => {
|
|||||||
/>
|
/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
disabled={formData.period === 'custom'}
|
disabled={period.period === 'custom'}
|
||||||
danger
|
danger
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
setFormData((prev) => ({
|
setFormData((prev) => ({
|
||||||
|
|||||||
Reference in New Issue
Block a user