Compare commits
28 Commits
a33c9b3b92
...
lavoce
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c2163cec5e | ||
|
|
d5866ceae4 | ||
| 6fdb259246 | |||
| 0aad43c751 | |||
| d988d47e30 | |||
|
|
e08eaaa43e | ||
|
|
f6ca54f5b4 | ||
|
|
a9b8053bd8 | ||
| 600c101c68 | |||
|
|
14a6884f43 | ||
|
|
8e151ffe0b | ||
| 8f64843613 | |||
|
|
fe8f6d1002 | ||
|
|
5281e288a9 | ||
|
|
4ed05cc640 | ||
|
|
14e97fead2 | ||
|
|
0935d7c9f5 | ||
|
|
3266641f81 | ||
|
|
739c55c0bc | ||
|
|
5b4485d20d | ||
| 98057beb0f | |||
|
|
b342289888 | ||
| d03bbf2a41 | |||
|
|
ec094b8f55 | ||
| b6d941ba2d | |||
| 167abcaa43 | |||
| beb8ccbaee | |||
| 797f6c2383 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -6,7 +6,6 @@ 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="CallOfDuty">
|
<rule name="reactViteSypiu">
|
||||||
<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" />
|
||||||
|
|||||||
@@ -46,10 +46,60 @@ const getNotificationLogByNotificationId = async (notificationId) => {
|
|||||||
return response.data;
|
return response.data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// update is_read status
|
||||||
|
const updateIsRead = async (notificationId) => {
|
||||||
|
const response = await SendRequest({
|
||||||
|
method: 'put',
|
||||||
|
prefix: `notification/${notificationId}`,
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Resend notification to specific user
|
||||||
|
const resendNotificationToUser = async (notificationId, userId) => {
|
||||||
|
const response = await SendRequest({
|
||||||
|
method: 'post',
|
||||||
|
prefix: `notification/${notificationId}/resend/${userId}`,
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Resend Chat by User
|
||||||
|
const resendChatByUser = async (notificationId, userPhone) => {
|
||||||
|
const response = await SendRequest({
|
||||||
|
method: 'post',
|
||||||
|
prefix: `notification-user/resend/${notificationId}/${userPhone}`,
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Resend Chat All User
|
||||||
|
const resendChatAllUser = async (notificationId) => {
|
||||||
|
const response = await SendRequest({
|
||||||
|
method: 'post',
|
||||||
|
prefix: `notification/resend/${notificationId}`,
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
};
|
||||||
|
|
||||||
|
// Searching
|
||||||
|
const searchData = async (queryParams) => {
|
||||||
|
const response = await SendRequest({
|
||||||
|
method: 'get',
|
||||||
|
prefix: `notification?criteria=${queryParams}`,
|
||||||
|
});
|
||||||
|
return response.data;
|
||||||
|
};
|
||||||
|
|
||||||
export {
|
export {
|
||||||
getAllNotification,
|
getAllNotification,
|
||||||
getNotificationById,
|
getNotificationById,
|
||||||
getNotificationDetail,
|
getNotificationDetail,
|
||||||
createNotificationLog,
|
createNotificationLog,
|
||||||
getNotificationLogByNotificationId
|
getNotificationLogByNotificationId,
|
||||||
|
updateIsRead,
|
||||||
|
resendNotificationToUser,
|
||||||
|
resendChatByUser,
|
||||||
|
resendChatAllUser,
|
||||||
|
searchData,
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -30,18 +30,18 @@ instance.interceptors.response.use(
|
|||||||
originalRequest._retry = true;
|
originalRequest._retry = true;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log('🔄 Refresh token dipanggil...');
|
// console.log('🔄 Refresh token dipanggil...');
|
||||||
const refreshRes = await refreshApi.post('/auth/refresh-token');
|
const refreshRes = await refreshApi.post('/auth/refresh-token');
|
||||||
|
|
||||||
const newAccessToken = refreshRes.data.data.accessToken;
|
const newAccessToken = refreshRes.data.data.accessToken;
|
||||||
localStorage.setItem('token', newAccessToken);
|
localStorage.setItem('token', newAccessToken);
|
||||||
console.log('✅ Token refreshed successfully');
|
// console.log('✅ Token refreshed successfully');
|
||||||
|
|
||||||
// update token di header
|
// update token di header
|
||||||
instance.defaults.headers.common['Authorization'] = `Bearer ${newAccessToken}`;
|
instance.defaults.headers.common['Authorization'] = `Bearer ${newAccessToken}`;
|
||||||
originalRequest.headers['Authorization'] = `Bearer ${newAccessToken}`;
|
originalRequest.headers['Authorization'] = `Bearer ${newAccessToken}`;
|
||||||
|
|
||||||
console.log('🔁 Retrying original request...');
|
// console.log('🔁 Retrying original request...');
|
||||||
return instance(originalRequest);
|
return instance(originalRequest);
|
||||||
} catch (refreshError) {
|
} catch (refreshError) {
|
||||||
console.error(
|
console.error(
|
||||||
@@ -81,24 +81,24 @@ async function ApiRequest({ method = 'GET', params = {}, prefix = '/', token = t
|
|||||||
rawToken = localStorage.getItem('token');
|
rawToken = localStorage.getItem('token');
|
||||||
// console.log(`localStorage: ${rawToken}`);
|
// console.log(`localStorage: ${rawToken}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (token && rawToken) {
|
if (token && rawToken) {
|
||||||
const cleanToken = rawToken.replace(/"/g, '');
|
const cleanToken = rawToken.replace(/"/g, '');
|
||||||
request.headers['Authorization'] = `Bearer ${cleanToken}`;
|
request.headers['Authorization'] = `Bearer ${cleanToken}`;
|
||||||
console.log('🔐 Sending request with token:', cleanToken.substring(0, 20) + '...');
|
// console.log('🔐 Sending request with token:', cleanToken.substring(0, 20) + '...');
|
||||||
} else {
|
} else {
|
||||||
console.warn('⚠️ No token found in localStorage');
|
console.warn('⚠️ No token found in localStorage');
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('📤 API Request:', { method, url: prefix, hasToken: !!rawToken });
|
// console.log('📤 API Request:', { method, url: prefix, hasToken: !!rawToken });
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await instance(request);
|
const response = await instance(request);
|
||||||
console.log('✅ API Response:', {
|
// console.log('✅ API Response:', {
|
||||||
url: prefix,
|
// url: prefix,
|
||||||
status: response.status,
|
// status: response.status,
|
||||||
statusCode: response.data?.statusCode,
|
// statusCode: response.data?.statusCode,
|
||||||
});
|
// });
|
||||||
return { ...response, error: false };
|
return { ...response, error: false };
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
const status = error?.response?.status || 500;
|
const status = error?.response?.status || 500;
|
||||||
@@ -143,17 +143,10 @@ async function cekError(status, message = '') {
|
|||||||
const SendRequest = async (queryParams) => {
|
const SendRequest = async (queryParams) => {
|
||||||
try {
|
try {
|
||||||
const response = await ApiRequest(queryParams);
|
const response = await ApiRequest(queryParams);
|
||||||
console.log('📦 SendRequest response:', {
|
|
||||||
hasError: response.error,
|
|
||||||
status: response.status,
|
|
||||||
statusCode: response.data?.statusCode,
|
|
||||||
data: response.data,
|
|
||||||
});
|
|
||||||
|
|
||||||
// If ApiRequest returned error flag, return error structure
|
// If ApiRequest returned error flag, return error structure
|
||||||
if (response.error) {
|
if (response.error) {
|
||||||
const errorMsg = response.data?.message || response.statusText || 'Request failed';
|
const errorMsg = response.data?.message || response.statusText || 'Request failed';
|
||||||
console.error('❌ SendRequest error response:', errorMsg);
|
|
||||||
|
|
||||||
// Return consistent error structure instead of empty array
|
// Return consistent error structure instead of empty array
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -2,7 +2,16 @@
|
|||||||
import mqtt from 'mqtt';
|
import mqtt from 'mqtt';
|
||||||
|
|
||||||
const mqttUrl = `${import.meta.env.VITE_MQTT_SERVER ?? 'ws://localhost:1884'}`;
|
const mqttUrl = `${import.meta.env.VITE_MQTT_SERVER ?? 'ws://localhost:1884'}`;
|
||||||
const topics = ['cod/air_dryer/air_dryer1'];
|
const topics = [
|
||||||
|
'PIU_COD/AIR_DRYER/OVERVIEW',
|
||||||
|
'PIU_COD/AIR_DRYER/AIR_DRYER_A',
|
||||||
|
'PIU_COD/AIR_DRYER/AIR_DRYER_B',
|
||||||
|
'PIU_COD/AIR_DRYER/AIR_DRYER_C',
|
||||||
|
'PIU_COD/COMPRESSOR/OVERVIEW',
|
||||||
|
'PIU_COD/COMPRESSOR/COMPRESSOR_A',
|
||||||
|
'PIU_COD/COMPRESSOR/COMPRESSOR_B',
|
||||||
|
'PIU_COD/COMPRESSOR/COMPRESSOR_C'
|
||||||
|
];
|
||||||
const options = {
|
const options = {
|
||||||
keepalive: 30,
|
keepalive: 30,
|
||||||
clientId: 'react_mqtt_' + Math.random().toString(16).substr(2, 8),
|
clientId: 'react_mqtt_' + Math.random().toString(16).substr(2, 8),
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ export default function RedirectWa() {
|
|||||||
|
|
||||||
console.log('tes', response);
|
console.log('tes', response);
|
||||||
|
|
||||||
const tokenResult = JSON.stringify(response.data?.accessToken);
|
const tokenResult = JSON.stringify(response.data?.data?.accessToken);
|
||||||
|
|
||||||
sessionStorage.setItem('token_redirect', tokenResult);
|
sessionStorage.setItem('token_redirect', tokenResult);
|
||||||
response.data.auth = true;
|
response.data.auth = true;
|
||||||
|
|||||||
@@ -267,9 +267,6 @@ const ListContact = memo(function ListContact(props) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Backend doesn't support is_active filter or order parameter
|
|
||||||
// Contact hanya supports: criteria, name, code, limit, page
|
|
||||||
|
|
||||||
const queryParams = new URLSearchParams();
|
const queryParams = new URLSearchParams();
|
||||||
Object.entries(searchParams).forEach(([key, value]) => {
|
Object.entries(searchParams).forEach(([key, value]) => {
|
||||||
if (value !== '' && value !== null && value !== undefined) {
|
if (value !== '' && value !== null && value !== undefined) {
|
||||||
@@ -309,11 +306,10 @@ const ListContact = memo(function ListContact(props) {
|
|||||||
// Listen for saved contact data
|
// Listen for saved contact data
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (props.lastSavedContact) {
|
if (props.lastSavedContact) {
|
||||||
fetchContacts(); // Refetch all contacts when data is saved
|
fetchContacts();
|
||||||
}
|
}
|
||||||
}, [props.lastSavedContact]);
|
}, [props.lastSavedContact]);
|
||||||
|
|
||||||
// Get contacts (already filtered by backend)
|
|
||||||
const getFilteredContacts = () => {
|
const getFilteredContacts = () => {
|
||||||
return filteredContacts;
|
return filteredContacts;
|
||||||
};
|
};
|
||||||
@@ -326,7 +322,7 @@ const ListContact = memo(function ListContact(props) {
|
|||||||
const showAddModal = () => {
|
const showAddModal = () => {
|
||||||
props.setSelectedData(null);
|
props.setSelectedData(null);
|
||||||
props.setActionMode('add');
|
props.setActionMode('add');
|
||||||
// Pass the current active tab to determine contact type
|
|
||||||
props.setContactType?.(activeTab);
|
props.setContactType?.(activeTab);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import filePathSvg from '../../assets/svg/air_dryer_A_rev.svg';
|
|||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
|
|
||||||
// const filePathSvg = '/src/assets/svg/air_dryer_A_rev.svg';
|
// const filePathSvg = '/src/assets/svg/air_dryer_A_rev.svg';
|
||||||
const topicMqtt = 'PIU_GGCP/Devices/PB';
|
const topicMqtt = 'PIU_COD/AIR_DRYER/AIR_DRYER_A';
|
||||||
|
|
||||||
const SvgAirDryerA = () => {
|
const SvgAirDryerA = () => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import filePathSvg from '../../assets/svg/air_dryer_B_rev.svg';
|
|||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
|
|
||||||
// const filePathSvg = '/src/assets/svg/air_dryer_B_rev.svg';
|
// const filePathSvg = '/src/assets/svg/air_dryer_B_rev.svg';
|
||||||
const topicMqtt = 'PIU_GGCP/Devices/PB';
|
const topicMqtt = 'PIU_COD/AIR_DRYER/AIR_DRYER_B';
|
||||||
|
|
||||||
const SvgAirDryerB = () => {
|
const SvgAirDryerB = () => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import filePathSvg from '../../assets/svg/air_dryer_C_rev.svg';
|
|||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
|
|
||||||
// const filePathSvg = '/src/assets/svg/air_dryer_C_rev.svg';
|
// const filePathSvg = '/src/assets/svg/air_dryer_C_rev.svg';
|
||||||
const topicMqtt = 'PIU_GGCP/Devices/PB';
|
const topicMqtt = 'PIU_COD/AIR_DRYER/AIR_DRYER_C';
|
||||||
|
|
||||||
const SvgAirDryerC = () => {
|
const SvgAirDryerC = () => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import filePathSvg from '../../assets/svg/compressorA_rev.svg';
|
|||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
|
|
||||||
// const filePathSvg = '/src/assets/svg/test-new.svg';
|
// const filePathSvg = '/src/assets/svg/test-new.svg';
|
||||||
const topicMqtt = 'PIU_GGCP/Devices/PB';
|
const topicMqtt = 'PIU_COD/COMPRESSOR/COMPRESSOR_A';
|
||||||
|
|
||||||
const SvgCompressorA = () => {
|
const SvgCompressorA = () => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import SvgViewer from './SvgViewer';
|
|||||||
import filePathSvg from '../../assets/svg/compressorB_rev.svg';
|
import filePathSvg from '../../assets/svg/compressorB_rev.svg';
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
const topicMqtt = 'cod/air_dryer/air_dryer1';
|
const topicMqtt = 'PIU_COD/COMPRESSOR/COMPRESSOR_B';
|
||||||
|
|
||||||
const SvgCompressorB = () => {
|
const SvgCompressorB = () => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import filePathSvg from '../../assets/svg/compressorC_rev.svg';
|
|||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
|
|
||||||
// const filePathSvg = '/src/assets/svg/test-new.svg';
|
// const filePathSvg = '/src/assets/svg/test-new.svg';
|
||||||
const topicMqtt = 'PIU_GGCP/Devices/PB';
|
const topicMqtt = 'PIU_COD/COMPRESSOR/COMPRESSOR_C';
|
||||||
|
|
||||||
const SvgCompressorC = () => {
|
const SvgCompressorC = () => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import filePathSvg from '../../assets/svg/overview-airdryer.svg';
|
|||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
|
|
||||||
// const filePathSvg = '/src/assets/svg/test-new.svg';
|
// const filePathSvg = '/src/assets/svg/test-new.svg';
|
||||||
const topicMqtt = 'PIU_GGCP/Devices/PB';
|
const topicMqtt = 'PIU_COD/AIR_DRYER/OVERVIEW';
|
||||||
|
|
||||||
const SvgOverviewAirDryer = () => {
|
const SvgOverviewAirDryer = () => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ import filePathSvg from '../../assets/svg/overview-compressor.svg';
|
|||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
|
|
||||||
// const filePathSvg = '/src/assets/svg/test-new.svg';
|
// const filePathSvg = '/src/assets/svg/test-new.svg';
|
||||||
const topicMqtt = 'PIU_GGCP/Devices/PB';
|
const topicMqtt = 'PIU_COD/COMPRESSOR/OVERVIEW';
|
||||||
|
|
||||||
const SvgOverviewCompressor = () => {
|
const SvgOverviewCompressor = () => {
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -13,13 +13,18 @@ import {
|
|||||||
Space,
|
Space,
|
||||||
ConfigProvider,
|
ConfigProvider,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import {
|
import { EditOutlined, DeleteOutlined } from '@ant-design/icons';
|
||||||
EditOutlined,
|
|
||||||
DeleteOutlined
|
|
||||||
} from '@ant-design/icons';
|
|
||||||
import { NotifAlert, NotifOk, NotifConfirmDialog } from '../../../components/Global/ToastNotif';
|
import { NotifAlert, NotifOk, NotifConfirmDialog } from '../../../components/Global/ToastNotif';
|
||||||
import { useBreadcrumb } from '../../../layout/LayoutBreadcrumb';
|
import { useBreadcrumb } from '../../../layout/LayoutBreadcrumb';
|
||||||
import { getBrandById, createBrand, createErrorCode, getErrorCodesByBrandId, updateErrorCode, deleteErrorCode, deleteBrand } from '../../../api/master-brand';
|
import {
|
||||||
|
getBrandById,
|
||||||
|
createBrand,
|
||||||
|
createErrorCode,
|
||||||
|
getErrorCodesByBrandId,
|
||||||
|
updateErrorCode,
|
||||||
|
deleteErrorCode,
|
||||||
|
deleteBrand,
|
||||||
|
} from '../../../api/master-brand';
|
||||||
import BrandForm from './component/BrandForm';
|
import BrandForm from './component/BrandForm';
|
||||||
import ErrorCodeForm from './component/ErrorCodeForm';
|
import ErrorCodeForm from './component/ErrorCodeForm';
|
||||||
import SolutionForm from './component/SolutionForm';
|
import SolutionForm from './component/SolutionForm';
|
||||||
@@ -42,7 +47,9 @@ const AddBrandDevice = () => {
|
|||||||
const [selectedSparepartIds, setSelectedSparepartIds] = useState([]);
|
const [selectedSparepartIds, setSelectedSparepartIds] = useState([]);
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const tab = searchParams.get('tab');
|
const tab = searchParams.get('tab');
|
||||||
const [currentStep, setCurrentStep] = useState(tab === 'error-codes' ? 1 : (location.state?.phase || 0));
|
const [currentStep, setCurrentStep] = useState(
|
||||||
|
tab === 'error-codes' ? 1 : location.state?.phase || 0
|
||||||
|
);
|
||||||
const [editingErrorCodeKey, setEditingErrorCodeKey] = useState(null);
|
const [editingErrorCodeKey, setEditingErrorCodeKey] = useState(null);
|
||||||
const [isErrorCodeFormReadOnly, setIsErrorCodeFormReadOnly] = useState(false);
|
const [isErrorCodeFormReadOnly, setIsErrorCodeFormReadOnly] = useState(false);
|
||||||
const [searchText, setSearchText] = useState('');
|
const [searchText, setSearchText] = useState('');
|
||||||
@@ -68,7 +75,7 @@ const AddBrandDevice = () => {
|
|||||||
const values = solutionForm.getFieldsValue(true);
|
const values = solutionForm.getFieldsValue(true);
|
||||||
const solutions = [];
|
const solutions = [];
|
||||||
|
|
||||||
solutionFields.forEach(fieldKey => {
|
solutionFields.forEach((fieldKey) => {
|
||||||
let solution = null;
|
let solution = null;
|
||||||
|
|
||||||
if (values.solution_items && values.solution_items[fieldKey]) {
|
if (values.solution_items && values.solution_items[fieldKey]) {
|
||||||
@@ -85,9 +92,16 @@ const AddBrandDevice = () => {
|
|||||||
if (solutionType === 'text') {
|
if (solutionType === 'text') {
|
||||||
isValid = solution.text && solution.text.trim() !== '';
|
isValid = solution.text && solution.text.trim() !== '';
|
||||||
} else if (solutionType === 'file') {
|
} else if (solutionType === 'file') {
|
||||||
const hasPathSolution = solution.path_solution && solution.path_solution.trim() !== '';
|
const hasPathSolution =
|
||||||
const hasFileUpload = (solution.fileUpload && typeof solution.fileUpload === 'object' && Object.keys(solution.fileUpload).length > 0);
|
solution.path_solution && solution.path_solution.trim() !== '';
|
||||||
const hasFile = (solution.file && typeof solution.file === 'object' && Object.keys(solution.file).length > 0);
|
const hasFileUpload =
|
||||||
|
solution.fileUpload &&
|
||||||
|
typeof solution.fileUpload === 'object' &&
|
||||||
|
Object.keys(solution.fileUpload).length > 0;
|
||||||
|
const hasFile =
|
||||||
|
solution.file &&
|
||||||
|
typeof solution.file === 'object' &&
|
||||||
|
Object.keys(solution.file).length > 0;
|
||||||
isValid = hasPathSolution || hasFileUpload || hasFile;
|
isValid = hasPathSolution || hasFileUpload || hasFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,9 +132,9 @@ const AddBrandDevice = () => {
|
|||||||
text: '',
|
text: '',
|
||||||
status: true,
|
status: true,
|
||||||
file: null,
|
file: null,
|
||||||
fileUpload: null
|
fileUpload: null,
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
}, 100);
|
}, 100);
|
||||||
}
|
}
|
||||||
@@ -128,7 +142,6 @@ const AddBrandDevice = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const setSolutionsForExistingRecord = (solutions, targetForm) => {
|
const setSolutionsForExistingRecord = (solutions, targetForm) => {
|
||||||
|
|
||||||
if (!targetForm || !solutions || solutions.length === 0) {
|
if (!targetForm || !solutions || solutions.length === 0) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -153,11 +166,14 @@ const AddBrandDevice = () => {
|
|||||||
fileObject = {
|
fileObject = {
|
||||||
uploadPath: solution.path_solution || solution.path_document,
|
uploadPath: solution.path_solution || solution.path_document,
|
||||||
path_solution: solution.path_solution || solution.path_document,
|
path_solution: solution.path_solution || solution.path_document,
|
||||||
name: solution.file_upload_name || (solution.path_solution || solution.path_document).split('/').pop() || 'File',
|
name:
|
||||||
|
solution.file_upload_name ||
|
||||||
|
(solution.path_solution || solution.path_document).split('/').pop() ||
|
||||||
|
'File',
|
||||||
type_solution: solution.type_solution,
|
type_solution: solution.type_solution,
|
||||||
isExisting: true,
|
isExisting: true,
|
||||||
size: 0,
|
size: 0,
|
||||||
url: solution.path_solution || solution.path_document
|
url: solution.path_solution || solution.path_document,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -170,7 +186,7 @@ const AddBrandDevice = () => {
|
|||||||
file: fileObject,
|
file: fileObject,
|
||||||
fileUpload: fileObject,
|
fileUpload: fileObject,
|
||||||
path_solution: solution.path_solution || solution.path_document || null,
|
path_solution: solution.path_solution || solution.path_document || null,
|
||||||
fileName: solution.file_upload_name || null
|
fileName: solution.file_upload_name || null,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -180,28 +196,35 @@ const AddBrandDevice = () => {
|
|||||||
|
|
||||||
setSolutionStatuses(newSolutionStatuses);
|
setSolutionStatuses(newSolutionStatuses);
|
||||||
|
|
||||||
|
|
||||||
targetForm.resetFields();
|
targetForm.resetFields();
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
targetForm.setFieldsValue({
|
targetForm.setFieldsValue({
|
||||||
solution_items: solutionItems
|
solution_items: solutionItems,
|
||||||
});
|
});
|
||||||
|
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
Object.keys(solutionItems).forEach(key => {
|
Object.keys(solutionItems).forEach((key) => {
|
||||||
const solution = solutionItems[key];
|
const solution = solutionItems[key];
|
||||||
targetForm.setFieldValue(['solution_items', key, 'name'], solution.name);
|
targetForm.setFieldValue(['solution_items', key, 'name'], solution.name);
|
||||||
targetForm.setFieldValue(['solution_items', key, 'type'], solution.type);
|
targetForm.setFieldValue(['solution_items', key, 'type'], solution.type);
|
||||||
targetForm.setFieldValue(['solution_items', key, 'text'], solution.text);
|
targetForm.setFieldValue(['solution_items', key, 'text'], solution.text);
|
||||||
targetForm.setFieldValue(['solution_items', key, 'file'], solution.file);
|
targetForm.setFieldValue(['solution_items', key, 'file'], solution.file);
|
||||||
targetForm.setFieldValue(['solution_items', key, 'fileUpload'], solution.fileUpload);
|
targetForm.setFieldValue(
|
||||||
|
['solution_items', key, 'fileUpload'],
|
||||||
|
solution.fileUpload
|
||||||
|
);
|
||||||
targetForm.setFieldValue(['solution_items', key, 'status'], solution.status);
|
targetForm.setFieldValue(['solution_items', key, 'status'], solution.status);
|
||||||
targetForm.setFieldValue(['solution_items', key, 'path_solution'], solution.path_solution);
|
targetForm.setFieldValue(
|
||||||
targetForm.setFieldValue(['solution_items', key, 'fileName'], solution.fileName);
|
['solution_items', key, 'path_solution'],
|
||||||
|
solution.path_solution
|
||||||
|
);
|
||||||
|
targetForm.setFieldValue(
|
||||||
|
['solution_items', key, 'fileName'],
|
||||||
|
solution.fileName
|
||||||
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const finalValues = targetForm.getFieldsValue();
|
const finalValues = targetForm.getFieldsValue();
|
||||||
}, 100);
|
}, 100);
|
||||||
}, 100);
|
}, 100);
|
||||||
@@ -209,14 +232,14 @@ const AddBrandDevice = () => {
|
|||||||
|
|
||||||
const handleAddSolutionField = () => {
|
const handleAddSolutionField = () => {
|
||||||
const newKey = Math.max(...solutionFields, 0) + 1;
|
const newKey = Math.max(...solutionFields, 0) + 1;
|
||||||
setSolutionFields(prev => [...prev, newKey]);
|
setSolutionFields((prev) => [...prev, newKey]);
|
||||||
setSolutionTypes(prev => ({ ...prev, [newKey]: 'text' }));
|
setSolutionTypes((prev) => ({ ...prev, [newKey]: 'text' }));
|
||||||
setSolutionStatuses(prev => ({ ...prev, [newKey]: true }));
|
setSolutionStatuses((prev) => ({ ...prev, [newKey]: true }));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleRemoveSolutionField = (fieldKey) => {
|
const handleRemoveSolutionField = (fieldKey) => {
|
||||||
if (solutionFields.length > 1) {
|
if (solutionFields.length > 1) {
|
||||||
setSolutionFields(prev => prev.filter(key => key !== fieldKey));
|
setSolutionFields((prev) => prev.filter((key) => key !== fieldKey));
|
||||||
const newTypes = { ...solutionTypes };
|
const newTypes = { ...solutionTypes };
|
||||||
const newStatuses = { ...solutionStatuses };
|
const newStatuses = { ...solutionStatuses };
|
||||||
delete newTypes[fieldKey];
|
delete newTypes[fieldKey];
|
||||||
@@ -233,7 +256,7 @@ const AddBrandDevice = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSolutionTypeChange = (fieldKey, type) => {
|
const handleSolutionTypeChange = (fieldKey, type) => {
|
||||||
setSolutionTypes(prev => ({ ...prev, [fieldKey]: type }));
|
setSolutionTypes((prev) => ({ ...prev, [fieldKey]: type }));
|
||||||
|
|
||||||
if (type === 'file') {
|
if (type === 'file') {
|
||||||
solutionForm.setFieldValue(['solution_items', fieldKey, 'text'], '');
|
solutionForm.setFieldValue(['solution_items', fieldKey, 'text'], '');
|
||||||
@@ -246,7 +269,7 @@ const AddBrandDevice = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSolutionStatusChange = (fieldKey, status) => {
|
const handleSolutionStatusChange = (fieldKey, status) => {
|
||||||
setSolutionStatuses(prev => ({ ...prev, [fieldKey]: status }));
|
setSolutionStatuses((prev) => ({ ...prev, [fieldKey]: status }));
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleNextStep = async () => {
|
const handleNextStep = async () => {
|
||||||
@@ -259,7 +282,7 @@ const AddBrandDevice = () => {
|
|||||||
brand_type: brandValues.brand_type || '',
|
brand_type: brandValues.brand_type || '',
|
||||||
brand_manufacture: brandValues.brand_manufacture || '',
|
brand_manufacture: brandValues.brand_manufacture || '',
|
||||||
brand_model: brandValues.brand_model || '',
|
brand_model: brandValues.brand_model || '',
|
||||||
is_active: brandValues.is_active !== undefined ? brandValues.is_active : true
|
is_active: brandValues.is_active !== undefined ? brandValues.is_active : true,
|
||||||
};
|
};
|
||||||
|
|
||||||
const response = await createBrand(brandApiData);
|
const response = await createBrand(brandApiData);
|
||||||
@@ -268,7 +291,7 @@ const AddBrandDevice = () => {
|
|||||||
const newBrandInfo = {
|
const newBrandInfo = {
|
||||||
...brandValues,
|
...brandValues,
|
||||||
brand_id: response.data.brand_id,
|
brand_id: response.data.brand_id,
|
||||||
brand_code: response.data.brand_code
|
brand_code: response.data.brand_code,
|
||||||
};
|
};
|
||||||
setBrandInfo(newBrandInfo);
|
setBrandInfo(newBrandInfo);
|
||||||
setTemporaryBrandId(response.data.brand_id);
|
setTemporaryBrandId(response.data.brand_id);
|
||||||
@@ -307,8 +330,7 @@ const AddBrandDevice = () => {
|
|||||||
if (isTemporaryBrand && temporaryBrandId) {
|
if (isTemporaryBrand && temporaryBrandId) {
|
||||||
try {
|
try {
|
||||||
await deleteBrand(temporaryBrandId);
|
await deleteBrand(temporaryBrandId);
|
||||||
} catch (error) {
|
} catch (error) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
navigate('/master/brand-device');
|
navigate('/master/brand-device');
|
||||||
};
|
};
|
||||||
@@ -360,8 +382,6 @@ const AddBrandDevice = () => {
|
|||||||
setTrigerFilter((prev) => !prev);
|
setTrigerFilter((prev) => !prev);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
const resetErrorCodeForm = () => {
|
const resetErrorCodeForm = () => {
|
||||||
errorCodeForm.resetFields();
|
errorCodeForm.resetFields();
|
||||||
errorCodeForm.setFieldsValue({
|
errorCodeForm.setFieldsValue({
|
||||||
@@ -391,16 +411,16 @@ const AddBrandDevice = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!solutionData || solutionData.length === 0) {
|
// if (!solutionData || solutionData.length === 0) {
|
||||||
NotifAlert({
|
// NotifAlert({
|
||||||
icon: 'warning',
|
// icon: 'warning',
|
||||||
title: 'Perhatian',
|
// title: 'Perhatian',
|
||||||
message: 'Setiap error code harus memiliki minimal 1 solution!',
|
// message: 'Setiap error code harus memiliki minimal 1 solution!',
|
||||||
});
|
// });
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
const formattedSolutions = solutionData.map(solution => {
|
const formattedSolutions = solutionData.map((solution) => {
|
||||||
const solutionType = solution.type || 'text';
|
const solutionType = solution.type || 'text';
|
||||||
|
|
||||||
let typeSolution = solutionType === 'text' ? 'text' : 'image';
|
let typeSolution = solutionType === 'text' ? 'text' : 'image';
|
||||||
@@ -422,7 +442,11 @@ const AddBrandDevice = () => {
|
|||||||
} else {
|
} else {
|
||||||
formattedSolution.text_solution = '';
|
formattedSolution.text_solution = '';
|
||||||
|
|
||||||
formattedSolution.path_solution = solution.path_solution || solution.file?.uploadPath || solution.fileUpload?.uploadPath || '';
|
formattedSolution.path_solution =
|
||||||
|
solution.path_solution ||
|
||||||
|
solution.file?.uploadPath ||
|
||||||
|
solution.fileUpload?.uploadPath ||
|
||||||
|
'';
|
||||||
}
|
}
|
||||||
|
|
||||||
if (formattedSolution.brand_code_solution_id) {
|
if (formattedSolution.brand_code_solution_id) {
|
||||||
@@ -440,7 +464,7 @@ const AddBrandDevice = () => {
|
|||||||
path_icon: errorCodeIcon?.uploadPath || '',
|
path_icon: errorCodeIcon?.uploadPath || '',
|
||||||
is_active: errorCodeValues.status === undefined ? true : errorCodeValues.status,
|
is_active: errorCodeValues.status === undefined ? true : errorCodeValues.status,
|
||||||
solution: formattedSolutions,
|
solution: formattedSolutions,
|
||||||
spareparts: selectedSparepartIds || []
|
spareparts: selectedSparepartIds || [],
|
||||||
};
|
};
|
||||||
|
|
||||||
let response;
|
let response;
|
||||||
@@ -456,11 +480,13 @@ const AddBrandDevice = () => {
|
|||||||
NotifOk({
|
NotifOk({
|
||||||
icon: 'success',
|
icon: 'success',
|
||||||
title: 'Berhasil',
|
title: 'Berhasil',
|
||||||
message: editingErrorCodeKey ? 'Error code berhasil diupdate!' : 'Error code berhasil ditambahkan!',
|
message: editingErrorCodeKey
|
||||||
|
? 'Error code berhasil diupdate!'
|
||||||
|
: 'Error code berhasil ditambahkan!',
|
||||||
});
|
});
|
||||||
|
|
||||||
resetErrorCodeForm();
|
resetErrorCodeForm();
|
||||||
setTrigerFilter(prev => !prev);
|
setTrigerFilter((prev) => !prev);
|
||||||
} else {
|
} else {
|
||||||
NotifAlert({
|
NotifAlert({
|
||||||
icon: 'error',
|
icon: 'error',
|
||||||
@@ -479,12 +505,10 @@ const AddBrandDevice = () => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const handleErrorCodeIconRemove = () => {
|
const handleErrorCodeIconRemove = () => {
|
||||||
setErrorCodeIcon(null);
|
setErrorCodeIcon(null);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
const handleFinish = async () => {
|
const handleFinish = async () => {
|
||||||
setConfirmLoading(true);
|
setConfirmLoading(true);
|
||||||
try {
|
try {
|
||||||
@@ -506,10 +530,10 @@ const AddBrandDevice = () => {
|
|||||||
const response = await getErrorCodesByBrandId(brandInfo.brand_id, queryParams);
|
const response = await getErrorCodesByBrandId(brandInfo.brand_id, queryParams);
|
||||||
|
|
||||||
if (response && response.statusCode === 200 && response.data) {
|
if (response && response.statusCode === 200 && response.data) {
|
||||||
const freshErrorCodes = response.data.map(ec => ({
|
const freshErrorCodes = response.data.map((ec) => ({
|
||||||
...ec,
|
...ec,
|
||||||
tempId: `existing_${ec.error_code_id}`,
|
tempId: `existing_${ec.error_code_id}`,
|
||||||
status: 'existing'
|
status: 'existing',
|
||||||
}));
|
}));
|
||||||
setApiErrorCodes(freshErrorCodes);
|
setApiErrorCodes(freshErrorCodes);
|
||||||
|
|
||||||
@@ -517,7 +541,8 @@ const AddBrandDevice = () => {
|
|||||||
NotifAlert({
|
NotifAlert({
|
||||||
icon: 'warning',
|
icon: 'warning',
|
||||||
title: 'Perhatian',
|
title: 'Perhatian',
|
||||||
message: 'Harap tambahkan minimal 1 error code sebelum menyelesaikan.',
|
message:
|
||||||
|
'Harap tambahkan minimal 1 error code sebelum menyelesaikan.',
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -526,7 +551,8 @@ const AddBrandDevice = () => {
|
|||||||
NotifAlert({
|
NotifAlert({
|
||||||
icon: 'warning',
|
icon: 'warning',
|
||||||
title: 'Perhatian',
|
title: 'Perhatian',
|
||||||
message: 'Harap tambahkan minimal 1 error code sebelum menyelesaikan.',
|
message:
|
||||||
|
'Harap tambahkan minimal 1 error code sebelum menyelesaikan.',
|
||||||
});
|
});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -591,11 +617,7 @@ const AddBrandDevice = () => {
|
|||||||
<Spin size="large" />
|
<Spin size="large" />
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<BrandForm
|
<BrandForm form={brandForm} isEdit={false} brandInfo={brandInfo} />
|
||||||
form={brandForm}
|
|
||||||
isEdit={false}
|
|
||||||
brandInfo={brandInfo}
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -635,31 +657,39 @@ const AddBrandDevice = () => {
|
|||||||
</Col>
|
</Col>
|
||||||
|
|
||||||
<Col xs={24} md={16} lg={16}>
|
<Col xs={24} md={16} lg={16}>
|
||||||
<div style={{
|
<div
|
||||||
paddingLeft: '12px'
|
style={{
|
||||||
}}>
|
paddingLeft: '12px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
<Card
|
<Card
|
||||||
title={
|
title={
|
||||||
<div style={{
|
<div
|
||||||
display: 'flex',
|
style={{
|
||||||
alignItems: 'center',
|
|
||||||
justifyContent: 'space-between',
|
|
||||||
width: '100%'
|
|
||||||
}}>
|
|
||||||
<span style={{
|
|
||||||
fontSize: '16px',
|
|
||||||
fontWeight: '600',
|
|
||||||
color: '#262626',
|
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
alignItems: 'center',
|
||||||
gap: '8px'
|
justifyContent: 'space-between',
|
||||||
}}>
|
width: '100%',
|
||||||
<span style={{
|
}}
|
||||||
width: '4px',
|
>
|
||||||
height: '20px',
|
<span
|
||||||
backgroundColor: '#23A55A',
|
style={{
|
||||||
borderRadius: '2px'
|
fontSize: '16px',
|
||||||
}}></span>
|
fontWeight: '600',
|
||||||
|
color: '#262626',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: '8px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
width: '4px',
|
||||||
|
height: '20px',
|
||||||
|
backgroundColor: '#23A55A',
|
||||||
|
borderRadius: '2px',
|
||||||
|
}}
|
||||||
|
></span>
|
||||||
Error Code Form
|
Error Code Form
|
||||||
</span>
|
</span>
|
||||||
<Button
|
<Button
|
||||||
@@ -675,43 +705,51 @@ const AddBrandDevice = () => {
|
|||||||
padding: '0 24px',
|
padding: '0 24px',
|
||||||
fontWeight: '500',
|
fontWeight: '500',
|
||||||
boxShadow: '0 2px 4px rgba(35, 165, 90, 0.2)',
|
boxShadow: '0 2px 4px rgba(35, 165, 90, 0.2)',
|
||||||
transition: 'all 0.3s ease'
|
transition: 'all 0.3s ease',
|
||||||
}}
|
}}
|
||||||
onMouseEnter={(e) => {
|
onMouseEnter={(e) => {
|
||||||
e.target.style.boxShadow = '0 4px 8px rgba(35, 165, 90, 0.3)';
|
e.target.style.boxShadow =
|
||||||
|
'0 4px 8px rgba(35, 165, 90, 0.3)';
|
||||||
}}
|
}}
|
||||||
onMouseLeave={(e) => {
|
onMouseLeave={(e) => {
|
||||||
e.target.style.boxShadow = '0 2px 4px rgba(35, 165, 90, 0.2)';
|
e.target.style.boxShadow =
|
||||||
|
'0 2px 4px rgba(35, 165, 90, 0.2)';
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{editingErrorCodeKey ? 'Update Error Code' : 'Save Error Code'}
|
{editingErrorCodeKey
|
||||||
|
? 'Update Error Code'
|
||||||
|
: 'Save Error Code'}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
style={{
|
style={{
|
||||||
width: '100%',
|
width: '100%',
|
||||||
boxShadow: '0 2px 8px rgba(0,0,0,0.06)',
|
boxShadow: '0 2px 8px rgba(0,0,0,0.06)',
|
||||||
borderRadius: '12px'
|
borderRadius: '12px',
|
||||||
}}
|
}}
|
||||||
styles={{
|
styles={{
|
||||||
body: { padding: '16px 24px 12px 24px' },
|
body: { padding: '16px 24px 12px 24px' },
|
||||||
header: {
|
header: {
|
||||||
padding: '16px 24px',
|
padding: '16px 24px',
|
||||||
borderBottom: '1px solid #f0f0f0',
|
borderBottom: '1px solid #f0f0f0',
|
||||||
backgroundColor: '#fafafa'
|
backgroundColor: '#fafafa',
|
||||||
}
|
},
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<div style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}>
|
<div
|
||||||
<div style={{
|
style={{ display: 'flex', flexDirection: 'column', gap: '8px' }}
|
||||||
padding: '16px',
|
>
|
||||||
border: '1px solid #f0f0f0',
|
<div
|
||||||
borderRadius: '10px',
|
style={{
|
||||||
backgroundColor: '#ffffff',
|
padding: '16px',
|
||||||
marginBottom: '0',
|
border: '1px solid #f0f0f0',
|
||||||
transition: 'all 0.3s ease',
|
borderRadius: '10px',
|
||||||
boxShadow: '0 1px 3px rgba(0,0,0,0.04)'
|
backgroundColor: '#ffffff',
|
||||||
}}>
|
marginBottom: '0',
|
||||||
|
transition: 'all 0.3s ease',
|
||||||
|
boxShadow: '0 1px 3px rgba(0,0,0,0.04)',
|
||||||
|
}}
|
||||||
|
>
|
||||||
<ErrorCodeForm
|
<ErrorCodeForm
|
||||||
errorCodeForm={errorCodeForm}
|
errorCodeForm={errorCodeForm}
|
||||||
isErrorCodeFormReadOnly={isErrorCodeFormReadOnly}
|
isErrorCodeFormReadOnly={isErrorCodeFormReadOnly}
|
||||||
@@ -724,29 +762,42 @@ const AddBrandDevice = () => {
|
|||||||
|
|
||||||
<Row gutter={[20, 0]} style={{ marginTop: '0' }}>
|
<Row gutter={[20, 0]} style={{ marginTop: '0' }}>
|
||||||
<Col xs={24} md={12} lg={12}>
|
<Col xs={24} md={12} lg={12}>
|
||||||
<div style={{
|
<div
|
||||||
padding: '16px',
|
style={{
|
||||||
border: '1px solid #f0f0f0',
|
padding: '16px',
|
||||||
borderRadius: '10px',
|
border: '1px solid #f0f0f0',
|
||||||
backgroundColor: '#ffffff',
|
borderRadius: '10px',
|
||||||
transition: 'all 0.3s ease',
|
backgroundColor: '#ffffff',
|
||||||
boxShadow: '0 1px 3px rgba(0,0,0,0.04)'
|
transition: 'all 0.3s ease',
|
||||||
}}>
|
boxShadow: '0 1px 3px rgba(0,0,0,0.04)',
|
||||||
<div style={{
|
}}
|
||||||
display: 'flex',
|
>
|
||||||
alignItems: 'center',
|
<div
|
||||||
gap: '8px',
|
style={{
|
||||||
marginBottom: '12px',
|
display: 'flex',
|
||||||
paddingBottom: '8px',
|
alignItems: 'center',
|
||||||
borderBottom: '1px solid #f5f5f5'
|
gap: '8px',
|
||||||
}}>
|
marginBottom: '12px',
|
||||||
<div style={{
|
paddingBottom: '8px',
|
||||||
width: '3px',
|
borderBottom: '1px solid #f5f5f5',
|
||||||
height: '16px',
|
}}
|
||||||
backgroundColor: '#1890ff',
|
>
|
||||||
borderRadius: '2px'
|
<div
|
||||||
}}></div>
|
style={{
|
||||||
<h4 style={{ margin: 0, color: '#262626', fontSize: '14px', fontWeight: '600' }}>
|
width: '3px',
|
||||||
|
height: '16px',
|
||||||
|
backgroundColor: '#1890ff',
|
||||||
|
borderRadius: '2px',
|
||||||
|
}}
|
||||||
|
></div>
|
||||||
|
<h4
|
||||||
|
style={{
|
||||||
|
margin: 0,
|
||||||
|
color: '#262626',
|
||||||
|
fontSize: '14px',
|
||||||
|
fontWeight: '600',
|
||||||
|
}}
|
||||||
|
>
|
||||||
Solution
|
Solution
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
@@ -756,14 +807,23 @@ const AddBrandDevice = () => {
|
|||||||
solutionTypes={solutionTypes}
|
solutionTypes={solutionTypes}
|
||||||
solutionStatuses={solutionStatuses}
|
solutionStatuses={solutionStatuses}
|
||||||
onAddSolutionField={handleAddSolutionField}
|
onAddSolutionField={handleAddSolutionField}
|
||||||
onRemoveSolutionField={handleRemoveSolutionField}
|
onRemoveSolutionField={
|
||||||
|
handleRemoveSolutionField
|
||||||
|
}
|
||||||
onSolutionTypeChange={handleSolutionTypeChange}
|
onSolutionTypeChange={handleSolutionTypeChange}
|
||||||
onSolutionStatusChange={handleSolutionStatusChange}
|
onSolutionStatusChange={
|
||||||
onSolutionFileUpload={(fileData) => {
|
handleSolutionStatusChange
|
||||||
}}
|
}
|
||||||
|
onSolutionFileUpload={(fileData) => {}}
|
||||||
onFileView={(fileData) => {
|
onFileView={(fileData) => {
|
||||||
if (fileData && (fileData.url || fileData.uploadPath)) {
|
if (
|
||||||
window.open(fileData.url || fileData.uploadPath, '_blank');
|
fileData &&
|
||||||
|
(fileData.url || fileData.uploadPath)
|
||||||
|
) {
|
||||||
|
window.open(
|
||||||
|
fileData.url || fileData.uploadPath,
|
||||||
|
'_blank'
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
isReadOnly={false}
|
isReadOnly={false}
|
||||||
@@ -772,40 +832,55 @@ const AddBrandDevice = () => {
|
|||||||
</div>
|
</div>
|
||||||
</Col>
|
</Col>
|
||||||
<Col xs={24} md={12} lg={12}>
|
<Col xs={24} md={12} lg={12}>
|
||||||
<div style={{
|
<div
|
||||||
padding: '16px',
|
style={{
|
||||||
border: '1px solid #f0f0f0',
|
padding: '16px',
|
||||||
borderRadius: '10px',
|
border: '1px solid #f0f0f0',
|
||||||
backgroundColor: '#ffffff',
|
borderRadius: '10px',
|
||||||
transition: 'all 0.3s ease',
|
backgroundColor: '#ffffff',
|
||||||
boxShadow: '0 1px 3px rgba(0,0,0,0.04)'
|
transition: 'all 0.3s ease',
|
||||||
}}>
|
boxShadow: '0 1px 3px rgba(0,0,0,0.04)',
|
||||||
<div style={{
|
}}
|
||||||
display: 'flex',
|
>
|
||||||
alignItems: 'center',
|
<div
|
||||||
gap: '8px',
|
style={{
|
||||||
marginBottom: '12px',
|
display: 'flex',
|
||||||
paddingBottom: '8px',
|
alignItems: 'center',
|
||||||
borderBottom: '1px solid #f5f5f5'
|
gap: '8px',
|
||||||
}}>
|
marginBottom: '12px',
|
||||||
<div style={{
|
paddingBottom: '8px',
|
||||||
width: '3px',
|
borderBottom: '1px solid #f5f5f5',
|
||||||
height: '16px',
|
}}
|
||||||
backgroundColor: '#faad14',
|
>
|
||||||
borderRadius: '2px'
|
<div
|
||||||
}}></div>
|
style={{
|
||||||
<h4 style={{ margin: 0, color: '#262626', fontSize: '14px', fontWeight: '600' }}>
|
width: '3px',
|
||||||
|
height: '16px',
|
||||||
|
backgroundColor: '#faad14',
|
||||||
|
borderRadius: '2px',
|
||||||
|
}}
|
||||||
|
></div>
|
||||||
|
<h4
|
||||||
|
style={{
|
||||||
|
margin: 0,
|
||||||
|
color: '#262626',
|
||||||
|
fontSize: '14px',
|
||||||
|
fontWeight: '600',
|
||||||
|
}}
|
||||||
|
>
|
||||||
Sparepart Selection
|
Sparepart Selection
|
||||||
</h4>
|
</h4>
|
||||||
</div>
|
</div>
|
||||||
<div style={{
|
<div
|
||||||
maxHeight: '45vh',
|
style={{
|
||||||
overflow: 'auto',
|
maxHeight: '45vh',
|
||||||
border: '1px solid #e8e8e8',
|
overflow: 'auto',
|
||||||
borderRadius: '8px',
|
border: '1px solid #e8e8e8',
|
||||||
padding: '12px',
|
borderRadius: '8px',
|
||||||
backgroundColor: '#fafafa'
|
padding: '12px',
|
||||||
}}>
|
backgroundColor: '#fafafa',
|
||||||
|
}}
|
||||||
|
>
|
||||||
<SparepartSelect
|
<SparepartSelect
|
||||||
selectedSparepartIds={selectedSparepartIds}
|
selectedSparepartIds={selectedSparepartIds}
|
||||||
onSparepartChange={setSelectedSparepartIds}
|
onSparepartChange={setSelectedSparepartIds}
|
||||||
@@ -816,15 +891,16 @@ const AddBrandDevice = () => {
|
|||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
<div style={{
|
<div
|
||||||
display: 'flex',
|
style={{
|
||||||
justifyContent: 'space-between',
|
display: 'flex',
|
||||||
alignItems: 'center',
|
justifyContent: 'space-between',
|
||||||
padding: '16px 0 0 0',
|
alignItems: 'center',
|
||||||
borderTop: '1px solid #f0f0f0',
|
padding: '16px 0 0 0',
|
||||||
marginTop: '12px'
|
borderTop: '1px solid #f0f0f0',
|
||||||
}}>
|
marginTop: '12px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
{editingErrorCodeKey && (
|
{editingErrorCodeKey && (
|
||||||
<Button
|
<Button
|
||||||
size="large"
|
size="large"
|
||||||
@@ -837,7 +913,7 @@ const AddBrandDevice = () => {
|
|||||||
height: '40px',
|
height: '40px',
|
||||||
padding: '0 24px',
|
padding: '0 24px',
|
||||||
fontWeight: '500',
|
fontWeight: '500',
|
||||||
transition: 'all 0.3s ease'
|
transition: 'all 0.3s ease',
|
||||||
}}
|
}}
|
||||||
onMouseEnter={(e) => {
|
onMouseEnter={(e) => {
|
||||||
e.target.style.borderColor = '#ff4d4f';
|
e.target.style.borderColor = '#ff4d4f';
|
||||||
@@ -871,7 +947,7 @@ const AddBrandDevice = () => {
|
|||||||
|
|
||||||
setBreadcrumbItems([
|
setBreadcrumbItems([
|
||||||
{
|
{
|
||||||
title: <span style={{ fontSize: '14px', fontWeight: 'bold' }}>• Master</span>
|
title: <span style={{ fontSize: '14px', fontWeight: 'bold' }}>• Master</span>,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: (
|
title: (
|
||||||
@@ -895,12 +971,11 @@ const AddBrandDevice = () => {
|
|||||||
if (location.state?.fromFileViewer && location.state.phase !== undefined) {
|
if (location.state?.fromFileViewer && location.state.phase !== undefined) {
|
||||||
setCurrentStep(location.state.phase);
|
setCurrentStep(location.state.phase);
|
||||||
}
|
}
|
||||||
|
|
||||||
}, [setBreadcrumbItems, navigate, searchParams, location.state]);
|
}, [setBreadcrumbItems, navigate, searchParams, location.state]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (brandInfo.brand_id && currentStep === 1) {
|
if (brandInfo.brand_id && currentStep === 1) {
|
||||||
setTrigerFilter(prev => !prev);
|
setTrigerFilter((prev) => !prev);
|
||||||
}
|
}
|
||||||
}, [brandInfo.brand_id, currentStep]);
|
}, [brandInfo.brand_id, currentStep]);
|
||||||
|
|
||||||
@@ -913,8 +988,7 @@ const AddBrandDevice = () => {
|
|||||||
const errorCodes = response.data || [];
|
const errorCodes = response.data || [];
|
||||||
setApiErrorCodes(errorCodes);
|
setApiErrorCodes(errorCodes);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
fetchErrorCodes();
|
fetchErrorCodes();
|
||||||
@@ -925,8 +999,7 @@ const AddBrandDevice = () => {
|
|||||||
if (isTemporaryBrand && temporaryBrandId && currentStep === 0) {
|
if (isTemporaryBrand && temporaryBrandId && currentStep === 0) {
|
||||||
try {
|
try {
|
||||||
await deleteBrand(temporaryBrandId);
|
await deleteBrand(temporaryBrandId);
|
||||||
} catch (error) {
|
} catch (error) {}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -937,7 +1010,6 @@ const AddBrandDevice = () => {
|
|||||||
};
|
};
|
||||||
}, [isTemporaryBrand, temporaryBrandId, currentStep]);
|
}, [isTemporaryBrand, temporaryBrandId, currentStep]);
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ConfigProvider
|
<ConfigProvider
|
||||||
theme={{
|
theme={{
|
||||||
@@ -988,14 +1060,9 @@ const AddBrandDevice = () => {
|
|||||||
<Divider />
|
<Divider />
|
||||||
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
|
||||||
<div>
|
<div>
|
||||||
<Button onClick={handleCancel}>
|
<Button onClick={handleCancel}>Cancel</Button>
|
||||||
Cancel
|
|
||||||
</Button>
|
|
||||||
{currentStep === 1 && (
|
{currentStep === 1 && (
|
||||||
<Button
|
<Button onClick={handlePrevStep} style={{ marginLeft: 8 }}>
|
||||||
onClick={handlePrevStep}
|
|
||||||
style={{ marginLeft: 8 }}
|
|
||||||
>
|
|
||||||
Kembali ke Brand Info
|
Kembali ke Brand Info
|
||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
@@ -1034,4 +1101,4 @@ const AddBrandDevice = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default AddBrandDevice;
|
export default AddBrandDevice;
|
||||||
|
|||||||
@@ -479,14 +479,14 @@ const EditBrandDevice = () => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!solutionData || solutionData.length === 0) {
|
// if (!solutionData || solutionData.length === 0) {
|
||||||
NotifAlert({
|
// NotifAlert({
|
||||||
icon: 'warning',
|
// icon: 'warning',
|
||||||
title: 'Perhatian',
|
// title: 'Perhatian',
|
||||||
message: 'Setiap error code harus memiliki minimal 1 solution!',
|
// message: 'Setiap error code harus memiliki minimal 1 solution!',
|
||||||
});
|
// });
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
const formattedSolutions = solutionData.map(solution => {
|
const formattedSolutions = solutionData.map(solution => {
|
||||||
const solutionType = solution.type || 'text';
|
const solutionType = solution.type || 'text';
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ const DetailPlantSubSection = (props) => {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log(`📝 Input change: ${name} = ${value}`);
|
// console.log(`📝 Input change: ${name} = ${value}`);
|
||||||
|
|
||||||
if (name) {
|
if (name) {
|
||||||
setFormData((prev) => ({
|
setFormData((prev) => ({
|
||||||
@@ -74,16 +74,20 @@ const DetailPlantSubSection = (props) => {
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log('💾 Current formData before save:', formData);
|
// console.log('💾 Current formData before save:', formData);
|
||||||
|
|
||||||
const payload = {
|
const payload = {
|
||||||
plant_sub_section_name: formData.plant_sub_section_name,
|
plant_sub_section_name: formData.plant_sub_section_name,
|
||||||
plant_sub_section_description: (formData.plant_sub_section_description && formData.plant_sub_section_description.trim() !== '') ? formData.plant_sub_section_description : ' ',
|
plant_sub_section_description:
|
||||||
|
formData.plant_sub_section_description &&
|
||||||
|
formData.plant_sub_section_description.trim() !== ''
|
||||||
|
? formData.plant_sub_section_description
|
||||||
|
: ' ',
|
||||||
table_name_value: formData.table_name_value, // Fix field name
|
table_name_value: formData.table_name_value, // Fix field name
|
||||||
is_active: formData.is_active,
|
is_active: formData.is_active,
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('📤 Payload to be sent:', payload);
|
// console.log('📤 Payload to be sent:', payload);
|
||||||
|
|
||||||
const response =
|
const response =
|
||||||
props.actionMode === 'edit'
|
props.actionMode === 'edit'
|
||||||
@@ -126,17 +130,17 @@ const DetailPlantSubSection = (props) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log('🔄 Modal state changed:', {
|
// console.log('🔄 Modal state changed:', {
|
||||||
showModal: props.showModal,
|
// showModal: props.showModal,
|
||||||
actionMode: props.actionMode,
|
// actionMode: props.actionMode,
|
||||||
selectedData: props.selectedData,
|
// selectedData: props.selectedData,
|
||||||
});
|
// });
|
||||||
|
|
||||||
if (props.selectedData) {
|
if (props.selectedData) {
|
||||||
console.log('📋 Setting form data from selectedData:', props.selectedData);
|
// console.log('📋 Setting form data from selectedData:', props.selectedData);
|
||||||
setFormData(props.selectedData);
|
setFormData(props.selectedData);
|
||||||
} else {
|
} else {
|
||||||
console.log('📋 Resetting to default data');
|
// console.log('📋 Resetting to default data');
|
||||||
setFormData(defaultData);
|
setFormData(defaultData);
|
||||||
}
|
}
|
||||||
}, [props.showModal, props.selectedData, props.actionMode]);
|
}, [props.showModal, props.selectedData, props.actionMode]);
|
||||||
|
|||||||
@@ -112,9 +112,9 @@ const DetailShift = (props) => {
|
|||||||
is_active: formData.is_active,
|
is_active: formData.is_active,
|
||||||
};
|
};
|
||||||
|
|
||||||
console.log('Payload yang dikirim:', payload);
|
// console.log('Payload yang dikirim:', payload);
|
||||||
console.log('Type start_time:', typeof payload.start_time, payload.start_time);
|
// console.log('Type start_time:', typeof payload.start_time, payload.start_time);
|
||||||
console.log('Type end_time:', typeof payload.end_time, payload.end_time);
|
// console.log('Type end_time:', typeof payload.end_time, payload.end_time);
|
||||||
|
|
||||||
const response =
|
const response =
|
||||||
props.actionMode === 'edit'
|
props.actionMode === 'edit'
|
||||||
|
|||||||
@@ -95,11 +95,11 @@ const DetailSparepart = (props) => {
|
|||||||
const newFile = fileList.length > 0 ? fileList[0] : null;
|
const newFile = fileList.length > 0 ? fileList[0] : null;
|
||||||
|
|
||||||
if (newFile && newFile.originFileObj) {
|
if (newFile && newFile.originFileObj) {
|
||||||
console.log('Uploading file:', newFile.originFileObj);
|
// console.log('Uploading file:', newFile.originFileObj);
|
||||||
const uploadResponse = await uploadFile(newFile.originFileObj, 'images');
|
const uploadResponse = await uploadFile(newFile.originFileObj, 'images');
|
||||||
|
|
||||||
// Log untuk debugging
|
// Log untuk debugging
|
||||||
console.log('Upload response:', uploadResponse);
|
// console.log('Upload response:', uploadResponse);
|
||||||
|
|
||||||
// Cek berbagai kemungkinan struktur respons dari API
|
// Cek berbagai kemungkinan struktur respons dari API
|
||||||
let uploadedUrl = null;
|
let uploadedUrl = null;
|
||||||
@@ -169,7 +169,7 @@ const DetailSparepart = (props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (uploadedUrl) {
|
if (uploadedUrl) {
|
||||||
console.log('Successfully extracted image URL:', uploadedUrl);
|
// console.log('Successfully extracted image URL:', uploadedUrl);
|
||||||
imageUrl = uploadedUrl;
|
imageUrl = uploadedUrl;
|
||||||
} else {
|
} else {
|
||||||
console.error('Upload response structure:', uploadResponse);
|
console.error('Upload response structure:', uploadResponse);
|
||||||
@@ -209,7 +209,10 @@ const DetailSparepart = (props) => {
|
|||||||
sparepart_name: formData.sparepart_name, // Wajib
|
sparepart_name: formData.sparepart_name, // Wajib
|
||||||
};
|
};
|
||||||
|
|
||||||
payload.sparepart_description = (formData.sparepart_description && formData.sparepart_description.trim() !== '') ? formData.sparepart_description : ' ';
|
payload.sparepart_description =
|
||||||
|
formData.sparepart_description && formData.sparepart_description.trim() !== ''
|
||||||
|
? formData.sparepart_description
|
||||||
|
: ' ';
|
||||||
if (formData.sparepart_model && formData.sparepart_model.trim() !== '') {
|
if (formData.sparepart_model && formData.sparepart_model.trim() !== '') {
|
||||||
payload.sparepart_model = formData.sparepart_model;
|
payload.sparepart_model = formData.sparepart_model;
|
||||||
}
|
}
|
||||||
@@ -233,13 +236,13 @@ const DetailSparepart = (props) => {
|
|||||||
payload.sparepart_foto = imageUrl;
|
payload.sparepart_foto = imageUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Sending payload:', payload);
|
// console.log('Sending payload:', payload);
|
||||||
|
|
||||||
const response = formData.sparepart_id
|
const response = formData.sparepart_id
|
||||||
? await updateSparepart(formData.sparepart_id, payload)
|
? await updateSparepart(formData.sparepart_id, payload)
|
||||||
: await createSparepart(payload);
|
: await createSparepart(payload);
|
||||||
|
|
||||||
console.log('API response:', response);
|
// console.log('API response:', response);
|
||||||
|
|
||||||
if (response && (response.statusCode === 200 || response.statusCode === 201)) {
|
if (response && (response.statusCode === 200 || response.statusCode === 201)) {
|
||||||
NotifOk({
|
NotifOk({
|
||||||
|
|||||||
@@ -164,7 +164,7 @@ const ListUnit = memo(function ListUnit(props) {
|
|||||||
const handleDelete = async (param) => {
|
const handleDelete = async (param) => {
|
||||||
try {
|
try {
|
||||||
const response = await deleteUnit(param.unit_id);
|
const response = await deleteUnit(param.unit_id);
|
||||||
console.log('deleteUnit response:', response);
|
// console.log('deleteUnit response:', response);
|
||||||
|
|
||||||
if (response.statusCode === 200) {
|
if (response.statusCode === 200) {
|
||||||
NotifAlert({
|
NotifAlert({
|
||||||
|
|||||||
@@ -38,7 +38,14 @@ import {
|
|||||||
SearchOutlined,
|
SearchOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import { useNavigate, Link as RouterLink } from 'react-router-dom';
|
import { useNavigate, Link as RouterLink } from 'react-router-dom';
|
||||||
import { getAllNotification, getNotificationLogByNotificationId } from '../../../api/notification';
|
import {
|
||||||
|
getAllNotification,
|
||||||
|
getNotificationLogByNotificationId,
|
||||||
|
getNotificationDetail,
|
||||||
|
resendChatByUser,
|
||||||
|
resendChatAllUser,
|
||||||
|
searchData,
|
||||||
|
} from '../../../api/notification';
|
||||||
|
|
||||||
const { Text, Paragraph, Link: AntdLink } = Typography;
|
const { Text, Paragraph, Link: AntdLink } = Typography;
|
||||||
|
|
||||||
@@ -60,7 +67,8 @@ const transformNotificationData = (apiData) => {
|
|||||||
}) + ' WIB'
|
}) + ' WIB'
|
||||||
: 'N/A',
|
: 'N/A',
|
||||||
location: item.plant_sub_section_name || item.device_location || 'Location not specified',
|
location: item.plant_sub_section_name || item.device_location || 'Location not specified',
|
||||||
details: item.message_error_issue || 'No details available',
|
details: item.device_name || '-',
|
||||||
|
errId: item.notification_error_id || 0,
|
||||||
link: `/verification-sparepart/${item.notification_error_id}`, // Dummy URL untuk verifikasi spare part
|
link: `/verification-sparepart/${item.notification_error_id}`, // Dummy URL untuk verifikasi spare part
|
||||||
subsection: item.plant_sub_section_name || 'N/A',
|
subsection: item.plant_sub_section_name || 'N/A',
|
||||||
isRead: item.is_read,
|
isRead: item.is_read,
|
||||||
@@ -77,31 +85,6 @@ const transformNotificationData = (apiData) => {
|
|||||||
}));
|
}));
|
||||||
};
|
};
|
||||||
|
|
||||||
// Dummy data untuk user history
|
|
||||||
const userHistoryData = [
|
|
||||||
{
|
|
||||||
id: '1',
|
|
||||||
name: 'John Doe',
|
|
||||||
phone: '081234567890',
|
|
||||||
status: 'Delivered',
|
|
||||||
timestamp: '04-11-2025 11:40 WIB',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '2',
|
|
||||||
name: 'Jane Smith',
|
|
||||||
phone: '087654321098',
|
|
||||||
status: 'Delivered',
|
|
||||||
timestamp: '04-11-2025 11:41 WIB',
|
|
||||||
},
|
|
||||||
{
|
|
||||||
id: '3',
|
|
||||||
name: 'Peter Jones',
|
|
||||||
phone: '082345678901',
|
|
||||||
status: 'Delivered',
|
|
||||||
timestamp: '04-11-2025 11:42 WIB',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
|
|
||||||
const ListNotification = memo(function ListNotification(props) {
|
const ListNotification = memo(function ListNotification(props) {
|
||||||
const [notifications, setNotifications] = useState([]);
|
const [notifications, setNotifications] = useState([]);
|
||||||
const [activeTab, setActiveTab] = useState('all');
|
const [activeTab, setActiveTab] = useState('all');
|
||||||
@@ -113,6 +96,8 @@ const ListNotification = memo(function ListNotification(props) {
|
|||||||
const [selectedNotification, setSelectedNotification] = useState(null);
|
const [selectedNotification, setSelectedNotification] = useState(null);
|
||||||
const [logHistoryData, setLogHistoryData] = useState([]);
|
const [logHistoryData, setLogHistoryData] = useState([]);
|
||||||
const [logLoading, setLogLoading] = useState(false);
|
const [logLoading, setLogLoading] = useState(false);
|
||||||
|
const [userHistoryData, setUserHistoryData] = useState([]);
|
||||||
|
const [userLoading, setUserLoading] = useState(false);
|
||||||
const [pagination, setPagination] = useState({
|
const [pagination, setPagination] = useState({
|
||||||
current_page: 1,
|
current_page: 1,
|
||||||
current_limit: 10,
|
current_limit: 10,
|
||||||
@@ -214,9 +199,9 @@ const ListNotification = memo(function ListNotification(props) {
|
|||||||
content: `Are you sure you want to resend the notification for "${notification.title}"?`,
|
content: `Are you sure you want to resend the notification for "${notification.title}"?`,
|
||||||
okText: 'Resend',
|
okText: 'Resend',
|
||||||
cancelText: 'Cancel',
|
cancelText: 'Cancel',
|
||||||
onOk() {
|
async onOk() {
|
||||||
console.log('Resending notification:', notification.id);
|
console.log('Resending notification:', notification.id);
|
||||||
|
await resendChatAllUser(notification.errId);
|
||||||
message.success(
|
message.success(
|
||||||
`Notification for "${notification.title}" has been resent successfully.`
|
`Notification for "${notification.title}" has been resent successfully.`
|
||||||
);
|
);
|
||||||
@@ -235,13 +220,49 @@ const ListNotification = memo(function ListNotification(props) {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const fetchSearch = async (data) => {
|
||||||
|
setLoading(true);
|
||||||
|
try {
|
||||||
|
const response = await searchData(data);
|
||||||
|
if (response && response.data) {
|
||||||
|
const transformedData = transformNotificationData(response.data);
|
||||||
|
setNotifications(transformedData);
|
||||||
|
|
||||||
|
// Update pagination with API response or calculate from data
|
||||||
|
if (response.paging) {
|
||||||
|
setPagination({
|
||||||
|
current_page: response.paging.current_page || page,
|
||||||
|
current_limit: response.paging.current_limit || limit,
|
||||||
|
total_limit: response.paging.total_limit || transformedData.length,
|
||||||
|
total_page:
|
||||||
|
response.paging.total_page || Math.ceil(transformedData.length / limit),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Fallback: calculate pagination from data
|
||||||
|
const totalItems = transformedData.length;
|
||||||
|
setPagination((prev) => ({
|
||||||
|
...prev,
|
||||||
|
current_page: page,
|
||||||
|
current_limit: limit,
|
||||||
|
total_limit: totalItems,
|
||||||
|
total_page: Math.ceil(totalItems / limit),
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleSearch = () => {
|
const handleSearch = () => {
|
||||||
setSearchTerm(searchValue);
|
fetchSearch(searchValue);
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSearchClear = () => {
|
const handleSearchClear = () => {
|
||||||
setSearchValue('');
|
setSearchValue('');
|
||||||
setSearchTerm('');
|
fetchSearch('');
|
||||||
};
|
};
|
||||||
|
|
||||||
const getUnreadCount = () => notifications.filter((n) => !n.isRead).length;
|
const getUnreadCount = () => notifications.filter((n) => !n.isRead).length;
|
||||||
@@ -290,6 +311,44 @@ const ListNotification = memo(function ListNotification(props) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Fetch user history from API
|
||||||
|
const fetchUserHistory = async (notificationId) => {
|
||||||
|
try {
|
||||||
|
setUserLoading(true);
|
||||||
|
|
||||||
|
const response = await getNotificationDetail(notificationId);
|
||||||
|
|
||||||
|
if (response && response.data && response.data.users) {
|
||||||
|
// Transform API data to component format
|
||||||
|
const transformedUsers = response.data.users.map((user) => ({
|
||||||
|
id: user.notification_error_user_id.toString(),
|
||||||
|
name: user.contact_name,
|
||||||
|
phone: user.contact_phone,
|
||||||
|
status: user.is_send ? 'Delivered' : 'Pending',
|
||||||
|
timestamp: user.updated_at
|
||||||
|
? new Date(user.updated_at)
|
||||||
|
.toLocaleString('id-ID', {
|
||||||
|
day: '2-digit',
|
||||||
|
month: '2-digit',
|
||||||
|
year: 'numeric',
|
||||||
|
hour: '2-digit',
|
||||||
|
minute: '2-digit',
|
||||||
|
})
|
||||||
|
.replace('.', ':') + ' WIB'
|
||||||
|
: 'N/A',
|
||||||
|
}));
|
||||||
|
setUserHistoryData(transformedUsers);
|
||||||
|
} else {
|
||||||
|
setUserHistoryData([]);
|
||||||
|
}
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error fetching user history:', err);
|
||||||
|
setUserHistoryData([]); // Set empty array on error
|
||||||
|
} finally {
|
||||||
|
setUserLoading(false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const tabButtonStyle = (isActive) => ({
|
const tabButtonStyle = (isActive) => ({
|
||||||
padding: '12px 16px',
|
padding: '12px 16px',
|
||||||
border: 'none',
|
border: 'none',
|
||||||
@@ -362,7 +421,7 @@ const ListNotification = memo(function ListNotification(props) {
|
|||||||
<Text strong>{notification.title}</Text>
|
<Text strong>{notification.title}</Text>
|
||||||
<div style={{ marginTop: '4px' }}>
|
<div style={{ marginTop: '4px' }}>
|
||||||
<Text style={{ color }}>
|
<Text style={{ color }}>
|
||||||
{notification.issue}
|
Error Code {notification.issue}
|
||||||
</Text>
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -379,7 +438,7 @@ const ListNotification = memo(function ListNotification(props) {
|
|||||||
</div>
|
</div>
|
||||||
</Col>
|
</Col>
|
||||||
<Col flex="auto">
|
<Col flex="auto">
|
||||||
<div
|
{/* <div
|
||||||
style={{
|
style={{
|
||||||
display: 'flex',
|
display: 'flex',
|
||||||
gap: '8px',
|
gap: '8px',
|
||||||
@@ -402,12 +461,18 @@ const ListNotification = memo(function ListNotification(props) {
|
|||||||
>
|
>
|
||||||
{notification.details}
|
{notification.details}
|
||||||
</Paragraph>
|
</Paragraph>
|
||||||
</div>
|
</div> */}
|
||||||
<Space
|
<Space
|
||||||
direction="vertical"
|
direction="vertical"
|
||||||
size={4}
|
size={4}
|
||||||
style={{ fontSize: '13px', color: '#8c8c8c' }}
|
style={{ fontSize: '13px', color: '#8c8c8c' }}
|
||||||
>
|
>
|
||||||
|
<Space>
|
||||||
|
<MobileOutlined />
|
||||||
|
<Text type="secondary">
|
||||||
|
{notification.details}
|
||||||
|
</Text>
|
||||||
|
</Space>
|
||||||
<Space>
|
<Space>
|
||||||
<ClockCircleOutlined />
|
<ClockCircleOutlined />
|
||||||
<Text type="secondary">
|
<Text type="secondary">
|
||||||
@@ -421,17 +486,10 @@ const ListNotification = memo(function ListNotification(props) {
|
|||||||
</Text>
|
</Text>
|
||||||
</Space>
|
</Space>
|
||||||
<Space>
|
<Space>
|
||||||
<LinkOutlined />
|
|
||||||
<AntdLink
|
|
||||||
href={notification.link}
|
|
||||||
target="_blank"
|
|
||||||
>
|
|
||||||
{notification.link}
|
|
||||||
</AntdLink>
|
|
||||||
<Button
|
<Button
|
||||||
type="link"
|
type="link"
|
||||||
icon={<SendOutlined />}
|
icon={<SendOutlined />}
|
||||||
style={{ paddingLeft: '8px' }}
|
style={{ paddingLeft: '0px' }}
|
||||||
onClick={(e) => {
|
onClick={(e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
handleResend(notification);
|
handleResend(notification);
|
||||||
@@ -467,8 +525,18 @@ const ListNotification = memo(function ListNotification(props) {
|
|||||||
border: '1px solid #1890ff',
|
border: '1px solid #1890ff',
|
||||||
borderRadius: '4px',
|
borderRadius: '4px',
|
||||||
}}
|
}}
|
||||||
onClick={(e) => {
|
onClick={async (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
|
||||||
|
setSelectedNotification(notification);
|
||||||
|
|
||||||
|
// Extract notification ID from the notification object
|
||||||
|
const notificationId =
|
||||||
|
notification.id.split('-')[1];
|
||||||
|
|
||||||
|
// Fetch user history for the selected notification
|
||||||
|
await fetchUserHistory(notificationId);
|
||||||
|
|
||||||
setModalContent('user');
|
setModalContent('user');
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
@@ -535,37 +603,67 @@ const ListNotification = memo(function ListNotification(props) {
|
|||||||
|
|
||||||
const renderUserHistory = () => (
|
const renderUserHistory = () => (
|
||||||
<>
|
<>
|
||||||
<Space direction="vertical" size="middle" style={{ display: 'flex' }}>
|
{userLoading ? (
|
||||||
{userHistoryData.map((user) => (
|
<div style={{ textAlign: 'center', padding: '24px' }}>
|
||||||
<Card key={user.id} style={{ borderColor: '#91d5ff' }}>
|
<Spin size="large" />
|
||||||
<Row align="middle" justify="space-between">
|
</div>
|
||||||
<Col>
|
) : (
|
||||||
<Space align="center">
|
<Space direction="vertical" size="middle" style={{ display: 'flex' }}>
|
||||||
<Text strong>{user.name}</Text>
|
{userHistoryData.map((user) => (
|
||||||
<Text>|</Text>
|
<Card key={user.id} style={{ borderColor: '#91d5ff' }}>
|
||||||
<Text>
|
<Row align="middle" justify="space-between">
|
||||||
<MobileOutlined /> {user.phone}
|
<Col>
|
||||||
</Text>
|
<Space align="center">
|
||||||
<Text>|</Text>
|
<Text strong>{user.name}</Text>
|
||||||
<Badge status="success" text={user.status} />
|
<Text>|</Text>
|
||||||
</Space>
|
<Text>
|
||||||
<Divider style={{ margin: '8px 0' }} />
|
<MobileOutlined /> {user.phone}
|
||||||
<Space align="center">
|
</Text>
|
||||||
<CheckCircleFilled style={{ color: '#52c41a' }} />
|
<Text>|</Text>
|
||||||
<Text type="secondary">
|
<Badge
|
||||||
Success Delivered at {user.timestamp}
|
status={
|
||||||
</Text>
|
user.status === 'Delivered' ? 'success' : 'default'
|
||||||
</Space>
|
}
|
||||||
</Col>
|
text={user.status}
|
||||||
<Col>
|
/>
|
||||||
<Button type="primary" ghost icon={<SendOutlined />}>
|
</Space>
|
||||||
Resend
|
<Divider style={{ margin: '8px 0' }} />
|
||||||
</Button>
|
<Space align="center">
|
||||||
</Col>
|
{user.status === 'Delivered' ? (
|
||||||
</Row>
|
<CheckCircleFilled style={{ color: '#52c41a' }} />
|
||||||
</Card>
|
) : (
|
||||||
))}
|
<ClockCircleOutlined style={{ color: '#faad14' }} />
|
||||||
</Space>
|
)}
|
||||||
|
<Text type="secondary">
|
||||||
|
{user.status === 'Delivered'
|
||||||
|
? 'Success Delivered at'
|
||||||
|
: 'Status '}{' '}
|
||||||
|
{user.timestamp}
|
||||||
|
</Text>
|
||||||
|
</Space>
|
||||||
|
</Col>
|
||||||
|
<Col>
|
||||||
|
<Button
|
||||||
|
type="primary"
|
||||||
|
ghost
|
||||||
|
icon={<SendOutlined />}
|
||||||
|
onClick={async () => {
|
||||||
|
await resendChatByUser(user.id, user.phone);
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Resend
|
||||||
|
</Button>
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
|
</Card>
|
||||||
|
))}
|
||||||
|
{userHistoryData.length === 0 && (
|
||||||
|
<div style={{ textAlign: 'center', padding: '24px', color: '#8c8c8c' }}>
|
||||||
|
No user history available
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Space>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -580,97 +678,114 @@ const ListNotification = memo(function ListNotification(props) {
|
|||||||
Tidak ada log history
|
Tidak ada log history
|
||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<div style={{ padding: '0 16px', position: 'relative' }}>
|
<div
|
||||||
{/* Garis vertikal yang menyambung */}
|
style={{
|
||||||
<div
|
height: '400px',
|
||||||
style={{
|
overflowY: 'auto',
|
||||||
position: 'absolute',
|
padding: '0 16px',
|
||||||
top: '7px',
|
position: 'relative',
|
||||||
left: '23px',
|
border: '1px solid #f0f0f0',
|
||||||
bottom: '7px',
|
borderRadius: '4px',
|
||||||
width: '2px',
|
}}
|
||||||
backgroundColor: '#91d5ff',
|
>
|
||||||
zIndex: 0,
|
<div style={{ position: 'relative' }}>
|
||||||
}}
|
{/* Garis vertikal yang menyambung */}
|
||||||
></div>
|
<div
|
||||||
|
style={{
|
||||||
|
position: 'absolute',
|
||||||
|
top: '7px',
|
||||||
|
left: '23px',
|
||||||
|
bottom: '7px',
|
||||||
|
width: '2px',
|
||||||
|
backgroundColor: '#91d5ff',
|
||||||
|
zIndex: 0,
|
||||||
|
}}
|
||||||
|
></div>
|
||||||
|
|
||||||
{logHistoryData.map((log, index) => (
|
{logHistoryData.map((log, index) => (
|
||||||
<Row
|
<Row
|
||||||
key={log.id}
|
key={log.id}
|
||||||
wrap={false}
|
wrap={false}
|
||||||
style={{ marginBottom: '16px', position: 'relative', zIndex: 1 }}
|
style={{ marginBottom: '16px', position: 'relative', zIndex: 1 }}
|
||||||
>
|
|
||||||
{/* Kolom Kiri: Branch/Timeline */}
|
|
||||||
<Col
|
|
||||||
style={{
|
|
||||||
position: 'relative',
|
|
||||||
display: 'flex',
|
|
||||||
flexDirection: 'column',
|
|
||||||
alignItems: 'center',
|
|
||||||
marginRight: '16px',
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
<div
|
{/* Kolom Kiri: Branch/Timeline */}
|
||||||
|
<Col
|
||||||
style={{
|
style={{
|
||||||
width: '14px',
|
position: 'relative',
|
||||||
height: '14px',
|
display: 'flex',
|
||||||
backgroundColor: '#fff',
|
flexDirection: 'column',
|
||||||
border: '3px solid #1890ff',
|
alignItems: 'center',
|
||||||
borderRadius: '50%',
|
marginRight: '16px',
|
||||||
zIndex: 1,
|
|
||||||
flexShrink: 0,
|
|
||||||
}}
|
}}
|
||||||
></div>
|
>
|
||||||
</Col>
|
<div
|
||||||
|
style={{
|
||||||
|
width: '14px',
|
||||||
|
height: '14px',
|
||||||
|
backgroundColor: '#fff',
|
||||||
|
border: '3px solid #1890ff',
|
||||||
|
borderRadius: '50%',
|
||||||
|
zIndex: 1,
|
||||||
|
flexShrink: 0,
|
||||||
|
}}
|
||||||
|
></div>
|
||||||
|
</Col>
|
||||||
|
|
||||||
{/* Kolom Kanan: Card */}
|
{/* Kolom Kanan: Card */}
|
||||||
<Col flex="auto">
|
<Col flex="auto">
|
||||||
<Card size="small" style={{ borderColor: '#91d5ff' }}>
|
<Card size="small" style={{ borderColor: '#91d5ff' }}>
|
||||||
<Row gutter={[16, 8]} align="middle">
|
<Row gutter={[16, 8]} align="top">
|
||||||
<Col xs={24} md={12}>
|
<Col xs={24} md={10}>
|
||||||
<Space direction="vertical" size={4}>
|
<Space direction="vertical" size={4}>
|
||||||
<Space>
|
<Space>
|
||||||
<ClockCircleOutlined />
|
<ClockCircleOutlined />
|
||||||
<Text
|
<Text
|
||||||
type="secondary"
|
type="secondary"
|
||||||
style={{ fontSize: '12px' }}
|
style={{ fontSize: '12px' }}
|
||||||
>
|
>
|
||||||
Added at {log.timestamp}
|
Added at {log.timestamp}
|
||||||
</Text>
|
</Text>
|
||||||
|
</Space>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<Text strong>
|
||||||
|
{log.addedBy.name}
|
||||||
|
</Text>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<span
|
||||||
|
style={{
|
||||||
|
border: '1px solid #52c41a',
|
||||||
|
color: '#52c41a',
|
||||||
|
padding: '2px 6px',
|
||||||
|
borderRadius: '4px',
|
||||||
|
fontSize: '12px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<MobileOutlined /> {log.addedBy.phone}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
</Space>
|
</Space>
|
||||||
<div>
|
</Col>
|
||||||
<Text strong>Added by: {log.addedBy.name}</Text>
|
<Col xs={24} md={14}>
|
||||||
<span
|
<Text strong>Description:</Text>
|
||||||
style={{
|
<Paragraph
|
||||||
marginLeft: '8px',
|
style={{
|
||||||
border: '1px solid #52c41a',
|
color: '#595959',
|
||||||
color: '#52c41a',
|
margin: 0,
|
||||||
padding: '2px 6px',
|
fontSize: '13px',
|
||||||
borderRadius: '4px',
|
}}
|
||||||
fontSize: '12px',
|
>
|
||||||
}}
|
{log.description}
|
||||||
>
|
</Paragraph>
|
||||||
<MobileOutlined /> {log.addedBy.phone}
|
</Col>
|
||||||
</span>
|
</Row>
|
||||||
</div>
|
</Card>
|
||||||
</Space>
|
</Col>
|
||||||
</Col>
|
</Row>
|
||||||
<Col xs={24} md={12}>
|
))}
|
||||||
<Paragraph
|
</div>
|
||||||
style={{
|
|
||||||
color: '#595959',
|
|
||||||
margin: 0,
|
|
||||||
fontSize: '13px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{log.description}
|
|
||||||
</Paragraph>
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
</Card>
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
))}
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
@@ -1342,7 +1457,7 @@ const ListNotification = memo(function ListNotification(props) {
|
|||||||
</div>
|
</div>
|
||||||
) : (
|
) : (
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>
|
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||||
{modalContent === 'user' && 'User History Notification'}
|
{modalContent === 'user' && 'History User Notification'}
|
||||||
{modalContent === 'log' && 'Log History Notification'}
|
{modalContent === 'log' && 'Log History Notification'}
|
||||||
</Typography.Title>
|
</Typography.Title>
|
||||||
)}
|
)}
|
||||||
|
|||||||
@@ -1,6 +1,12 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Modal, Typography, Card, Row, Col, Avatar, Tag, Button, Space } from 'antd';
|
import { Modal, Typography, Card, Row, Col, Avatar, Tag, Button, Space } from 'antd';
|
||||||
import { UserOutlined, PhoneOutlined, CheckCircleOutlined, SyncOutlined, SendOutlined } from '@ant-design/icons';
|
import {
|
||||||
|
UserOutlined,
|
||||||
|
PhoneOutlined,
|
||||||
|
CheckCircleOutlined,
|
||||||
|
SyncOutlined,
|
||||||
|
SendOutlined,
|
||||||
|
} from '@ant-design/icons';
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
|
|
||||||
@@ -41,9 +47,17 @@ const UserHistoryModal = ({ visible, onCancel, notificationData }) => {
|
|||||||
const getStatusTag = (status) => {
|
const getStatusTag = (status) => {
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case 'delivered':
|
case 'delivered':
|
||||||
return <Tag icon={<CheckCircleOutlined />} color="success">Delivered</Tag>;
|
return (
|
||||||
|
<Tag icon={<CheckCircleOutlined />} color="success">
|
||||||
|
Delivered
|
||||||
|
</Tag>
|
||||||
|
);
|
||||||
case 'sent':
|
case 'sent':
|
||||||
return <Tag icon={<SyncOutlined spin />} color="processing">Sent</Tag>;
|
return (
|
||||||
|
<Tag icon={<SyncOutlined spin />} color="processing">
|
||||||
|
Sent
|
||||||
|
</Tag>
|
||||||
|
);
|
||||||
case 'failed':
|
case 'failed':
|
||||||
return <Tag color="error">Failed</Tag>;
|
return <Tag color="error">Failed</Tag>;
|
||||||
default:
|
default:
|
||||||
@@ -55,7 +69,7 @@ const UserHistoryModal = ({ visible, onCancel, notificationData }) => {
|
|||||||
<Modal
|
<Modal
|
||||||
title={
|
title={
|
||||||
<Text strong style={{ fontSize: '18px' }}>
|
<Text strong style={{ fontSize: '18px' }}>
|
||||||
User History Notification
|
History User Notification
|
||||||
</Text>
|
</Text>
|
||||||
}
|
}
|
||||||
open={visible}
|
open={visible}
|
||||||
@@ -78,7 +92,13 @@ const UserHistoryModal = ({ visible, onCancel, notificationData }) => {
|
|||||||
<Avatar size="large" icon={<UserOutlined />} />
|
<Avatar size="large" icon={<UserOutlined />} />
|
||||||
<div>
|
<div>
|
||||||
<Text strong>{user.name}</Text>
|
<Text strong>{user.name}</Text>
|
||||||
<div style={{ display: 'flex', alignItems: 'center', gap: '4px' }}>
|
<div
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
gap: '4px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
<PhoneOutlined style={{ color: '#8c8c8c' }} />
|
<PhoneOutlined style={{ color: '#8c8c8c' }} />
|
||||||
<Text type="secondary">{user.phone}</Text>
|
<Text type="secondary">{user.phone}</Text>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,14 +1,37 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Button, Row, Col, Card, Badge, Typography, Space, Divider } from 'antd';
|
import { Button, Row, Col, Card, Badge, Typography, Space, Divider } from 'antd';
|
||||||
import { SendOutlined, MobileOutlined, CheckCircleFilled, ArrowLeftOutlined } from '@ant-design/icons';
|
import {
|
||||||
|
SendOutlined,
|
||||||
|
MobileOutlined,
|
||||||
|
CheckCircleFilled,
|
||||||
|
ArrowLeftOutlined,
|
||||||
|
} from '@ant-design/icons';
|
||||||
|
|
||||||
const { Text } = Typography;
|
const { Text } = Typography;
|
||||||
|
|
||||||
// Dummy data for user history
|
// Dummy data for user history
|
||||||
const userHistoryData = [
|
const userHistoryData = [
|
||||||
{ id: 1, name: 'John Doe', phone: '081234567890', status: 'Delivered', timestamp: '04-11-2025 11:40 WIB' },
|
{
|
||||||
{ id: 2, name: 'Jane Smith', phone: '087654321098', status: 'Delivered', timestamp: '04-11-2025 11:41 WIB' },
|
id: 1,
|
||||||
{ id: 3, name: 'Peter Jones', phone: '082345678901', status: 'Delivered', timestamp: '04-11-2025 11:42 WIB' },
|
name: 'John Doe',
|
||||||
|
phone: '081234567890',
|
||||||
|
status: 'Delivered',
|
||||||
|
timestamp: '04-11-2025 11:40 WIB',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 2,
|
||||||
|
name: 'Jane Smith',
|
||||||
|
phone: '087654321098',
|
||||||
|
status: 'Delivered',
|
||||||
|
timestamp: '04-11-2025 11:41 WIB',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: 3,
|
||||||
|
name: 'Peter Jones',
|
||||||
|
phone: '082345678901',
|
||||||
|
status: 'Delivered',
|
||||||
|
timestamp: '04-11-2025 11:42 WIB',
|
||||||
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
const UserHistory = ({ notification, onBack }) => {
|
const UserHistory = ({ notification, onBack }) => {
|
||||||
@@ -18,7 +41,9 @@ const UserHistory = ({ notification, onBack }) => {
|
|||||||
<Col>
|
<Col>
|
||||||
<Space align="center">
|
<Space align="center">
|
||||||
<Button type="text" icon={<ArrowLeftOutlined />} onClick={onBack} />
|
<Button type="text" icon={<ArrowLeftOutlined />} onClick={onBack} />
|
||||||
<Typography.Title level={4} style={{ margin: 0 }}>User History Notification</Typography.Title>
|
<Typography.Title level={4} style={{ margin: 0 }}>
|
||||||
|
History User Notification
|
||||||
|
</Typography.Title>
|
||||||
</Space>
|
</Space>
|
||||||
<Text type="secondary" style={{ marginLeft: '40px' }}>
|
<Text type="secondary" style={{ marginLeft: '40px' }}>
|
||||||
{notification.title} - {notification.issue}
|
{notification.title} - {notification.issue}
|
||||||
@@ -27,25 +52,34 @@ const UserHistory = ({ notification, onBack }) => {
|
|||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
<Space direction="vertical" size="middle" style={{ display: 'flex' }}>
|
<Space direction="vertical" size="middle" style={{ display: 'flex' }}>
|
||||||
{userHistoryData.map(user => (
|
{userHistoryData.map((user) => (
|
||||||
<Card key={user.id} style={{ backgroundColor: '#e6f7ff', borderColor: '#91d5ff' }}>
|
<Card
|
||||||
|
key={user.id}
|
||||||
|
style={{ backgroundColor: '#e6f7ff', borderColor: '#91d5ff' }}
|
||||||
|
>
|
||||||
<Row align="middle" justify="space-between">
|
<Row align="middle" justify="space-between">
|
||||||
<Col>
|
<Col>
|
||||||
<Space align="center">
|
<Space align="center">
|
||||||
<Text strong>{user.name}</Text>
|
<Text strong>{user.name}</Text>
|
||||||
<Text>|</Text>
|
<Text>|</Text>
|
||||||
<Text><MobileOutlined /> {user.phone}</Text>
|
<Text>
|
||||||
|
<MobileOutlined /> {user.phone}
|
||||||
|
</Text>
|
||||||
<Text>|</Text>
|
<Text>|</Text>
|
||||||
<Badge status="success" text={user.status} />
|
<Badge status="success" text={user.status} />
|
||||||
</Space>
|
</Space>
|
||||||
<Divider style={{ margin: '8px 0' }} />
|
<Divider style={{ margin: '8px 0' }} />
|
||||||
<Space align="center">
|
<Space align="center">
|
||||||
<CheckCircleFilled style={{ color: '#52c41a' }} />
|
<CheckCircleFilled style={{ color: '#52c41a' }} />
|
||||||
<Text type="secondary">Success Delivered at {user.timestamp}</Text>
|
<Text type="secondary">
|
||||||
|
Success Delivered at {user.timestamp}
|
||||||
|
</Text>
|
||||||
</Space>
|
</Space>
|
||||||
</Col>
|
</Col>
|
||||||
<Col>
|
<Col>
|
||||||
<Button type="primary" ghost icon={<SendOutlined />}>Resend</Button>
|
<Button type="primary" ghost icon={<SendOutlined />}>
|
||||||
|
Resend
|
||||||
|
</Button>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import {
|
|||||||
message,
|
message,
|
||||||
Avatar,
|
Avatar,
|
||||||
Tag,
|
Tag,
|
||||||
|
Badge,
|
||||||
|
Divider,
|
||||||
} from 'antd';
|
} from 'antd';
|
||||||
import {
|
import {
|
||||||
ArrowLeftOutlined,
|
ArrowLeftOutlined,
|
||||||
@@ -33,11 +35,16 @@ import {
|
|||||||
CheckCircleOutlined,
|
CheckCircleOutlined,
|
||||||
SyncOutlined,
|
SyncOutlined,
|
||||||
SendOutlined,
|
SendOutlined,
|
||||||
|
MobileOutlined,
|
||||||
|
ClockCircleOutlined,
|
||||||
} from '@ant-design/icons';
|
} from '@ant-design/icons';
|
||||||
import {
|
import {
|
||||||
getNotificationDetail,
|
getNotificationDetail,
|
||||||
createNotificationLog,
|
createNotificationLog,
|
||||||
getNotificationLogByNotificationId,
|
getNotificationLogByNotificationId,
|
||||||
|
updateIsRead,
|
||||||
|
resendNotificationToUser,
|
||||||
|
resendChatByUser,
|
||||||
} from '../../api/notification';
|
} from '../../api/notification';
|
||||||
|
|
||||||
const { Content } = Layout;
|
const { Content } = Layout;
|
||||||
@@ -94,38 +101,32 @@ const transformNotificationData = (apiData) => {
|
|||||||
device_location: apiData.device_location,
|
device_location: apiData.device_location,
|
||||||
brand_name: apiData.brand_name,
|
brand_name: apiData.brand_name,
|
||||||
},
|
},
|
||||||
|
users: apiData.users || [],
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
// Dummy data baru untuk user history
|
// Function to get actual users from notification data
|
||||||
const getDummyUsers = (notification) => {
|
const getUsersFromNotification = (notification) => {
|
||||||
if (!notification) return [];
|
if (!notification || !notification.users) return [];
|
||||||
return [
|
|
||||||
{
|
return notification.users.map((user) => ({
|
||||||
id: '1',
|
id: user.notification_error_user_id.toString(),
|
||||||
name: 'John Doe',
|
name: user.contact_name,
|
||||||
phone: '081234567890',
|
phone: user.contact_phone,
|
||||||
status: 'delivered',
|
status: user.is_send ? 'Delivered' : 'Pending',
|
||||||
},
|
loading: user.loading || false,
|
||||||
{
|
timestamp: user.updated_at
|
||||||
id: '2',
|
? new Date(user.updated_at)
|
||||||
name: 'Jane Smith',
|
.toLocaleString('id-ID', {
|
||||||
phone: '082345678901',
|
day: '2-digit',
|
||||||
status: 'sent',
|
month: '2-digit',
|
||||||
},
|
year: 'numeric',
|
||||||
{
|
hour: '2-digit',
|
||||||
id: '3',
|
minute: '2-digit',
|
||||||
name: 'Bob Johnson',
|
})
|
||||||
phone: '083456789012',
|
.replace('.', ':') + ' WIB'
|
||||||
status: 'failed',
|
: 'N/A',
|
||||||
},
|
}));
|
||||||
{
|
|
||||||
id: '4',
|
|
||||||
name: 'Alice Brown',
|
|
||||||
phone: '084567890123',
|
|
||||||
status: 'delivered',
|
|
||||||
},
|
|
||||||
];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const getStatusTag = (status) => {
|
const getStatusTag = (status) => {
|
||||||
@@ -257,6 +258,9 @@ const NotificationDetailTab = (props) => {
|
|||||||
|
|
||||||
// Fetch log history
|
// Fetch log history
|
||||||
fetchLogHistory(notificationId);
|
fetchLogHistory(notificationId);
|
||||||
|
|
||||||
|
// Fetch using the actual API
|
||||||
|
const resUpdate = await updateIsRead(notificationId);
|
||||||
} else {
|
} else {
|
||||||
throw new Error('Notification not found');
|
throw new Error('Notification not found');
|
||||||
}
|
}
|
||||||
@@ -390,7 +394,7 @@ const NotificationDetailTab = (props) => {
|
|||||||
<Text>{notification.title}</Text>
|
<Text>{notification.title}</Text>
|
||||||
<div style={{ marginTop: '2px' }}>
|
<div style={{ marginTop: '2px' }}>
|
||||||
<Text strong style={{ fontSize: '16px' }}>
|
<Text strong style={{ fontSize: '16px' }}>
|
||||||
{notification.issue}
|
Error Code {notification.issue}
|
||||||
</Text>
|
</Text>
|
||||||
</div>
|
</div>
|
||||||
</Col>
|
</Col>
|
||||||
@@ -469,7 +473,7 @@ const NotificationDetailTab = (props) => {
|
|||||||
size={2}
|
size={2}
|
||||||
style={{ width: '100%' }}
|
style={{ width: '100%' }}
|
||||||
>
|
>
|
||||||
{getDummyUsers(notification).map((user) => (
|
{getUsersFromNotification(notification).map((user) => (
|
||||||
<Card
|
<Card
|
||||||
key={user.id}
|
key={user.id}
|
||||||
size="small"
|
size="small"
|
||||||
@@ -478,48 +482,56 @@ const NotificationDetailTab = (props) => {
|
|||||||
<Row align="middle" justify="space-between">
|
<Row align="middle" justify="space-between">
|
||||||
<Col>
|
<Col>
|
||||||
<Space align="center">
|
<Space align="center">
|
||||||
<Avatar
|
<Text strong>{user.name}</Text>
|
||||||
size="large"
|
<Text>|</Text>
|
||||||
icon={<UserOutlined />}
|
<Text>
|
||||||
|
<MobileOutlined /> {user.phone}
|
||||||
|
</Text>
|
||||||
|
<Text>|</Text>
|
||||||
|
<Badge
|
||||||
|
status={
|
||||||
|
user.status === 'Delivered'
|
||||||
|
? 'success'
|
||||||
|
: 'default'
|
||||||
|
}
|
||||||
|
text={user.status}
|
||||||
/>
|
/>
|
||||||
<div>
|
</Space>
|
||||||
<Text strong>{user.name}</Text>
|
<Divider style={{ margin: '8px 0' }} />
|
||||||
<div
|
<Space align="center">
|
||||||
style={{
|
{user.status === 'Delivered' ? (
|
||||||
display: 'flex',
|
<CheckCircleFilled
|
||||||
alignItems: 'center',
|
style={{ color: '#52c41a' }}
|
||||||
gap: '4px',
|
/>
|
||||||
}}
|
) : (
|
||||||
>
|
<ClockCircleOutlined
|
||||||
<PhoneOutlined
|
style={{ color: '#faad14' }}
|
||||||
style={{
|
/>
|
||||||
color: '#8c8c8c',
|
)}
|
||||||
}}
|
<Text type="secondary">
|
||||||
/>
|
{user.status === 'Delivered'
|
||||||
<Text type="secondary">
|
? 'Success Delivered at'
|
||||||
{user.phone}
|
: 'Status '}{' '}
|
||||||
</Text>
|
{user.timestamp}
|
||||||
</div>
|
</Text>
|
||||||
</div>
|
|
||||||
</Space>
|
</Space>
|
||||||
</Col>
|
</Col>
|
||||||
<Col>
|
<Col>
|
||||||
<Space align="center" size="large">
|
<Col>
|
||||||
{getStatusTag(user.status)}
|
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
|
ghost
|
||||||
icon={<SendOutlined />}
|
icon={<SendOutlined />}
|
||||||
size="small"
|
onClick={async () => {
|
||||||
onClick={(e) => {
|
await resendChatByUser(
|
||||||
e.stopPropagation();
|
user.id,
|
||||||
console.log(
|
user.phone
|
||||||
`Resend to ${user.name}`
|
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Resend
|
Resend
|
||||||
</Button>
|
</Button>
|
||||||
</Space>
|
</Col>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</Card>
|
</Card>
|
||||||
@@ -530,393 +542,407 @@ const NotificationDetailTab = (props) => {
|
|||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
|
|
||||||
<Row gutter={[8, 8]} style={{ marginBottom: 'px' }}>
|
<Row gutter={[8, 8]}>
|
||||||
<Col xs={24} md={8}>
|
<Col xs={24} md={8}>
|
||||||
<Card
|
<div>
|
||||||
hoverable
|
<Card
|
||||||
bodyStyle={{ padding: '12px', textAlign: 'center' }}
|
hoverable
|
||||||
>
|
bodyStyle={{ padding: '12px'}}
|
||||||
<Space>
|
|
||||||
<BookOutlined
|
|
||||||
style={{ fontSize: '16px', color: '#1890ff' }}
|
|
||||||
/>
|
|
||||||
<Text strong style={{ fontSize: '16px', color: '#262626' }}>
|
|
||||||
Handling Guideline
|
|
||||||
</Text>
|
|
||||||
</Space>
|
|
||||||
</Card>
|
|
||||||
</Col>
|
|
||||||
<Col xs={24} md={8}>
|
|
||||||
<Card
|
|
||||||
hoverable
|
|
||||||
bodyStyle={{ padding: '12px', textAlign: 'center' }}
|
|
||||||
>
|
|
||||||
<Space>
|
|
||||||
<ToolOutlined
|
|
||||||
style={{ fontSize: '16px', color: '#1890ff' }}
|
|
||||||
/>
|
|
||||||
<Text strong style={{ fontSize: '16px', color: '#262626' }}>
|
|
||||||
Spare Part
|
|
||||||
</Text>
|
|
||||||
</Space>
|
|
||||||
</Card>
|
|
||||||
</Col>
|
|
||||||
<Col xs={24} md={8}>
|
|
||||||
<Card bodyStyle={{ padding: '12px', textAlign: 'center' }}>
|
|
||||||
<Space>
|
|
||||||
<HistoryOutlined
|
|
||||||
style={{ fontSize: '16px', color: '#1890ff' }}
|
|
||||||
/>
|
|
||||||
<Text strong style={{ fontSize: '16px', color: '#262626' }}>
|
|
||||||
Log Activity
|
|
||||||
</Text>
|
|
||||||
</Space>
|
|
||||||
</Card>
|
|
||||||
</Col>
|
|
||||||
</Row>
|
|
||||||
|
|
||||||
<Row gutter={[8, 8]} style={{ marginTop: '-12px' }}>
|
|
||||||
<Col xs={24} md={8}>
|
|
||||||
<Card
|
|
||||||
size="small"
|
|
||||||
title="Guideline Documents"
|
|
||||||
style={{ height: '100%' }}
|
|
||||||
>
|
|
||||||
<Space
|
|
||||||
direction="vertical"
|
|
||||||
size="small"
|
|
||||||
style={{ width: '100%' }}
|
|
||||||
>
|
>
|
||||||
{notification.error_code?.solution &&
|
<Space>
|
||||||
notification.error_code.solution.length > 0 ? (
|
<BookOutlined
|
||||||
<>
|
style={{ fontSize: '16px', color: '#1890ff' }}
|
||||||
{notification.error_code.solution
|
/>
|
||||||
.filter((sol) => sol.is_active) // Hanya tampilkan solusi yang aktif
|
<Text
|
||||||
.map((sol, index) => (
|
strong
|
||||||
<div
|
style={{ fontSize: '16px', color: '#262626' }}
|
||||||
key={
|
>
|
||||||
sol.brand_code_solution_id || index
|
Handling Guideline
|
||||||
}
|
</Text>
|
||||||
>
|
</Space>
|
||||||
{sol.path_document ? (
|
|
||||||
<Card
|
<Space
|
||||||
size="small"
|
direction="vertical"
|
||||||
bodyStyle={{
|
size="small"
|
||||||
padding: '8px 12px',
|
style={{ width: '100%' }}
|
||||||
marginBottom: '4px',
|
>
|
||||||
}}
|
{notification.error_code?.solution &&
|
||||||
hoverable
|
notification.error_code.solution.length > 0 ? (
|
||||||
extra={
|
<>
|
||||||
<Text
|
{notification.error_code.solution
|
||||||
type="secondary"
|
.filter((sol) => sol.is_active) // Hanya tampilkan solusi yang aktif
|
||||||
style={{
|
.map((sol, index) => (
|
||||||
fontSize: '10px',
|
<div
|
||||||
}}
|
key={
|
||||||
>
|
sol.brand_code_solution_id ||
|
||||||
PDF
|
index
|
||||||
</Text>
|
}
|
||||||
}
|
>
|
||||||
>
|
{sol.path_document ? (
|
||||||
<div
|
<Card
|
||||||
style={{
|
size="small"
|
||||||
display: 'flex',
|
bodyStyle={{
|
||||||
justifyContent:
|
padding: '8px 12px',
|
||||||
'space-between',
|
marginBottom: '4px',
|
||||||
alignItems: 'center',
|
|
||||||
}}
|
}}
|
||||||
>
|
hoverable
|
||||||
<div>
|
extra={
|
||||||
<Text
|
<Text
|
||||||
|
type="secondary"
|
||||||
style={{
|
style={{
|
||||||
fontSize:
|
fontSize:
|
||||||
'12px',
|
'10px',
|
||||||
color: '#262626',
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<FilePdfOutlined
|
PDF
|
||||||
style={{
|
|
||||||
marginRight:
|
|
||||||
'8px',
|
|
||||||
}}
|
|
||||||
/>{' '}
|
|
||||||
{sol.file_upload_name ||
|
|
||||||
'Solution Document.pdf'}
|
|
||||||
</Text>
|
</Text>
|
||||||
<Link
|
}
|
||||||
href={sol.path_document.replace(
|
>
|
||||||
'/detail-notification/pdf/',
|
|
||||||
'/notification-detail/pdf/'
|
|
||||||
)}
|
|
||||||
target="_blank"
|
|
||||||
style={{
|
|
||||||
fontSize:
|
|
||||||
'12px',
|
|
||||||
display:
|
|
||||||
'block',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
lihat disini
|
|
||||||
</Link>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</Card>
|
|
||||||
) : null}
|
|
||||||
{sol.type_solution === 'text' &&
|
|
||||||
sol.text_solution ? (
|
|
||||||
<Card
|
|
||||||
size="small"
|
|
||||||
bodyStyle={{
|
|
||||||
padding: '8px 12px',
|
|
||||||
marginBottom: '4px',
|
|
||||||
}}
|
|
||||||
extra={
|
|
||||||
<Text
|
|
||||||
type="secondary"
|
|
||||||
style={{
|
|
||||||
fontSize: '10px',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{sol.type_solution.toUpperCase()}
|
|
||||||
</Text>
|
|
||||||
}
|
|
||||||
>
|
|
||||||
<div>
|
|
||||||
<Text strong>
|
|
||||||
{sol.solution_name}:
|
|
||||||
</Text>
|
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
marginTop: '4px',
|
display: 'flex',
|
||||||
|
justifyContent:
|
||||||
|
'space-between',
|
||||||
|
alignItems:
|
||||||
|
'center',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{sol.text_solution}
|
<div>
|
||||||
|
<Text
|
||||||
|
style={{
|
||||||
|
fontSize:
|
||||||
|
'12px',
|
||||||
|
color: '#262626',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<FilePdfOutlined
|
||||||
|
style={{
|
||||||
|
marginRight:
|
||||||
|
'8px',
|
||||||
|
}}
|
||||||
|
/>{' '}
|
||||||
|
{sol.file_upload_name ||
|
||||||
|
'Solution Document.pdf'}
|
||||||
|
</Text>
|
||||||
|
<Link
|
||||||
|
href={sol.path_document.replace(
|
||||||
|
'/detail-notification/pdf/',
|
||||||
|
'/notification-detail/pdf/'
|
||||||
|
)}
|
||||||
|
target="_blank"
|
||||||
|
style={{
|
||||||
|
fontSize:
|
||||||
|
'12px',
|
||||||
|
display:
|
||||||
|
'block',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
lihat disini
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Card>
|
||||||
</Card>
|
) : null}
|
||||||
) : null}
|
{sol.type_solution === 'text' &&
|
||||||
</div>
|
sol.text_solution ? (
|
||||||
))}
|
<Card
|
||||||
</>
|
size="small"
|
||||||
) : (
|
title={
|
||||||
<div
|
<Text strong>
|
||||||
style={{
|
{sol.solution_name}:
|
||||||
textAlign: 'center',
|
</Text>
|
||||||
padding: '20px',
|
}
|
||||||
color: '#8c8c8c',
|
bodyStyle={{
|
||||||
}}
|
padding: '8px 12px',
|
||||||
>
|
marginBottom: '4px',
|
||||||
Tidak ada dokumen solusi tersedia
|
}}
|
||||||
</div>
|
extra={
|
||||||
)}
|
<Text
|
||||||
</Space>
|
type="secondary"
|
||||||
</Card>
|
style={{
|
||||||
|
fontSize:
|
||||||
|
'10px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{sol.type_solution.toUpperCase()}
|
||||||
|
</Text>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<div>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
marginTop:
|
||||||
|
'4px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{sol.text_solution}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</Card>
|
||||||
|
) : null}
|
||||||
|
</div>
|
||||||
|
))}
|
||||||
|
</>
|
||||||
|
) : (
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
textAlign: 'center',
|
||||||
|
padding: '20px',
|
||||||
|
color: '#8c8c8c',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Tidak ada dokumen solusi tersedia
|
||||||
|
</div>
|
||||||
|
)}
|
||||||
|
</Space>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
</Col>
|
</Col>
|
||||||
<Col xs={24} md={8}>
|
<Col xs={24} md={8}>
|
||||||
<Card
|
<div>
|
||||||
size="small"
|
<Card
|
||||||
title="Required Spare Parts"
|
hoverable
|
||||||
style={{ height: '100%' }}
|
bodyStyle={{ padding: '12px'}}
|
||||||
>
|
|
||||||
<Space
|
|
||||||
direction="vertical"
|
|
||||||
size="small"
|
|
||||||
style={{ width: '100%' }}
|
|
||||||
>
|
>
|
||||||
{notification.spareparts &&
|
<Space>
|
||||||
notification.spareparts.length > 0 ? (
|
<ToolOutlined
|
||||||
notification.spareparts.map((sparepart, index) => (
|
style={{ fontSize: '16px', color: '#1890ff' }}
|
||||||
<Card
|
/>
|
||||||
size="small"
|
<Text
|
||||||
key={index}
|
strong
|
||||||
bodyStyle={{ padding: '12px' }}
|
style={{ fontSize: '16px', color: '#262626' }}
|
||||||
hoverable
|
>
|
||||||
>
|
Spare Part
|
||||||
<Row gutter={16} align="top">
|
</Text>
|
||||||
<Col
|
</Space>
|
||||||
span={7}
|
|
||||||
style={{ textAlign: 'center' }}
|
<Space
|
||||||
>
|
direction="vertical"
|
||||||
<div
|
size="small"
|
||||||
style={{
|
style={{ width: '100%' }}
|
||||||
width: '100%',
|
>
|
||||||
height: '60px',
|
{notification.spareparts &&
|
||||||
backgroundColor: '#f0f0f0',
|
notification.spareparts.length > 0 ? (
|
||||||
display: 'flex',
|
notification.spareparts.map((sparepart, index) => (
|
||||||
alignItems: 'center',
|
<Card
|
||||||
justifyContent: 'center',
|
size="small"
|
||||||
borderRadius: '4px',
|
key={index}
|
||||||
marginBottom: '8px',
|
bodyStyle={{ padding: '12px' }}
|
||||||
}}
|
hoverable
|
||||||
|
>
|
||||||
|
<Row gutter={16} align="top">
|
||||||
|
<Col
|
||||||
|
span={7}
|
||||||
|
style={{ textAlign: 'center' }}
|
||||||
>
|
>
|
||||||
<ToolOutlined
|
|
||||||
style={{
|
|
||||||
fontSize: '24px',
|
|
||||||
color: '#bfbfbf',
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<Text
|
|
||||||
style={{
|
|
||||||
fontSize: '12px',
|
|
||||||
color:
|
|
||||||
sparepart.sparepart_stok ===
|
|
||||||
'Available' ||
|
|
||||||
sparepart.sparepart_stok ===
|
|
||||||
'available'
|
|
||||||
? '#52c41a'
|
|
||||||
: '#ff4d4f',
|
|
||||||
fontWeight: 500,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{sparepart.sparepart_stok}
|
|
||||||
</Text>
|
|
||||||
</Col>
|
|
||||||
<Col span={17}>
|
|
||||||
<Space
|
|
||||||
direction="vertical"
|
|
||||||
size={4}
|
|
||||||
style={{ width: '100%' }}
|
|
||||||
>
|
|
||||||
<Text strong>
|
|
||||||
{sparepart.sparepart_name}
|
|
||||||
</Text>
|
|
||||||
<Paragraph
|
|
||||||
style={{
|
|
||||||
fontSize: '12px',
|
|
||||||
margin: 0,
|
|
||||||
color: '#595959',
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
{sparepart.sparepart_description ||
|
|
||||||
'Deskripsi tidak tersedia'}
|
|
||||||
</Paragraph>
|
|
||||||
<div
|
<div
|
||||||
style={{
|
style={{
|
||||||
border: '1px solid #d9d9d9',
|
width: '100%',
|
||||||
|
height: '60px',
|
||||||
|
backgroundColor: '#f0f0f0',
|
||||||
|
display: 'flex',
|
||||||
|
alignItems: 'center',
|
||||||
|
justifyContent: 'center',
|
||||||
borderRadius: '4px',
|
borderRadius: '4px',
|
||||||
padding: '4px 8px',
|
marginBottom: '8px',
|
||||||
fontSize: '11px',
|
|
||||||
color: '#8c8c8c',
|
|
||||||
marginTop: '8px',
|
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Kode: {sparepart.sparepart_code}{' '}
|
<ToolOutlined
|
||||||
| Qty: {sparepart.sparepart_qty}{' '}
|
style={{
|
||||||
| Unit:{' '}
|
fontSize: '24px',
|
||||||
{sparepart.sparepart_unit}
|
color: '#bfbfbf',
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Space>
|
<Text
|
||||||
</Col>
|
style={{
|
||||||
</Row>
|
fontSize: '12px',
|
||||||
</Card>
|
color:
|
||||||
))
|
sparepart.sparepart_stok ===
|
||||||
) : (
|
'Available' ||
|
||||||
<div
|
sparepart.sparepart_stok ===
|
||||||
style={{
|
'available'
|
||||||
textAlign: 'center',
|
? '#52c41a'
|
||||||
padding: '20px',
|
: '#ff4d4f',
|
||||||
color: '#8c8c8c',
|
fontWeight: 500,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
Tidak ada spare parts terkait
|
{sparepart.sparepart_stok}
|
||||||
</div>
|
</Text>
|
||||||
)}
|
</Col>
|
||||||
</Space>
|
<Col span={17}>
|
||||||
</Card>
|
<Space
|
||||||
</Col>
|
direction="vertical"
|
||||||
<Col span={8}>
|
size={4}
|
||||||
<Card size="small" style={{ height: '100%' }}>
|
style={{ width: '100%' }}
|
||||||
<Space
|
>
|
||||||
direction="vertical"
|
<Text strong>
|
||||||
size="small"
|
{sparepart.sparepart_name}
|
||||||
style={{ width: '100%' }}
|
</Text>
|
||||||
>
|
<Paragraph
|
||||||
<Card
|
style={{
|
||||||
size="small"
|
fontSize: '12px',
|
||||||
bodyStyle={{
|
margin: 0,
|
||||||
padding: '8px 12px',
|
color: '#595959',
|
||||||
backgroundColor: isAddingLog ? '#fafafa' : '#fff',
|
}}
|
||||||
}}
|
>
|
||||||
>
|
{sparepart.sparepart_description ||
|
||||||
<Space
|
'Deskripsi tidak tersedia'}
|
||||||
direction="vertical"
|
</Paragraph>
|
||||||
style={{ width: '100%' }}
|
<div
|
||||||
size="small"
|
style={{
|
||||||
>
|
border: '1px solid #d9d9d9',
|
||||||
{isAddingLog && (
|
borderRadius: '4px',
|
||||||
<>
|
padding: '4px 8px',
|
||||||
<Text strong style={{ fontSize: '12px' }}>
|
fontSize: '11px',
|
||||||
Add New Log / Update Progress
|
color: '#8c8c8c',
|
||||||
</Text>
|
marginTop: '8px',
|
||||||
<Input.TextArea
|
}}
|
||||||
rows={2}
|
>
|
||||||
placeholder="Tuliskan update penanganan di sini..."
|
Kode:{' '}
|
||||||
value={newLogDescription}
|
{sparepart.sparepart_code} |
|
||||||
onChange={(e) =>
|
Qty:{' '}
|
||||||
setNewLogDescription(e.target.value)
|
{sparepart.sparepart_qty} |
|
||||||
}
|
Unit:{' '}
|
||||||
disabled={submitLoading}
|
{sparepart.sparepart_unit}
|
||||||
/>
|
</div>
|
||||||
</>
|
</Space>
|
||||||
)}
|
</Col>
|
||||||
<Button
|
</Row>
|
||||||
type={isAddingLog ? 'primary' : 'dashed'}
|
</Card>
|
||||||
size="small"
|
))
|
||||||
block
|
) : (
|
||||||
icon={
|
<div
|
||||||
submitLoading ? (
|
style={{
|
||||||
<LoadingOutlined />
|
textAlign: 'center',
|
||||||
) : (
|
padding: '20px',
|
||||||
!isAddingLog && <PlusOutlined />
|
color: '#8c8c8c',
|
||||||
)
|
}}
|
||||||
}
|
|
||||||
onClick={
|
|
||||||
isAddingLog
|
|
||||||
? handleSubmitLog
|
|
||||||
: () => setIsAddingLog(true)
|
|
||||||
}
|
|
||||||
loading={submitLoading}
|
|
||||||
disabled={submitLoading}
|
|
||||||
>
|
>
|
||||||
{isAddingLog ? 'Submit Log' : 'Add Log'}
|
Tidak ada spare parts terkait
|
||||||
</Button>
|
</div>
|
||||||
{isAddingLog && (
|
)}
|
||||||
<Button
|
</Space>
|
||||||
size="small"
|
</Card>
|
||||||
block
|
</div>
|
||||||
onClick={() => {
|
</Col>
|
||||||
setIsAddingLog(false);
|
<Col xs={24} md={8}>
|
||||||
setNewLogDescription('');
|
<div>
|
||||||
}}
|
<Card bodyStyle={{ padding: '12px'}}>
|
||||||
disabled={submitLoading}
|
<Space>
|
||||||
>
|
<HistoryOutlined
|
||||||
Cancel
|
style={{ fontSize: '16px', color: '#1890ff' }}
|
||||||
</Button>
|
/>
|
||||||
)}
|
<Text
|
||||||
</Space>
|
strong
|
||||||
</Card>
|
style={{ fontSize: '16px', color: '#262626' }}
|
||||||
{logHistoryData.map((log) => (
|
>
|
||||||
|
Log Activity
|
||||||
|
</Text>
|
||||||
|
</Space>
|
||||||
|
|
||||||
|
<Space
|
||||||
|
direction="vertical"
|
||||||
|
size="small"
|
||||||
|
style={{ width: '100%' }}
|
||||||
|
>
|
||||||
<Card
|
<Card
|
||||||
key={log.id}
|
|
||||||
size="small"
|
size="small"
|
||||||
bodyStyle={{
|
bodyStyle={{
|
||||||
padding: '8px 12px',
|
padding: '8px 12px',
|
||||||
|
backgroundColor: isAddingLog
|
||||||
|
? '#fafafa'
|
||||||
|
: '#fff',
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<Paragraph
|
<Space
|
||||||
style={{ fontSize: '12px', margin: 0 }}
|
direction="vertical"
|
||||||
ellipsis={{ rows: 2 }}
|
style={{ width: '100%' }}
|
||||||
|
size="small"
|
||||||
>
|
>
|
||||||
<Text strong>{log.addedBy.name}:</Text>{' '}
|
{isAddingLog && (
|
||||||
{log.description}
|
<>
|
||||||
</Paragraph>
|
<Text
|
||||||
<Text type="secondary" style={{ fontSize: '11px' }}>
|
strong
|
||||||
{log.timestamp}
|
style={{ fontSize: '12px' }}
|
||||||
</Text>
|
>
|
||||||
|
Add New Log / Update Progress
|
||||||
|
</Text>
|
||||||
|
<Input.TextArea
|
||||||
|
rows={2}
|
||||||
|
placeholder="Tuliskan update penanganan di sini..."
|
||||||
|
value={newLogDescription}
|
||||||
|
onChange={(e) =>
|
||||||
|
setNewLogDescription(
|
||||||
|
e.target.value
|
||||||
|
)
|
||||||
|
}
|
||||||
|
disabled={submitLoading}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
<Button
|
||||||
|
type={isAddingLog ? 'primary' : 'dashed'}
|
||||||
|
size="small"
|
||||||
|
block
|
||||||
|
icon={
|
||||||
|
submitLoading ? (
|
||||||
|
<LoadingOutlined />
|
||||||
|
) : (
|
||||||
|
!isAddingLog && <PlusOutlined />
|
||||||
|
)
|
||||||
|
}
|
||||||
|
onClick={
|
||||||
|
isAddingLog
|
||||||
|
? handleSubmitLog
|
||||||
|
: () => setIsAddingLog(true)
|
||||||
|
}
|
||||||
|
loading={submitLoading}
|
||||||
|
disabled={submitLoading}
|
||||||
|
>
|
||||||
|
{isAddingLog ? 'Submit Log' : 'Add Log'}
|
||||||
|
</Button>
|
||||||
|
{isAddingLog && (
|
||||||
|
<Button
|
||||||
|
size="small"
|
||||||
|
block
|
||||||
|
onClick={() => {
|
||||||
|
setIsAddingLog(false);
|
||||||
|
setNewLogDescription('');
|
||||||
|
}}
|
||||||
|
disabled={submitLoading}
|
||||||
|
>
|
||||||
|
Cancel
|
||||||
|
</Button>
|
||||||
|
)}
|
||||||
|
</Space>
|
||||||
</Card>
|
</Card>
|
||||||
))}
|
{logHistoryData.map((log) => (
|
||||||
</Space>
|
<Card
|
||||||
</Card>
|
key={log.id}
|
||||||
|
size="small"
|
||||||
|
bodyStyle={{
|
||||||
|
padding: '8px 12px',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Paragraph
|
||||||
|
style={{ fontSize: '12px', margin: 0 }}
|
||||||
|
// ellipsis={{ rows: 2 }}
|
||||||
|
>
|
||||||
|
<Text strong>{log.addedBy.name}:</Text>{' '}
|
||||||
|
{log.description}
|
||||||
|
</Paragraph>
|
||||||
|
<Text
|
||||||
|
type="secondary"
|
||||||
|
style={{ fontSize: '11px' }}
|
||||||
|
>
|
||||||
|
{log.timestamp}
|
||||||
|
</Text>
|
||||||
|
</Card>
|
||||||
|
))}
|
||||||
|
</Space>
|
||||||
|
</Card>
|
||||||
|
</div>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</Space>
|
</Space>
|
||||||
|
|||||||
@@ -115,7 +115,7 @@ const ChangePasswordModal = (props) => {
|
|||||||
try {
|
try {
|
||||||
const response = await changePassword(props.selectedUser.user_id, formData.newPassword);
|
const response = await changePassword(props.selectedUser.user_id, formData.newPassword);
|
||||||
|
|
||||||
console.log('Change Password Response:', response);
|
// console.log('Change Password Response:', response);
|
||||||
|
|
||||||
if (response && response.statusCode === 200) {
|
if (response && response.statusCode === 200) {
|
||||||
NotifOk({
|
NotifOk({
|
||||||
|
|||||||
@@ -220,35 +220,27 @@ const DetailUser = (props) => {
|
|||||||
|
|
||||||
// For update mode: only send email if it has changed
|
// For update mode: only send email if it has changed
|
||||||
if (FormData.user_id) {
|
if (FormData.user_id) {
|
||||||
// Only include email if it has changed from original
|
|
||||||
if (FormData.user_email !== originalEmail) {
|
if (FormData.user_email !== originalEmail) {
|
||||||
payload.user_email = FormData.user_email;
|
payload.user_email = FormData.user_email;
|
||||||
}
|
}
|
||||||
// Add is_active for update mode
|
|
||||||
payload.is_active = FormData.is_active;
|
payload.is_active = FormData.is_active;
|
||||||
} else {
|
} else {
|
||||||
// For create mode: always send email
|
|
||||||
payload.user_email = FormData.user_email;
|
payload.user_email = FormData.user_email;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Only add role_id if it exists (backend requires number >= 1, no null)
|
|
||||||
if (FormData.role_id) {
|
if (FormData.role_id) {
|
||||||
payload.role_id = FormData.role_id;
|
payload.role_id = FormData.role_id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Add password and name for new user (create mode)
|
// Add password and name for new user (create mode)
|
||||||
if (!FormData.user_id) {
|
if (!FormData.user_id) {
|
||||||
payload.user_name = FormData.user_name; // Username only for create
|
payload.user_name = FormData.user_name;
|
||||||
payload.user_password = FormData.password; // Backend expects 'user_password'
|
payload.user_password = FormData.password;
|
||||||
// Don't send confirmPassword, is_sa for create
|
|
||||||
}
|
}
|
||||||
// For update mode:
|
|
||||||
// - Don't send 'user_name' (username is immutable)
|
|
||||||
// - is_active is now sent for update mode
|
|
||||||
// - Only send email if it has changed
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
console.log('Payload being sent:', payload);
|
// console.log('Payload being sent:', payload);
|
||||||
|
|
||||||
let response;
|
let response;
|
||||||
if (!FormData.user_id) {
|
if (!FormData.user_id) {
|
||||||
@@ -257,11 +249,10 @@ const DetailUser = (props) => {
|
|||||||
response = await updateUser(FormData.user_id, payload);
|
response = await updateUser(FormData.user_id, payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
console.log('Save User Response:', response);
|
// console.log('Save User Response:', response);
|
||||||
|
|
||||||
// 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)) {
|
||||||
// If in edit mode and newPassword is provided, change password
|
|
||||||
if (FormData.user_id && FormData.newPassword) {
|
if (FormData.user_id && FormData.newPassword) {
|
||||||
try {
|
try {
|
||||||
const passwordResponse = await changePassword(
|
const passwordResponse = await changePassword(
|
||||||
@@ -385,9 +376,9 @@ const DetailUser = (props) => {
|
|||||||
search: '',
|
search: '',
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log('Fetching roles with params:', queryParams.toString());
|
// console.log('Fetching roles with params:', queryParams.toString());
|
||||||
const response = await getAllRole(queryParams);
|
const response = await getAllRole(queryParams);
|
||||||
console.log('Fetched roles response:', response);
|
// console.log('Fetched roles response:', response);
|
||||||
|
|
||||||
// Handle different response structures
|
// Handle different response structures
|
||||||
if (response && response.data) {
|
if (response && response.data) {
|
||||||
@@ -408,7 +399,7 @@ const DetailUser = (props) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setRoleList(roles);
|
setRoleList(roles);
|
||||||
console.log('Setting role list:', roles);
|
// console.log('Setting role list:', roles);
|
||||||
} else {
|
} else {
|
||||||
// Add mock data as fallback
|
// Add mock data as fallback
|
||||||
console.warn('No response data, using mock data');
|
console.warn('No response data, using mock data');
|
||||||
@@ -418,7 +409,7 @@ const DetailUser = (props) => {
|
|||||||
{ role_id: 3, role_name: 'User', role_level: 3 },
|
{ role_id: 3, role_name: 'User', role_level: 3 },
|
||||||
];
|
];
|
||||||
setRoleList(mockRoles);
|
setRoleList(mockRoles);
|
||||||
console.log('Setting mock role list:', mockRoles);
|
// console.log('Setting mock role list:', mockRoles);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching roles:', error);
|
console.error('Error fetching roles:', error);
|
||||||
@@ -429,7 +420,7 @@ const DetailUser = (props) => {
|
|||||||
{ role_id: 3, role_name: 'User', role_level: 3 },
|
{ role_id: 3, role_name: 'User', role_level: 3 },
|
||||||
];
|
];
|
||||||
setRoleList(mockRoles);
|
setRoleList(mockRoles);
|
||||||
console.log('Setting mock role list due to error:', mockRoles);
|
// console.log('Setting mock role list due to error:', mockRoles);
|
||||||
|
|
||||||
// Only show error notification if we don't have fallback data
|
// Only show error notification if we don't have fallback data
|
||||||
if (process.env.NODE_ENV === 'development') {
|
if (process.env.NODE_ENV === 'development') {
|
||||||
@@ -1146,9 +1137,7 @@ const DetailUser = (props) => {
|
|||||||
))}
|
))}
|
||||||
</Select>
|
</Select>
|
||||||
{errors.role_id && (
|
{errors.role_id && (
|
||||||
<Text style={{ color: 'red', fontSize: '12px' }}>
|
<Text style={{ color: 'red', fontSize: '12px' }}>{errors.role_id}</Text>
|
||||||
{errors.role_id}
|
|
||||||
</Text>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user