lavoce #12

Merged
bragaz_rexita merged 2 commits from lavoce into main 2025-11-04 06:23:15 +00:00
18 changed files with 58 additions and 66 deletions

View File

@@ -4,6 +4,8 @@ import { Form, Input, Row, Col, Typography, Switch } from 'antd';
const { Text } = Typography; const { Text } = Typography;
const BrandForm = ({ form, formData, onValuesChange, isEdit = false }) => { const BrandForm = ({ form, formData, onValuesChange, isEdit = false }) => {
const isActive = Form.useWatch('is_active', form) ?? formData.is_active ?? true;
return ( return (
<Form <Form
layout="vertical" layout="vertical"
@@ -15,12 +17,11 @@ const BrandForm = ({ form, formData, onValuesChange, isEdit = false }) => {
<div style={{ display: 'flex', alignItems: 'center' }}> <div style={{ display: 'flex', alignItems: 'center' }}>
<Form.Item name="is_active" valuePropName="checked" noStyle> <Form.Item name="is_active" valuePropName="checked" noStyle>
<Switch <Switch
checked={formData.is_active} style={{ backgroundColor: isActive ? '#23A55A' : '#bfbfbf' }}
style={{ backgroundColor: formData.is_active ? '#23A55A' : '#bfbfbf' }}
/> />
</Form.Item> </Form.Item>
<Text style={{ marginLeft: 8 }}> <Text style={{ marginLeft: 8 }}>
{formData.is_active ? 'Running' : 'Offline'} {isActive ? 'Running' : 'Offline'}
</Text> </Text>
</div> </div>
</Form.Item> </Form.Item>

View File

@@ -112,6 +112,7 @@ const ErrorCodeForm = ({
const solutionName = values[`solution_name_${fieldId}`]; const solutionName = values[`solution_name_${fieldId}`];
const textSolution = values[`text_solution_${fieldId}`]; const textSolution = values[`text_solution_${fieldId}`];
const solutionStatus = values[`solution_status_${fieldId}`];
const filesForSolution = fileList.filter((file) => file.solutionId === fieldId); const filesForSolution = fileList.filter((file) => file.solutionId === fieldId);
const solutionType = values[`solution_type_${fieldId}`] || solutionTypes[fieldId]; const solutionType = values[`solution_type_${fieldId}`] || solutionTypes[fieldId];
@@ -122,7 +123,7 @@ const ErrorCodeForm = ({
type_solution: 'text', type_solution: 'text',
text_solution: textSolution.trim(), text_solution: textSolution.trim(),
path_solution: '', path_solution: '',
is_active: solutionStatuses[fieldId] !== false, is_active: solutionStatus !== undefined ? solutionStatus : true,
}; };
if (window.currentSolutionData && window.currentSolutionData[fieldId]) { if (window.currentSolutionData && window.currentSolutionData[fieldId]) {
@@ -145,7 +146,7 @@ const ErrorCodeForm = ({
(file.type.startsWith('image/') ? 'image' : 'pdf'), (file.type.startsWith('image/') ? 'image' : 'pdf'),
text_solution: '', text_solution: '',
path_solution: file.uploadPath, path_solution: file.uploadPath,
is_active: solutionStatuses[fieldId] !== false, is_active: solutionStatus !== undefined ? solutionStatus : true,
}; };
if (window.currentSolutionData && window.currentSolutionData[fieldId]) { if (window.currentSolutionData && window.currentSolutionData[fieldId]) {

View File

@@ -67,7 +67,7 @@ const columns = (showPreviewModal, showEditModal, showDeleteDialog) => [
), ),
}, },
{ {
title: 'Aksi', title: 'Action',
key: 'action', key: 'action',
align: 'center', align: 'center',
width: '15%', width: '15%',
@@ -251,7 +251,7 @@ const ListBrandDevice = memo(function ListBrandDevice(props) {
}} }}
size="large" size="large"
> >
Tambah Brand Device Add Brand Device
</Button> </Button>
</ConfigProvider> </ConfigProvider>
</Space> </Space>

View File

@@ -20,6 +20,8 @@ const SolutionField = ({
onFileView, onFileView,
errorCodeForm, errorCodeForm,
}) => { }) => {
// Watch the solution status from the form
const watchedStatus = Form.useWatch(`solution_status_${fieldId}`, errorCodeForm);
useEffect(() => { useEffect(() => {
if (currentSolutionData && errorCodeForm) { if (currentSolutionData && errorCodeForm) {
if (currentSolutionData.solution_name) { if (currentSolutionData.solution_name) {
@@ -146,34 +148,22 @@ const SolutionField = ({
</Form.Item> </Form.Item>
<Form.Item label="Status"> <Form.Item label="Status">
<Form.Item
shouldUpdate={(prevValues, currentValues) =>
prevValues[`solution_status_${fieldId}`] !==
currentValues[`solution_status_${fieldId}`]
}
noStyle
>
{({ getFieldValue, setFieldValue }) => {
const currentStatus = getFieldValue(`solution_status_${fieldId}`);
return (
<div style={{ display: 'flex', alignItems: 'center' }}> <div style={{ display: 'flex', alignItems: 'center' }}>
<Form.Item name={`solution_status_${fieldId}`} valuePropName="checked" noStyle>
<Switch <Switch
checked={currentStatus === true}
onChange={(checked) => {
setFieldValue(`solution_status_${fieldId}`, checked);
}}
disabled={isReadOnly} disabled={isReadOnly}
onChange={(checked) => {
onSolutionStatusChange(fieldId, checked);
}}
style={{ style={{
backgroundColor: solutionStatus ? '#23A55A' : '#bfbfbf', backgroundColor: (watchedStatus ?? true) ? '#23A55A' : '#bfbfbf',
}} }}
/> />
</Form.Item>
<Text style={{ marginLeft: 8 }}> <Text style={{ marginLeft: 8 }}>
{currentStatus === true ? 'Active' : 'Non Active'} {(watchedStatus ?? true) ? 'Active' : 'Non Active'}
</Text> </Text>
</div> </div>
);
}}
</Form.Item>
</Form.Item> </Form.Item>
<Form.Item label="Solution Type"> <Form.Item label="Solution Type">

View File

@@ -194,9 +194,7 @@ export const useErrorCodeLogic = (errorCodeForm, fileList) => {
}; };
const handleSolutionStatusChange = (fieldId, status) => { const handleSolutionStatusChange = (fieldId, status) => {
// Update form immediately // Only update local state - form is already updated by Form.Item
errorCodeForm.setFieldValue(`solution_status_${fieldId}`, status);
// Then update local state
setSolutionStatuses(prev => ({ setSolutionStatuses(prev => ({
...prev, ...prev,
[fieldId]: status [fieldId]: status

View File

@@ -81,7 +81,7 @@ const columns = (showPreviewModal, showEditModal, showDeleteDialog) => [
), ),
}, },
{ {
title: 'Aksi', title: 'Action',
key: 'aksi', key: 'aksi',
align: 'center', align: 'center',
width: '15%', width: '15%',
@@ -249,7 +249,7 @@ const ListDevice = memo(function ListDevice(props) {
onClick={() => showAddModal()} onClick={() => showAddModal()}
size="large" size="large"
> >
Tambah Data Add data
</Button> </Button>
</ConfigProvider> </ConfigProvider>
</Space> </Space>

View File

@@ -62,7 +62,7 @@ const columns = (showPreviewModal, showEditModal, showDeleteDialog) => [
), ),
}, },
{ {
title: 'Aksi', title: 'Action',
key: 'aksi', key: 'aksi',
align: 'center', align: 'center',
width: '15%', width: '15%',
@@ -226,7 +226,7 @@ const ListPlantSubSection = memo(function ListPlantSubSection(props) {
onClick={() => showAddModal()} onClick={() => showAddModal()}
size="large" size="large"
> >
Tambah Data Add data
</Button> </Button>
</ConfigProvider> </ConfigProvider>
</Space> </Space>

View File

@@ -78,7 +78,7 @@ const columns = (showPreviewModal, showEditModal, showDeleteDialog) => [
), ),
}, },
{ {
title: 'Aksi', title: 'Action',
key: 'aksi', key: 'aksi',
align: 'center', align: 'center',
width: '25%', width: '25%',
@@ -239,7 +239,7 @@ const ListShift = memo(function ListShift(props) {
onClick={() => showAddModal()} onClick={() => showAddModal()}
size="large" size="large"
> >
Tambah Data Add data
</Button> </Button>
</ConfigProvider> </ConfigProvider>
</Space> </Space>

View File

@@ -128,7 +128,7 @@ const DetailStatus = (props) => {
title={ title={
<Text style={{ fontSize: '18px' }}> <Text style={{ fontSize: '18px' }}>
{props.actionMode === 'add' {props.actionMode === 'add'
? 'Tambah Data' ? 'Add data'
: props.actionMode === 'preview' : props.actionMode === 'preview'
? 'Preview Status' ? 'Preview Status'
: 'Edit Status'} : 'Edit Status'}

View File

@@ -43,7 +43,7 @@ const columns = (showPreviewModal, showEditModal, showDeleteDialog) => [
width: '40%', width: '40%',
}, },
{ {
title: 'Aksi', title: 'Action',
key: 'aksi', key: 'aksi',
align: 'center', align: 'center',
width: '20%', width: '20%',
@@ -198,7 +198,7 @@ const ListStatus = memo(function ListStatus(props) {
}} }}
> >
<Button icon={<PlusOutlined />} onClick={showAddModal} size="large"> <Button icon={<PlusOutlined />} onClick={showAddModal} size="large">
Tambah Data Add data
</Button> </Button>
</ConfigProvider> </ConfigProvider>
</Col> </Col>

View File

@@ -98,7 +98,7 @@ const columns = (showPreviewModal, showEditModal, showDeleteDialog) => [
), ),
}, },
{ {
title: 'Aksi', title: 'Action',
key: 'aksi', key: 'aksi',
align: 'center', align: 'center',
width: '15%', width: '15%',
@@ -289,7 +289,7 @@ const ListTag = memo(function ListTag(props) {
onClick={() => showAddModal()} onClick={() => showAddModal()}
size="large" size="large"
> >
Tambah Data Add data
</Button> </Button>
</ConfigProvider> </ConfigProvider>
</Space> </Space>

View File

@@ -61,7 +61,7 @@ const columns = (showPreviewModal, showEditModal, showDeleteDialog) => [
), ),
}, },
{ {
title: 'Aksi', title: 'Action',
key: 'aksi', key: 'aksi',
align: 'center', align: 'center',
width: '20%', width: '20%',
@@ -258,7 +258,7 @@ const ListUnit = memo(function ListUnit(props) {
onClick={() => showAddModal()} onClick={() => showAddModal()}
size="large" size="large"
> >
Tambah Data Add Data
</Button> </Button>
</ConfigProvider> </ConfigProvider>
</Space> </Space>

View File

@@ -23,7 +23,7 @@ const IndexNotification = memo(function IndexNotification() {
{ {
title: ( title: (
<Text strong style={{ fontSize: '14px' }}> <Text strong style={{ fontSize: '14px' }}>
Notifikasi Notification
</Text> </Text>
), ),
}, },

View File

@@ -168,7 +168,7 @@ const ListNotification = memo(function ListNotification(props) {
color: '#262626', color: '#262626',
}} }}
> >
Notifikasi Notification
</h2> </h2>
<p style={{ margin: '0 0 24px 0', color: '#8c8c8c', fontSize: '14px' }}> <p style={{ margin: '0 0 24px 0', color: '#8c8c8c', fontSize: '14px' }}>
Riwayat notifikasi yang dikirim ke engineer Riwayat notifikasi yang dikirim ke engineer
@@ -181,7 +181,7 @@ const ListNotification = memo(function ListNotification(props) {
onClick={() => setActiveTab('all')} onClick={() => setActiveTab('all')}
style={tabButtonStyle(activeTab === 'all')} style={tabButtonStyle(activeTab === 'all')}
> >
Semua All
</button> </button>
<button <button
onClick={() => setActiveTab('unread')} onClick={() => setActiveTab('unread')}
@@ -192,7 +192,7 @@ const ListNotification = memo(function ListNotification(props) {
gap: '8px', gap: '8px',
}} }}
> >
Belum Dibaca Not read yet
{getUnreadCount() > 0 && ( {getUnreadCount() > 0 && (
<Badge <Badge
count={getUnreadCount()} count={getUnreadCount()}
@@ -206,7 +206,7 @@ const ListNotification = memo(function ListNotification(props) {
onClick={() => setActiveTab('read')} onClick={() => setActiveTab('read')}
style={tabButtonStyle(activeTab === 'read')} style={tabButtonStyle(activeTab === 'read')}
> >
Sudah Dibaca Already read
</button> </button>
</div> </div>
</div> </div>
@@ -381,7 +381,7 @@ const ListNotification = memo(function ListNotification(props) {
fontWeight: 500, fontWeight: 500,
}} }}
> >
Lihat Detail View Detail
</Button> </Button>
</div> </div>
</div> </div>
@@ -397,3 +397,5 @@ const ListNotification = memo(function ListNotification(props) {
}); });
export default ListNotification; export default ListNotification;

View File

@@ -186,7 +186,7 @@ const ListReport = memo(function ListReport(props) {
icon={<FileTextOutlined />} icon={<FileTextOutlined />}
onClick={handleSearch} onClick={handleSearch}
> >
Tampilkan Show
</Button> </Button>
</Col> </Col>
<Col> <Col>

View File

@@ -174,7 +174,7 @@ const ReportTrending = memo(function ReportTrending(props) {
icon={<FileTextOutlined />} icon={<FileTextOutlined />}
onClick={handleSearch} onClick={handleSearch}
> >
Tampilkan Show
</Button> </Button>
</Col> </Col>
<Col> <Col>

View File

@@ -42,7 +42,7 @@ const DetailRole = (props) => {
setConfirmLoading(true); setConfirmLoading(true);
const validationRules = [ const validationRules = [
{ field: 'role_name', label: 'Nama Role', required: true }, { field: 'role_name', label: 'Role name', required: true },
{ field: 'role_level', label: 'Level', required: true }, { field: 'role_level', label: 'Level', required: true },
]; ];
@@ -169,7 +169,7 @@ const DetailRole = (props) => {
<Row gutter={16}> <Row gutter={16}>
<Col span={12}> <Col span={12}>
<div style={{ marginBottom: 12 }}> <div style={{ marginBottom: 12 }}>
<Text strong>Nama Role</Text> <Text strong>Role name</Text>
<Text style={{ color: 'red' }}> *</Text> <Text style={{ color: 'red' }}> *</Text>
<Input <Input
name="role_name" name="role_name"
@@ -196,7 +196,7 @@ const DetailRole = (props) => {
</Col> </Col>
</Row> </Row>
<div style={{ marginBottom: 12 }}> <div style={{ marginBottom: 12 }}>
<Text strong>Deskripsi Role</Text> <Text strong>Role Description</Text>
<TextArea <TextArea
name="role_description" name="role_description"
value={formData.role_description} value={formData.role_description}

View File

@@ -28,7 +28,7 @@ const columns = (showPreviewModal, showEditModal, showDeleteDialog) => [
hidden: true, hidden: true,
}, },
{ {
title: 'Nama Role', title: 'Role Name',
dataIndex: 'role_name', dataIndex: 'role_name',
key: 'role_name', key: 'role_name',
width: '25%', width: '25%',
@@ -41,7 +41,7 @@ const columns = (showPreviewModal, showEditModal, showDeleteDialog) => [
align: 'center', align: 'center',
}, },
{ {
title: 'Deskripsi', title: 'Description',
dataIndex: 'role_description', dataIndex: 'role_description',
key: 'role_description', key: 'role_description',
width: '35%', width: '35%',
@@ -67,7 +67,7 @@ const columns = (showPreviewModal, showEditModal, showDeleteDialog) => [
), ),
}, },
{ {
title: 'Aksi', title: 'Action',
key: 'aksi', key: 'aksi',
align: 'center', align: 'center',
width: '15%', width: '15%',
@@ -229,7 +229,7 @@ const ListRole = memo(function ListRole(props) {
onClick={() => showAddModal()} onClick={() => showAddModal()}
size="large" size="large"
> >
Tambah Data Add Data
</Button> </Button>
</ConfigProvider> </ConfigProvider>
</Space> </Space>