complete changes on admin and slight changes on page routes loading
This commit is contained in:
@ -222,6 +222,7 @@ function AppBarAdmin(props) {
|
||||
|
||||
function handleMenuRoute(menu){
|
||||
// console.log(menu + " sini menunya di appbar")
|
||||
props.toRoute()
|
||||
Router.push(menu)
|
||||
}
|
||||
|
||||
|
||||
@ -103,6 +103,7 @@ function TabelJadwalDokter(props) {
|
||||
const jamSelesaiInputRef = useRef();
|
||||
const [jamMulai, setJamMulai] = useState(null);
|
||||
const [jamSelesai, setJamSelesai] = useState(null);
|
||||
const [status, setStatus] = useState('');
|
||||
|
||||
useEffect(() => {
|
||||
setHari(props.hari_nya)
|
||||
@ -141,20 +142,22 @@ function TabelJadwalDokter(props) {
|
||||
|
||||
await MySwal.fire({
|
||||
title: 'Yakin ?',
|
||||
text: `Jadwal Pada Hari ${hari} akan ditambahkan ke dokter dengan nik ${nik}`,
|
||||
text: (status == 'tambah') ? `Jadwal Pada Hari ${hari} akan ditambahkan ke dokter dengan nik ${nik}` : `Jadwal Pada Hari ${hari} akan diubah ke dokter dengan nik ${nik}`,
|
||||
icon: 'info',
|
||||
showCancelButton: true,
|
||||
confirmButtonColor: '#3085d6',
|
||||
cancelButtonColor: '#d33',
|
||||
confirmButtonText: 'Ya, tambahkan!'
|
||||
confirmButtonText: (status == 'tambah') ? 'Ya, tambahkan!' : 'Ya, ubah!',
|
||||
}).then(async (result) => {
|
||||
if (result.value) {
|
||||
props.backdropnya(true);
|
||||
|
||||
|
||||
|
||||
try {
|
||||
const url = process.env.HTTP_URL + "/api/admin/jadwal_dokter";
|
||||
const response = await fetch(url, {
|
||||
method: 'POST',
|
||||
method: (status == 'tambah') ? 'POST' : 'PUT',
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
'allow-cors-origin': '*',
|
||||
@ -210,6 +213,7 @@ function TabelJadwalDokter(props) {
|
||||
() => {
|
||||
setHari(props.harinya[i])
|
||||
setOpenDialog(true)
|
||||
setStatus("tambah")
|
||||
}
|
||||
}>
|
||||
<ModeEditIcon />
|
||||
@ -226,7 +230,21 @@ function TabelJadwalDokter(props) {
|
||||
<TableCell>{props.dataJadwal[j].jam_mulai}</TableCell>
|
||||
<TableCell>{props.dataJadwal[j].jam_selesai}</TableCell>
|
||||
<TableCell>
|
||||
<IconButton color="success">
|
||||
<IconButton color="success"
|
||||
onClick={
|
||||
() => {
|
||||
setHari(props.harinya[i])
|
||||
let today = new Date()
|
||||
let jam_mulai_new = new Date(today.getFullYear(), today.getMonth(), today.getDate(), props.dataJadwal[j].jam_mulai.split(":")[0], props.dataJadwal[j].jam_mulai.split(":")[1])
|
||||
let jam_selesai_new = new Date(today.getFullYear(), today.getMonth(), today.getDate(), props.dataJadwal[j].jam_selesai.split(":")[0], props.dataJadwal[j].jam_selesai.split(":")[1])
|
||||
|
||||
setJamMulai(jam_mulai_new)
|
||||
setJamSelesai(jam_selesai_new)
|
||||
setOpenDialog(true)
|
||||
setStatus("edit")
|
||||
}
|
||||
}
|
||||
>
|
||||
<ModeEditIcon />
|
||||
</IconButton>
|
||||
<IconButton color="error">
|
||||
@ -272,6 +290,7 @@ function TabelJadwalDokter(props) {
|
||||
label="Jam Mulai"
|
||||
value={jamMulai}
|
||||
onChange={(newValue) => {
|
||||
console.log(newValue, "ini new value")
|
||||
setJamMulai(newValue);
|
||||
}}
|
||||
renderInput={(params) => <TextField {...params} />}
|
||||
@ -296,7 +315,9 @@ function TabelJadwalDokter(props) {
|
||||
</DialogContent>
|
||||
<DialogActions>
|
||||
<Button variant="outlined" type="submit" color="primary">
|
||||
Tambah
|
||||
{
|
||||
status == "tambah" ? "Tambah" : "Edit"
|
||||
}
|
||||
</Button>
|
||||
|
||||
</DialogActions>
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
|
||||
import { useRef, useState } from "react";
|
||||
import { useRef, useState ,useEffect } from "react";
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
|
||||
@ -55,18 +55,15 @@ const StyledTableCell = styled(TableCell)(({ theme }) => ({
|
||||
}
|
||||
}));
|
||||
|
||||
// const useStyles = makeStyles({
|
||||
// table: {
|
||||
// minWidth: 650,
|
||||
// "& .MuiTableCell-root": {
|
||||
// borderLeft: "1px solid rgba(224, 224, 224, 1)"
|
||||
// }
|
||||
// }
|
||||
// });
|
||||
|
||||
export default function GridIndex(props) {
|
||||
// console.log(props)
|
||||
const [errornya , setError] = useState(props.errornya)
|
||||
console.log(props)
|
||||
const [errornya, setError] = useState(props.errornya)
|
||||
const [jadwal_dokter, setJadwalDokter] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
setJadwalDokter(props.jadwal_dokter)
|
||||
},[props.jadwal_dokter])
|
||||
|
||||
if (errornya == true) {
|
||||
MySwal.fire({
|
||||
@ -121,7 +118,7 @@ export default function GridIndex(props) {
|
||||
if (role == 'Admin') {
|
||||
// redirect to dashboard
|
||||
await router.replace('/admin');
|
||||
}else if (role == 'Dokter') {
|
||||
} else if (role == 'Dokter') {
|
||||
// redirect to dashboard
|
||||
await router.replace('/dokter');
|
||||
}
|
||||
@ -189,16 +186,32 @@ export default function GridIndex(props) {
|
||||
</TableHead>
|
||||
<TableBody>
|
||||
{
|
||||
props.jadwal_dokter.map((jadwal, index) => {
|
||||
return (
|
||||
<TableRow key={index}>
|
||||
<TableCell>{jadwal.tb_dokter.nama}</TableCell>
|
||||
<TableCell>{jadwal.tb_dokter.spesialis}</TableCell>
|
||||
<TableCell>{jadwal.jam_mulai}</TableCell>
|
||||
<TableCell>{jadwal.jam_selesai}</TableCell>
|
||||
// (jadwal_dokter == false)
|
||||
// ?
|
||||
// <TableRow>
|
||||
// <TableCell colSpan={4} align="center">
|
||||
// Masalah Dengan Server
|
||||
// </TableCell>
|
||||
// </TableRow>
|
||||
// :
|
||||
(jadwal_dokter.length > 0)
|
||||
?
|
||||
jadwal_dokter.map((jadwal, index) => {
|
||||
return (
|
||||
<TableRow key={index}>
|
||||
<TableCell>{jadwal.tb_dokter.nama}</TableCell>
|
||||
<TableCell>{jadwal.tb_dokter.spesialis}</TableCell>
|
||||
<TableCell>{jadwal.jam_mulai}</TableCell>
|
||||
<TableCell>{jadwal.jam_selesai}</TableCell>
|
||||
</TableRow>
|
||||
)
|
||||
})
|
||||
:
|
||||
<TableRow>
|
||||
<TableCell colSpan={4} align="center">
|
||||
Tidak Ada Jadwal Praktek
|
||||
</TableCell>
|
||||
</TableRow>
|
||||
)
|
||||
})
|
||||
}
|
||||
</TableBody>
|
||||
</Table>
|
||||
|
||||
Reference in New Issue
Block a user