Update Corporate Activation
This commit is contained in:
@@ -116,6 +116,7 @@ export default function PlanList() {
|
||||
}
|
||||
|
||||
const handleInactiveAction = (formularium : any) => {
|
||||
enqueueSnackbar('Fuck yuo'), { variant: 'error' });
|
||||
axios
|
||||
.put('/corporates/'+corporate_id+'/formulariums/'+formularium.id+'/activate')
|
||||
.then(() => {
|
||||
@@ -135,7 +136,8 @@ export default function PlanList() {
|
||||
})
|
||||
})
|
||||
.catch((error) => {
|
||||
enqueueSnackbar(error.message ?? 'Failed Processing Request', { variant: 'error' });
|
||||
console.log(error)
|
||||
enqueueSnackbar(error.data?.message ?? (error.message ?? 'Failed Processing Request'), { variant: 'error' });
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -18,6 +18,7 @@ import { LaravelPaginatedData } from '../../@types/paginated-data';
|
||||
import HeaderBreadcrumbs from '../../components/HeaderBreadcrumbs';
|
||||
import BasePagination from '../../components/BasePagination';
|
||||
import { fCurrency } from '../../utils/formatNumber';
|
||||
import { enqueueSnackbar } from 'notistack';
|
||||
|
||||
export default function Corporates() {
|
||||
const { themeStretch } = useSettings();
|
||||
@@ -223,7 +224,7 @@ export default function Corporates() {
|
||||
{/* </Grid> */}
|
||||
</Stack>
|
||||
|
||||
<Button type='hidden' sx={{ display: 'none' }}>Search</Button>
|
||||
<Button type='submit' sx={{ display: 'none' }}>Search</Button>
|
||||
</form>
|
||||
);
|
||||
}
|
||||
@@ -234,6 +235,29 @@ export default function Corporates() {
|
||||
const { row } = props;
|
||||
const [open, setOpen] = React.useState(false);
|
||||
|
||||
const handleActivate = (model: any, status: string) => {
|
||||
axios.put(`/corporates/${row.id}/activation`, {
|
||||
// service_code: service.service_code,
|
||||
active: status == 'active'
|
||||
})
|
||||
.then((res) => {
|
||||
setDataTableData({
|
||||
...dataTableData,
|
||||
data: dataTableData.data.map((model) => {
|
||||
let updatedModel = model
|
||||
if (row.id == model.id) {
|
||||
updatedModel.active = res.data.corporate.active
|
||||
}
|
||||
return updatedModel
|
||||
})
|
||||
})
|
||||
})
|
||||
.catch((error) => {
|
||||
// console.log('asdasd', error.response.data.message)
|
||||
enqueueSnackbar(error.response.data.message ?? error.message ?? 'Failed Processing Request', { variant: 'error' });
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<React.Fragment>
|
||||
<TableRow sx={{ '& > *': { borderBottom: 'unset' } }}>
|
||||
@@ -248,7 +272,10 @@ export default function Corporates() {
|
||||
</TableCell>
|
||||
<TableCell align="left">{row.code}</TableCell>
|
||||
<TableCell align="left">{row.name}</TableCell>
|
||||
<TableCell align="left"><Button variant="outlined" color="success" size="small">Active</Button></TableCell>
|
||||
<TableCell align="left">
|
||||
{( row.active == 1 && <Button variant="outlined" color="success" size="small" onClick={() => { handleActivate(row, 'inactive') }}>Active</Button> )}
|
||||
{( row.active != 1 && <Button variant="outlined" color="error" size="small" onClick={() => { handleActivate(row, 'active') }}>Inactive</Button> )}
|
||||
</TableCell>
|
||||
<TableCell align="right">
|
||||
<Stack direction="row" justifyContent="flex-end" spacing={1}>
|
||||
<Link to={"/corporates/" + row.id + "/edit"}><Button variant="outlined" color="primary" size="small">Edit</Button></ Link>
|
||||
@@ -368,7 +395,7 @@ export default function Corporates() {
|
||||
<Table aria-label="collapsible table">
|
||||
<TableBody>
|
||||
<TableRow>
|
||||
<TableCell style={headStyle} align="left">#</TableCell>
|
||||
<TableCell style={headStyle} align="left" width={50} />
|
||||
<TableCell style={headStyle} align="left">Code</TableCell>
|
||||
<TableCell style={headStyle} align="left">Name</TableCell>
|
||||
<TableCell style={headStyle} align="left" width={100}>Status</TableCell>
|
||||
|
||||
Reference in New Issue
Block a user