Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…epro-health into fix/chatbot
  • Loading branch information
nflnsr committed Dec 13, 2023
2 parents 5b6c16f + 2d3e560 commit 8846a4a
Show file tree
Hide file tree
Showing 14 changed files with 327 additions and 503 deletions.
30 changes: 30 additions & 0 deletions src/apis/APISchedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,34 @@ export const APISchedule = {
throw new Error(err);
}
},

updateInactiveSchedule: async ({ date, session }) => {
try {
const result = await axiosInstance.put(
`/doctors/schedule/inactive?date=${date}&session=${session}`,
);
return result.data.response;
} catch (err) {
if (err instanceof AxiosError) {
const { response } = err.response.data;
throw new AxiosError(response);
}
throw new Error(err);
}
},

updateActiveSchedule: async ({ date, session }) => {
try {
const result = await axiosInstance.put(
`/doctors/schedule/active?date=${date}&session=${session}`,
);
return result.data.response;
} catch (err) {
if (err instanceof AxiosError) {
const { response } = err.response.data;
throw new AxiosError(response);
}
throw new Error(err);
}
},
};
4 changes: 2 additions & 2 deletions src/components/layout-components/Topbar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,14 @@ export default function Topbar() {
<div className="app-container z-10 flex justify-between py-5 md:py-3">
<div className="flex items-center">
<DrawerSidebar />
<Link to="/dashboard">
<a href="/dashboard">
<img
id="logo-reprohealth-topbar"
src={logoReproHealth}
alt="logo"
className="hidden w-28 cursor-pointer sm:block md:w-40"
/>
</Link>
</a>
</div>

<div id="profile-doctor-topbar" className="flex items-center gap-3">
Expand Down
75 changes: 46 additions & 29 deletions src/components/shared-components/ModalConfirmSchedule.jsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,60 @@
import { Button, Modal } from "antd";
import { useState } from "react";
import { Button, Modal } from "antd";
import { useDispatch } from "react-redux";
import { IoIosWarning } from "react-icons/io";

import { showSuccessToast } from "./Toast";
import { showErrorToast, showSuccessToast } from "./Toast";
import { APISchedule } from "@/apis/APISchedule";
import { toggleFetchLatestData } from "@/store/toggle-fetch-new-data";

export function ModalConfirmSchedule({
payload,
handleOpenDrawer,
closeModal,
textDate,
textSession,
}) {
const [isModalOpen, setIsModalOpen] = useState(true);
const [isSubmitting, setIsSubmitting] = useState(false);
const dispatch = useDispatch();
const handleOk = async () => {
setIsSubmitting(true);

const handleOk = () => {
setIsModalOpen(false);
closeModal();
handleOpenDrawer();
showSuccessToast("Jadwal berhasil diubah !", "top-center", "large");
if (payload.doctor_available) {
try {
await APISchedule.updateActiveSchedule(payload);
showSuccessToast("Jadwal berhasil diubah !", "top-center", "large");
} catch (error) {
console.error(error);
showErrorToast("Jadwal gagal diubah !", "top-center", "large");
} finally {
setIsModalOpen(false);
closeModal();
handleOpenDrawer();
dispatch(toggleFetchLatestData());
}
} else {
try {
await APISchedule.updateInactiveSchedule(payload);
showSuccessToast("Jadwal berhasil diubah !", "top-center", "large");
} catch (error) {
console.error(error);
showErrorToast("Jadwal gagal diubah !", "top-center", "large");
} finally {
setIsModalOpen(false);
closeModal();
handleOpenDrawer();
dispatch(toggleFetchLatestData());
}
}
};

const handleCancel = () => {
setIsModalOpen(false);
closeModal();
handleOpenDrawer();
};

const status = payload.doctor_available ? "mengaktifkan" : "menonaktifkan";
return (
<>
<Modal
Expand All @@ -36,18 +67,19 @@ export function ModalConfirmSchedule({
id="button-confirm-schedule"
key="ok"
onClick={handleOk}
className="mb-2 mt-5 h-10 rounded-lg bg-[#FEA53F] text-sm text-white sm:px-7 sm:text-base sm:font-medium"
className="mb-2 mt-5 h-10 rounded-lg bg-warning text-sm text-white disabled:bg-warning/70 sm:px-7 sm:text-base sm:font-medium"
style={{
border: "transparent",
}}
disabled={isSubmitting}
>
Ya, Saya yakin
</Button>
<Button
id="button-cancel-schedule"
key="cancel"
onClick={handleCancel}
className="ms-4 mt-5 h-10 rounded-lg border-[#FEA53F] text-sm text-[#FEA53F] sm:px-7 sm:text-base sm:font-medium"
className="ms-4 mt-5 h-10 rounded-lg border-warning text-sm text-warning sm:px-7 sm:text-base sm:font-medium"
>
Tidak, Batalkan
</Button>
Expand All @@ -60,28 +92,13 @@ export function ModalConfirmSchedule({
>
<IoIosWarning className="h-16 w-16 text-[#FEA53F] sm:h-20 sm:w-20" />
<p className="mt-5 text-[14px] font-normal text-grey-400 sm:text-sm md:px-3">
Anda akan menonaktifkan sesi {textSession} pada {textDate}. Yakin
untuk mengonfirmasi pengubahan ini?
Anda akan <strong>{status}</strong> sesi{" "}
<strong>{payload?.session}</strong> pada tanggal{" "}
<strong>{textDate}</strong>. Yakin untuk mengonfirmasi pengubahan
ini?
</p>
</section>
</Modal>
</>
);
}

// const openNotification = () => {
// notification.open({
// message: (
// <p className="font-medium text-[#FBFBFB]">Jadwal berhasil diubah!</p>
// ),
// });

// notification.config({
// top: 75,
// placement: "topRight",
// closeIcon: <p className="text-sm text-[#93E5D5]">Abaikan</p>,
// duration: 5,
// className: "bg-green-500 h-[64px] w-screen",
// stack: true,
// });
// };
21 changes: 21 additions & 0 deletions src/utils/FormatDate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import dayjs from "dayjs";
import "dayjs/locale/id";

dayjs.locale("id");

export const formatDateToStringMonth = (date) => {
const value = dayjs(date, "YYYY-MM-DD");
return value.format("MMMM YYYY");
};

export const formatDateToStringDay = (date) => {
const value = dayjs(date, "YYYY-MM-DD");
return value.format("dddd, DD MMMM YYYY");
};

export const formatDateToStringWeek = (date) => {
const value = dayjs(date, "YYYY-MM-DD");
return `Week ${value.week()}, ${value.startOf("week").format("DD")} - ${value
.endOf("week")
.format("DD MMMM YYYY")}`;
};
2 changes: 1 addition & 1 deletion src/utils/MapListData.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export function formatStrDayJs(date) {
return date?.format("DD-MM-YYYY");
return date?.format("YYYY-MM-DD");
}

export function mapListData(data, eventDate) {
Expand Down
2 changes: 1 addition & 1 deletion src/views/app-views/article/misc/DetailArticle.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function DetailArticle() {
setDetailArticles(result?.response);
setIsLoading(false);
} catch (error) {
console.log(error);
console.error(error);
setIsError(error);
setIsLoading(false);
}
Expand Down
3 changes: 0 additions & 3 deletions src/views/app-views/dashboard/components/AppointmentTable.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ export function AppointmentTable() {
const fetchDataAppointment = async () => {
try {
const result = await APIAppointment.getListAppointments();
console.log(result);

setData(result);
setIsLoading(false);
Expand All @@ -29,8 +28,6 @@ export function AppointmentTable() {
fetchDataAppointment();
}, []);

console.log("data appointment", data);

return (
<>
<Card id="appointment-table-section">
Expand Down
Loading

0 comments on commit 8846a4a

Please sign in to comment.