update status function
This commit is contained in:
@@ -19,12 +19,18 @@ import { useForm } from 'react-hook-form';
|
|||||||
import * as Yup from 'yup';
|
import * as Yup from 'yup';
|
||||||
import { CorporateFormulariumList } from "./Types";
|
import { CorporateFormulariumList } from "./Types";
|
||||||
|
|
||||||
export default function CategoryDetail(props: DetailCorpFormularium) {
|
type ParamsDetail = {
|
||||||
|
props: DetailCorpFormularium,
|
||||||
|
formularium: CorporateFormulariumList,
|
||||||
|
}
|
||||||
|
|
||||||
|
export default function CategoryDetail({props, formularium} : ParamsDetail) {
|
||||||
|
|
||||||
type FormValuesProps = {
|
type FormValuesProps = {
|
||||||
value: string;
|
value: string;
|
||||||
active: boolean;
|
active: boolean;
|
||||||
};
|
};
|
||||||
|
const { corporate_id } = useParams();
|
||||||
const [open, setOpen] = React.useState(false);
|
const [open, setOpen] = React.useState(false);
|
||||||
const [isDialogOpen, setDialogOpen] = useState(false)
|
const [isDialogOpen, setDialogOpen] = useState(false)
|
||||||
let titles = {
|
let titles = {
|
||||||
@@ -59,7 +65,7 @@ export default function CategoryDetail(props: DetailCorpFormularium) {
|
|||||||
|
|
||||||
const onSubmit = async (row : any) => {
|
const onSubmit = async (row : any) => {
|
||||||
try {
|
try {
|
||||||
handleUpdate(dataValue?.active, dataValue?.id)
|
handleUpdate(dataValue?.active, dataValue?.id, row.reason)
|
||||||
} catch (error: any) {
|
} catch (error: any) {
|
||||||
console.log('data gagal');
|
console.log('data gagal');
|
||||||
}
|
}
|
||||||
@@ -70,14 +76,19 @@ export default function CategoryDetail(props: DetailCorpFormularium) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleUpdate = (active: string, id: number) => {
|
const handleUpdate = (active: string, id: number, reason: string) => {
|
||||||
console.log(active)
|
if (active == "Active") {
|
||||||
|
active = "0"
|
||||||
|
} else {
|
||||||
|
active = "1"
|
||||||
|
}
|
||||||
|
console.log(corporate_id, id , active)
|
||||||
axios
|
axios
|
||||||
.put(`/corporates/${id}/formulariums-update-status/${id}`, {
|
.put(`/corporates/${corporate_id}/formulariums-update-status/${id}`, {
|
||||||
active: active,
|
active: active,
|
||||||
reason: reason
|
|
||||||
})
|
})
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
|
console.log(res.data.message)
|
||||||
window.location.reload();
|
window.location.reload();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -85,7 +96,7 @@ export default function CategoryDetail(props: DetailCorpFormularium) {
|
|||||||
const getContent = () => (
|
const getContent = () => (
|
||||||
<>
|
<>
|
||||||
<Stack paddingX={2} paddingY={2}>
|
<Stack paddingX={2} paddingY={2}>
|
||||||
<Typography variant='subtitle1'>Are you sure to {dataValue?.active === "1" ? 'Inactive' : 'Active'} this Formularium ?</Typography>
|
<Typography variant='subtitle1'>Are you sure to {dataValue?.active === "Active" ? 'inactive' : 'active'} this Formularium ?</Typography>
|
||||||
<Stack>
|
<Stack>
|
||||||
<Card>
|
<Card>
|
||||||
<Grid container paddingX={2} paddingY={2}>
|
<Grid container paddingX={2} paddingY={2}>
|
||||||
@@ -127,7 +138,7 @@ export default function CategoryDetail(props: DetailCorpFormularium) {
|
|||||||
>
|
>
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
{dataValue?.active == "1" ?
|
{dataValue?.active == "Active" ?
|
||||||
<LoadingButton
|
<LoadingButton
|
||||||
sx={{boxShadow: '0px 2px 4px rgba(0,0,0,0.1)'}}
|
sx={{boxShadow: '0px 2px 4px rgba(0,0,0,0.1)'}}
|
||||||
type='submit'
|
type='submit'
|
||||||
@@ -167,9 +178,11 @@ export default function CategoryDetail(props: DetailCorpFormularium) {
|
|||||||
<TableCell align='left'>{props.code}</TableCell>
|
<TableCell align='left'>{props.code}</TableCell>
|
||||||
<TableCell align='left'>{props.name}</TableCell>
|
<TableCell align='left'>{props.name}</TableCell>
|
||||||
<TableCell align='left' width={100}>
|
<TableCell align='left' width={100}>
|
||||||
<Label color='success'>
|
{formularium.active == "Active" ? (
|
||||||
Active
|
<Label color='success'>Active</Label>
|
||||||
</Label>
|
): (
|
||||||
|
<Label color='error'>Inactive</Label>
|
||||||
|
)}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
<TableCell align='center' width={100}>
|
<TableCell align='center' width={100}>
|
||||||
<TableMoreMenu actions={
|
<TableMoreMenu actions={
|
||||||
@@ -179,11 +192,11 @@ export default function CategoryDetail(props: DetailCorpFormularium) {
|
|||||||
Detail
|
Detail
|
||||||
</MenuItem>
|
</MenuItem>
|
||||||
<MenuItem onClick={() => handleActivate(true, {
|
<MenuItem onClick={() => handleActivate(true, {
|
||||||
id: 0,
|
id: formularium.id,
|
||||||
formulaurium_category_id: 0,
|
formulaurium_category_id: formularium.formulaurium_category_id,
|
||||||
category: '-',
|
category: formularium.category,
|
||||||
description: '-',
|
description: formularium.description,
|
||||||
active: '1'
|
active: formularium.active
|
||||||
})
|
})
|
||||||
}>
|
}>
|
||||||
<CachedOutlined />
|
<CachedOutlined />
|
||||||
@@ -194,13 +207,15 @@ export default function CategoryDetail(props: DetailCorpFormularium) {
|
|||||||
</TableCell>
|
</TableCell>
|
||||||
</TableRow>
|
</TableRow>
|
||||||
</TableBody>
|
</TableBody>
|
||||||
<TableRow>
|
<TableBody>
|
||||||
<TableCell colSpan={5} style={{paddingBottom:0, paddingTop:0}}>
|
<TableRow>
|
||||||
<Collapse in={open} timeout='auto' unmountOnExit>
|
<TableCell colSpan={5} style={{paddingBottom:0, paddingTop:0}}>
|
||||||
<InfoDetail {...props}/>
|
<Collapse in={open} timeout='auto' unmountOnExit>
|
||||||
</Collapse>
|
<InfoDetail {...props}/>
|
||||||
</TableCell>
|
</Collapse>
|
||||||
</TableRow>
|
</TableCell>
|
||||||
|
</TableRow>
|
||||||
|
</TableBody>
|
||||||
|
|
||||||
{/* TODO: dialog update status */}
|
{/* TODO: dialog update status */}
|
||||||
<DialogUpdateStatus
|
<DialogUpdateStatus
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ const CategoryRow: React.FC<CorporateFormulariumList> = (props) => {
|
|||||||
<TableCell colSpan={5} align="center">No Data</TableCell>
|
<TableCell colSpan={5} align="center">No Data</TableCell>
|
||||||
) : (
|
) : (
|
||||||
dataRow?.map(item => (
|
dataRow?.map(item => (
|
||||||
<CategoryDetail {...item}/>
|
<CategoryDetail props={item} formularium={props}/>
|
||||||
))
|
))
|
||||||
)}
|
)}
|
||||||
</Table>
|
</Table>
|
||||||
|
|||||||
@@ -45,8 +45,6 @@ export default function List() {
|
|||||||
setDataTableLoading(false);
|
setDataTableLoading(false);
|
||||||
setDataTableData(resp.data);
|
setDataTableData(resp.data);
|
||||||
setDataRow(resp.data.data);
|
setDataRow(resp.data.data);
|
||||||
console.log(dataTableData);
|
|
||||||
console.log(dataRow);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const applyFilter = async (searchFilter: any) => {
|
const applyFilter = async (searchFilter: any) => {
|
||||||
@@ -63,6 +61,8 @@ export default function List() {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
loadDataTableData();
|
loadDataTableData();
|
||||||
|
console.log(dataTableData);
|
||||||
|
console.log(dataRow);
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ export default function List() {
|
|||||||
<Table aria-label="collapsible table">
|
<Table aria-label="collapsible table">
|
||||||
<TableHead>
|
<TableHead>
|
||||||
<TableRow>
|
<TableRow>
|
||||||
<TableCell align='left' width={50}/>
|
<TableCell align='left' width={50}></TableCell>
|
||||||
<TableCell style={headStyle} align="left">Formularium Name</TableCell>
|
<TableCell style={headStyle} align="left">Formularium Name</TableCell>
|
||||||
<TableCell style={headStyle} align="left">Description</TableCell>
|
<TableCell style={headStyle} align="left">Description</TableCell>
|
||||||
<TableCell style={headStyle} align="center" width={100}></TableCell>
|
<TableCell style={headStyle} align="center" width={100}></TableCell>
|
||||||
|
|||||||
Reference in New Issue
Block a user