add fitur edit hak kamar, penempatan dan submission date
This commit is contained in:
@@ -212,12 +212,17 @@ class RequestLogController extends Controller
|
||||
public function update(Request $request, $id)
|
||||
{
|
||||
$requestLog = RequestLog::findOrFail($id);
|
||||
$requestLog->submission_date = $request->submission_date;
|
||||
$requestLog->keterangan = $request->keterangan;
|
||||
$requestLog->hak_kamar_pasien = $request->hak_kamar_pasien;
|
||||
$requestLog->penempatan_kamar = $request->penempatan_kamar;
|
||||
$requestLog->catatan = $request->catatan;
|
||||
$requestLog->reason = $request->reason;
|
||||
|
||||
if ($request->status){
|
||||
$requestLog->status = $request->status;
|
||||
}
|
||||
|
||||
$requestLog->status = $request->status;
|
||||
$requestLog->approved_by = auth()->user()->id;
|
||||
$requestLog->approved_at = Carbon::now();
|
||||
$requestLog->save();
|
||||
|
||||
@@ -113,6 +113,7 @@ class RequestLogShowResource extends JsonResource
|
||||
'hak_kamar_pasien' => $requestLog['hak_kamar_pasien'],
|
||||
'penempatan_kamar' => $requestLog['penempatan_kamar'],
|
||||
'catatan' => $requestLog['catatan'],
|
||||
'reason' => $requestLog['reason'],
|
||||
|
||||
|
||||
];
|
||||
|
||||
@@ -38,6 +38,7 @@ class RequestLog extends Model
|
||||
'import_system',
|
||||
'diagnosis',
|
||||
'code',
|
||||
'reason',
|
||||
'approved_by',
|
||||
'approved_at',
|
||||
'approved_final_log_by',
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
return new class extends Migration
|
||||
{
|
||||
/**
|
||||
* Run the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function up()
|
||||
{
|
||||
Schema::table('request_logs', function (Blueprint $table) {
|
||||
$table->string('reason')->after('diagnosis')->default(null);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Reverse the migrations.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function down()
|
||||
{
|
||||
Schema::table('request_logs', function (Blueprint $table) {
|
||||
$table->dropColumn('reason');
|
||||
});
|
||||
}
|
||||
};
|
||||
@@ -542,7 +542,7 @@ export default function CorporateForm({ isEdit, currentCorporate }: Props) {
|
||||
<option value="Agreement changed">Agreement changed</option>
|
||||
<option value="Endorsement">Endorsement</option>
|
||||
<option value="Renewal">Renewal</option>
|
||||
<option value="Worng Setting">Worng Setting</option>
|
||||
<option value="Wrong Setting">Wrong Setting</option>
|
||||
</RHFSelect>
|
||||
)}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import MuiDialog from "@/components/MuiDialog";
|
||||
import { Button, Card, Checkbox, DialogActions, Grid, TextField, Typography } from "@mui/material";
|
||||
import { Button, Card, Checkbox, DialogActions, Grid, TextField, TextareaAutosize, Typography } from "@mui/material";
|
||||
import { Paper } from "@mui/material";
|
||||
import { Stack } from '@mui/material';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
@@ -103,6 +103,16 @@ export default function DialogConfirmation({requestLog, setOpenDialog, openDialo
|
||||
return numericInput;
|
||||
};
|
||||
|
||||
const handleKeyPress = (e:any) => {
|
||||
if (e.key === 'Enter' && !e.shiftKey) {
|
||||
// Menghentikan default "Enter" (tidak membuat baris baru)
|
||||
e.preventDefault();
|
||||
|
||||
// Menambahkan karakter baris baru
|
||||
handleChange('keterangan', `${formData.keterangan}\n`);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
const getContent = () => (
|
||||
<Stack spacing={1} marginTop={2}>
|
||||
@@ -147,12 +157,20 @@ export default function DialogConfirmation({requestLog, setOpenDialog, openDialo
|
||||
</Stack>
|
||||
<Stack direction='row' spacing={2} sx={marginBottom2}>
|
||||
<Typography variant='subtitle2' sx={style1} gutterBottom>Keterangan</Typography>
|
||||
<TextField
|
||||
label="Keterangan"
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
<TextareaAutosize
|
||||
aria-label="Keterangan"
|
||||
minRows={3}
|
||||
placeholder="Masukkan keterangan..."
|
||||
value={formData.keterangan}
|
||||
onChange={(e) => handleChange('keterangan', e.target.value)}
|
||||
onKeyDown={handleKeyPress}
|
||||
style={{
|
||||
width: '100%',
|
||||
padding: '8px',
|
||||
border: '1px solid #ced4da',
|
||||
borderRadius: '4px',
|
||||
fontSize: '14px',
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack direction='row' spacing={2} sx={marginBottom2}>
|
||||
|
||||
@@ -0,0 +1,234 @@
|
||||
import MuiDialog from "@/components/MuiDialog";
|
||||
import { Button, Card, Checkbox, DialogActions, Grid, TextField, TextareaAutosize, Typography, Select } from "@mui/material";
|
||||
import { Paper } from "@mui/material";
|
||||
import { Stack } from '@mui/material';
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import { DetailRequestLogType } from "../Model/Types";
|
||||
import { fDateOnly, fDateTimesecond, toTitleCase } from "@/utils/formatTime";
|
||||
import axios from "@/utils/axios";
|
||||
import { enqueueSnackbar } from "notistack";
|
||||
import { useNavigate } from "react-router";
|
||||
import { RHFSelect, RHFTextField, RHFEditor } from "@/components/hook-form";
|
||||
import { Autocomplete } from "@mui/material";
|
||||
// import { RHFEditor } from "@/components/hook-form/v2";
|
||||
|
||||
|
||||
type DialogConfirmationType = {
|
||||
openDialog: boolean;
|
||||
setOpenDialog: any;
|
||||
onSubmit?: void;
|
||||
requestLog: DetailRequestLogType|undefined;
|
||||
}
|
||||
|
||||
export default function DialogEditInformation({requestLog, setOpenDialog, openDialog, onSubmit} : DialogConfirmationType ) {
|
||||
const navigate = useNavigate();
|
||||
|
||||
const [formData, setFormData] = useState({
|
||||
submission_date: requestLog?.submission_date,
|
||||
keterangan: requestLog?.keterangan,
|
||||
hak_kamar_pasien: requestLog?.hak_kamar_pasien,
|
||||
penempatan_kamar: requestLog?.penempatan_kamar,
|
||||
reason: requestLog?.reason
|
||||
});
|
||||
|
||||
const [isReasonSelected, setIsReasonSelected] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
// Update formData setiap kali requestLog berubah
|
||||
setFormData({
|
||||
submission_date: requestLog?.submission_date || '',
|
||||
keterangan: requestLog?.keterangan || '',
|
||||
hak_kamar_pasien: requestLog?.hak_kamar_pasien || '',
|
||||
penempatan_kamar: requestLog?.penempatan_kamar || '',
|
||||
reason: requestLog?.reason || '',
|
||||
|
||||
});
|
||||
}, [requestLog]);
|
||||
|
||||
const handleChange = (field, value) => {
|
||||
setFormData((prevData) => ({
|
||||
...prevData,
|
||||
[field]: value,
|
||||
}));
|
||||
if (field === 'reason') {
|
||||
setIsReasonSelected(!!value);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
const handleApprove = () => {
|
||||
setFormData((prevData) => ({
|
||||
...prevData,
|
||||
}));
|
||||
handleSubmit();
|
||||
};
|
||||
|
||||
|
||||
const handleSubmit = () => {
|
||||
if (isReasonSelected && formData.reason !== '') {
|
||||
axios
|
||||
.put(`customer-service/request/${requestLog?.id}`, formData)
|
||||
.then((response) => {
|
||||
enqueueSnackbar('Verification Request LOG Success', { variant: 'success' });
|
||||
setOpenDialog(false);
|
||||
navigate('/custormer-service/request')
|
||||
})
|
||||
.catch(({ response }) => {
|
||||
enqueueSnackbar(response.data.message ?? 'Something went wrong!', { variant: 'error' });
|
||||
});
|
||||
} else {
|
||||
setIsReasonSelected(false);
|
||||
alert('Silakan pilih alasan sebelum mengirimkan data.');
|
||||
}
|
||||
}
|
||||
|
||||
const style1 = {
|
||||
color: '#919EAB',
|
||||
width: '30%'
|
||||
}
|
||||
const style2 = {
|
||||
width: '70%'
|
||||
}
|
||||
const marginBottom1 = {
|
||||
marginBottom: 1,
|
||||
}
|
||||
|
||||
const marginBottom2 = {
|
||||
marginBottom: 2,
|
||||
}
|
||||
|
||||
const resetForm = () => {
|
||||
setFormData({
|
||||
submission_date: requestLog?.submission_date ?? '',
|
||||
keterangan: requestLog?.keterangan ?? '',
|
||||
hak_kamar_pasien: requestLog?.hak_kamar_pasien ?? '',
|
||||
penempatan_kamar: requestLog?.penempatan_kamar ?? '',
|
||||
reason: requestLog?.reason ?? '',
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
const handleCloseDialog = () => {
|
||||
setOpenDialog(false);
|
||||
resetForm();
|
||||
}
|
||||
|
||||
const handleNumericInput = (input: any) => {
|
||||
const numericInput = input.replace(/\D/g, '');
|
||||
return numericInput;
|
||||
};
|
||||
|
||||
const handleKeyPress = (e:any) => {
|
||||
if (e.key === 'Enter' && !e.shiftKey) {
|
||||
// Menghentikan default "Enter" (tidak membuat baris baru)
|
||||
e.preventDefault();
|
||||
|
||||
// Menambahkan karakter baris baru
|
||||
handleChange('keterangan', `${formData.keterangan}\n`);
|
||||
}
|
||||
};
|
||||
|
||||
const reasons = [
|
||||
{ value: 'agreement', label: 'Agreement changed' },
|
||||
{ value: 'endorsement', label: 'Endorsement' },
|
||||
{ value: 'renewal', label: 'Renewal' },
|
||||
{ value: 'wrong_setting', label: 'Wrong Setting' },
|
||||
// Add more options as needed
|
||||
];
|
||||
|
||||
const getContent = () => (
|
||||
<Stack spacing={1} marginTop={2}>
|
||||
<Typography variant="subtitle2">Are you sure to update this request ?</Typography>
|
||||
<Grid item xs={12} md={12} marginTop={4}>
|
||||
<Card sx={{padding:2, marginTop:2}} >
|
||||
<Stack direction='row' spacing={2} sx={marginBottom2}>
|
||||
<Typography variant='subtitle2' sx={style1} gutterBottom>Addmision Date</Typography>
|
||||
<TextField
|
||||
label="Addmision Date"
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
type="date"
|
||||
value={formData.submission_date ? fDateOnly(formData.submission_date) : ''}
|
||||
onChange={(e) => handleChange('submission_date', e.target.value)}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack direction='row' spacing={2} sx={marginBottom2}>
|
||||
<Typography variant='subtitle2' sx={style1} gutterBottom>Keterangan</Typography>
|
||||
<TextareaAutosize
|
||||
aria-label="Keterangan"
|
||||
minRows={3}
|
||||
placeholder="Masukkan keterangan..."
|
||||
value={formData.keterangan}
|
||||
onChange={(e) => handleChange('keterangan', e.target.value)}
|
||||
onKeyDown={handleKeyPress}
|
||||
style={{
|
||||
width: '100%',
|
||||
padding: '8px',
|
||||
border: '1px solid #ced4da',
|
||||
borderRadius: '4px',
|
||||
fontSize: '14px',
|
||||
}}
|
||||
/>
|
||||
{/* <RHFEditor name="description" placeholder="Tuliskan Deskripsi" /> */}
|
||||
</Stack>
|
||||
<Stack direction='row' spacing={2} sx={marginBottom2}>
|
||||
<Typography variant='subtitle2' sx={style1} gutterBottom>Hak Kamar Pasien</Typography>
|
||||
<TextField
|
||||
label="Hak Kamar Pasien"
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
value={formData.hak_kamar_pasien}
|
||||
onChange={(e) => handleChange('hak_kamar_pasien', e.target.value)}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack direction='row' spacing={2} sx={marginBottom2}>
|
||||
<Typography variant='subtitle2' sx={style1} gutterBottom>Penempatan Kamar</Typography>
|
||||
<TextField
|
||||
label="Penempatan Kamar"
|
||||
variant="outlined"
|
||||
fullWidth
|
||||
value={formData.penempatan_kamar}
|
||||
onChange={(e) => handleChange('penempatan_kamar', e.target.value)}
|
||||
/>
|
||||
</Stack>
|
||||
<Stack direction='row' spacing={2} sx={marginBottom2}>
|
||||
<Typography variant='subtitle2' sx={style1} gutterBottom>Reason*</Typography>
|
||||
<Autocomplete
|
||||
options={reasons}
|
||||
getOptionLabel={(option) => option.label}
|
||||
fullWidth
|
||||
value={reasons.find((r) => r.value === formData.reason) || null} // Use find to match the default value
|
||||
onChange={(e, newValue) => handleChange('reason', newValue?.value)}
|
||||
renderInput={(params) => (
|
||||
<TextField
|
||||
{...params}
|
||||
label="Reason"
|
||||
variant="outlined"
|
||||
required
|
||||
error={!isReasonSelected} // Menandai input sebagai salah jika opsi tidak dipilih
|
||||
helperText={!isReasonSelected ? 'Alasan harus dipilih' : ''}
|
||||
|
||||
/>
|
||||
)}
|
||||
/>
|
||||
</Stack>
|
||||
</Card>
|
||||
</Grid>
|
||||
<DialogActions>
|
||||
<Button variant="outlined" sx={{color: '#212B36', borderColor: '#919EAB52'}} onClick={handleCloseDialog}>Cancel</Button>
|
||||
<Button color="primary" variant="contained" onClick={() => handleApprove()}>Update</Button>
|
||||
</DialogActions>
|
||||
</Stack>
|
||||
);
|
||||
|
||||
|
||||
return (
|
||||
<MuiDialog
|
||||
title={{name: "Confirmation"}}
|
||||
openDialog={openDialog}
|
||||
setOpenDialog={setOpenDialog}
|
||||
content={getContent()}
|
||||
maxWidth="xl"
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import {
|
||||
Typography,
|
||||
Card,
|
||||
Dialog,
|
||||
MenuItem,
|
||||
} from '@mui/material';
|
||||
// components
|
||||
import Page from '../../../components/Page';
|
||||
@@ -20,6 +21,9 @@ import { DetailRequestLogType } from './Model/Types';
|
||||
import { fDate, fDateTimesecond } from '@/utils/formatTime';
|
||||
import { Button } from '@mui/material';
|
||||
import DialogConfirmation from './Components/DialogConfirmation';
|
||||
import MoreMenu from '@/components/MoreMenu';
|
||||
import { EditOutlined } from '@mui/icons-material';
|
||||
import DialogEditInformation from './Components/DialogEditInformation';
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
@@ -69,6 +73,7 @@ export default function Detail() {
|
||||
|
||||
const [approve, setApprove] = useState('')
|
||||
|
||||
const [openDialogEdit, setOpenDialogEdit] = useState(false);
|
||||
return (
|
||||
<Page title='Detail'>
|
||||
<Container maxWidth={themeStretch ? false : 'xl'}>
|
||||
@@ -79,7 +84,28 @@ export default function Detail() {
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={12} md={12}>
|
||||
<Card sx={{padding:2}} >
|
||||
<Typography variant='subtitle1' sx={{color: '#19BBBB', marginBottom: 4}} gutterBottom>Detail</Typography>
|
||||
<Grid container spacing={2}>
|
||||
<Grid item xs={6}>
|
||||
<Typography variant='subtitle1' sx={{ color: '#19BBBB', marginBottom: 4 }} gutterBottom>
|
||||
Detail
|
||||
</Typography>
|
||||
</Grid>
|
||||
<Grid item xs={6} sx={{ display: 'flex', placeContent: 'end' }}>
|
||||
<MoreMenu
|
||||
actions={
|
||||
<>
|
||||
<MenuItem onClick={() => {
|
||||
setOpenDialogEdit(true);
|
||||
}}>
|
||||
<EditOutlined />
|
||||
Edit
|
||||
</MenuItem>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
<Stack direction='row' spacing={2} sx={marginBottom1}>
|
||||
<Typography variant='subtitle2' sx={style1} gutterBottom>Provider Name</Typography>
|
||||
<Typography variant='subtitle2' sx={style2} gutterBottom>{requestLog?.provider}</Typography>
|
||||
@@ -185,9 +211,20 @@ export default function Detail() {
|
||||
openDialog={openDialogSubmit}
|
||||
approve={approve}
|
||||
></DialogConfirmation>
|
||||
|
||||
</Stack>
|
||||
</Grid>
|
||||
) : null}
|
||||
<Grid item xs={12} md={12}>
|
||||
<Stack direction="row" padding={4} sx={{ justifyContent: 'space-between' }}>
|
||||
<DialogEditInformation
|
||||
setOpenDialog={setOpenDialogEdit}
|
||||
requestLog={requestLog}
|
||||
openDialog={openDialogEdit}
|
||||
>
|
||||
</DialogEditInformation>
|
||||
</Stack>
|
||||
</Grid>
|
||||
|
||||
</Grid>
|
||||
</Container>
|
||||
|
||||
@@ -50,8 +50,9 @@ export type DetailRequestLogType = {
|
||||
hak_kamar_pasien : string,
|
||||
penempatan_kamar : string,
|
||||
provider : string,
|
||||
status : string,
|
||||
status : string,
|
||||
benefit : Benefit[],
|
||||
reason : string
|
||||
}
|
||||
|
||||
export type Benefit = {
|
||||
|
||||
Reference in New Issue
Block a user