Compare commits

...

14 Commits

6 changed files with 754 additions and 687 deletions

View File

@@ -82,6 +82,15 @@ const resendChatAllUser = async (notificationId) => {
return response.data; 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,
@@ -92,4 +101,5 @@ export {
resendNotificationToUser, resendNotificationToUser,
resendChatByUser, resendChatByUser,
resendChatAllUser, resendChatAllUser,
searchData,
}; };

View File

@@ -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;

View File

@@ -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;

View File

@@ -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';

View File

@@ -44,6 +44,7 @@ import {
getNotificationDetail, getNotificationDetail,
resendChatByUser, resendChatByUser,
resendChatAllUser, resendChatAllUser,
searchData,
} from '../../../api/notification'; } from '../../../api/notification';
const { Text, Paragraph, Link: AntdLink } = Typography; const { Text, Paragraph, Link: AntdLink } = Typography;
@@ -219,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;
@@ -288,14 +325,16 @@ const ListNotification = memo(function ListNotification(props) {
name: user.contact_name, name: user.contact_name,
phone: user.contact_phone, phone: user.contact_phone,
status: user.is_send ? 'Delivered' : 'Pending', status: user.is_send ? 'Delivered' : 'Pending',
timestamp: user.created_at timestamp: user.updated_at
? new Date(user.created_at).toLocaleString('id-ID', { ? new Date(user.updated_at)
day: '2-digit', .toLocaleString('id-ID', {
month: '2-digit', day: '2-digit',
year: 'numeric', month: '2-digit',
hour: '2-digit', year: 'numeric',
minute: '2-digit', hour: '2-digit',
}) + ' WIB' minute: '2-digit',
})
.replace('.', ':') + ' WIB'
: 'N/A', : 'N/A',
})); }));
setUserHistoryData(transformedUsers); setUserHistoryData(transformedUsers);
@@ -382,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>
@@ -610,9 +649,6 @@ const ListNotification = memo(function ListNotification(props) {
icon={<SendOutlined />} icon={<SendOutlined />}
onClick={async () => { onClick={async () => {
await resendChatByUser(user.id, user.phone); await resendChatByUser(user.id, user.phone);
// message.info(
// 'Resend feature is not available yet. This feature is still under development.'
// );
}} }}
> >
Resend Resend
@@ -698,8 +734,8 @@ const ListNotification = memo(function ListNotification(props) {
{/* 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 />
@@ -710,13 +746,16 @@ const ListNotification = memo(function ListNotification(props) {
Added at {log.timestamp} Added at {log.timestamp}
</Text> </Text>
</Space> </Space>
<div> <div>
<Text strong> <Text strong>
Added by: {log.addedBy.name} {log.addedBy.name}
</Text> </Text>
</div>
<div>
<span <span
style={{ style={{
marginLeft: '8px',
border: '1px solid #52c41a', border: '1px solid #52c41a',
color: '#52c41a', color: '#52c41a',
padding: '2px 6px', padding: '2px 6px',
@@ -729,7 +768,8 @@ const ListNotification = memo(function ListNotification(props) {
</div> </div>
</Space> </Space>
</Col> </Col>
<Col xs={24} md={12}> <Col xs={24} md={14}>
<Text strong>Description:</Text>
<Paragraph <Paragraph
style={{ style={{
color: '#595959', color: '#595959',

File diff suppressed because it is too large Load Diff