design dark mode add-doctor & change field time to date-picker
This commit is contained in:
@@ -1,8 +1,16 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
|
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
|
||||||
import { LocalizationProvider, TimePicker } from "@mui/x-date-pickers";
|
import { LocalizationProvider, TimePicker } from "@mui/x-date-pickers";
|
||||||
|
import { handleTwoLength } from "@/helper";
|
||||||
|
|
||||||
function TimePickerField({ dataChange, disable, setData, timeStart, data }) {
|
function TimePickerField({
|
||||||
|
dataChange,
|
||||||
|
isVacation,
|
||||||
|
disable,
|
||||||
|
setData,
|
||||||
|
timeStart,
|
||||||
|
data,
|
||||||
|
}) {
|
||||||
const [value, setValue] = useState("00:00");
|
const [value, setValue] = useState("00:00");
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -10,7 +18,7 @@ function TimePickerField({ dataChange, disable, setData, timeStart, data }) {
|
|||||||
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
||||||
<TimePicker
|
<TimePicker
|
||||||
ampm={false}
|
ampm={false}
|
||||||
disabled={disable}
|
disabled={isVacation}
|
||||||
format="hh:mm"
|
format="hh:mm"
|
||||||
className="!w-full"
|
className="!w-full"
|
||||||
shouldDisableTime={(timeValue, clockType) => {
|
shouldDisableTime={(timeValue, clockType) => {
|
||||||
@@ -32,8 +40,6 @@ function TimePickerField({ dataChange, disable, setData, timeStart, data }) {
|
|||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
const hours = e.$H;
|
const hours = e.$H;
|
||||||
const minute = e.$m;
|
const minute = e.$m;
|
||||||
const handleTwoLength = (value) =>
|
|
||||||
String(value).length === 1 ? `0${value}` : value;
|
|
||||||
const newValue = `${handleTwoLength(hours)}:${handleTwoLength(
|
const newValue = `${handleTwoLength(hours)}:${handleTwoLength(
|
||||||
minute
|
minute
|
||||||
)}`;
|
)}`;
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import { useState } from "react";
|
||||||
|
import { AdapterDayjs } from "@mui/x-date-pickers/AdapterDayjs";
|
||||||
|
import { LocalizationProvider, TimePicker } from "@mui/x-date-pickers";
|
||||||
|
import { handleTwoLength } from "@/helper";
|
||||||
|
|
||||||
|
function TimePickerInput() {
|
||||||
|
const [value, setValue] = useState("00:00");
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="w-full relative">
|
||||||
|
<LocalizationProvider dateAdapter={AdapterDayjs}>
|
||||||
|
<TimePicker
|
||||||
|
ampm={false}
|
||||||
|
format="hh:mm"
|
||||||
|
className="!w-full"
|
||||||
|
views={["hours", "minutes"]}
|
||||||
|
placeholder="انتخاب کنید..."
|
||||||
|
onChange={(e) => {
|
||||||
|
const hours = e.$H;
|
||||||
|
const minute = e.$m;
|
||||||
|
const newValue = `${handleTwoLength(hours)}:${handleTwoLength(
|
||||||
|
minute
|
||||||
|
)}`;
|
||||||
|
setValue(newValue);
|
||||||
|
}}
|
||||||
|
sx={{
|
||||||
|
"& .MuiFormLabel-root": {
|
||||||
|
top: "-4px !important",
|
||||||
|
},
|
||||||
|
"& .MuiInputBase-input": { padding: "12.5px 14px" },
|
||||||
|
"& .MuiOutlinedInput-notchedOutline": {
|
||||||
|
border: "1px solid #D7D7D7 !important",
|
||||||
|
},
|
||||||
|
"& .MuiInputBase-root": {
|
||||||
|
borderRadius: "8px !important",
|
||||||
|
},
|
||||||
|
".Mui-focused": {
|
||||||
|
"& .MuiOutlinedInput-notchedOutline": {
|
||||||
|
border: "1px solid #5559CE !important",
|
||||||
|
transition: "0.5s all",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
"& .muirtl-jv54yp-MuiList-root-MuiMultiSectionDigitalClockSection-root::after":
|
||||||
|
{
|
||||||
|
display: "none !important",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
<p
|
||||||
|
className="absolute dark:bg-[#222433] dark:!text-[#A1A1A1] flex items-center right-[4px] h-[44px] py-[8px] px-[8px]
|
||||||
|
w-[calc(100%_-_52px)] text-[#7E7E7E] bg-[#FFFFFF] text-[14px] font-normal top-1/2 -translate-y-1/2"
|
||||||
|
>
|
||||||
|
{value}
|
||||||
|
</p>
|
||||||
|
</LocalizationProvider>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
export default TimePickerInput;
|
||||||
@@ -664,6 +664,10 @@ html {
|
|||||||
width: 464px !important;
|
width: 464px !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.sm-datepicker .panel-jalaali {
|
||||||
|
width: 300px !important;
|
||||||
|
}
|
||||||
|
|
||||||
.day-label-bar,
|
.day-label-bar,
|
||||||
.panel-header-inner,
|
.panel-header-inner,
|
||||||
.days-body {
|
.days-body {
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { DatePicker } from "jalaali-react-date-picker";
|
|||||||
|
|
||||||
function Date() {
|
function Date() {
|
||||||
return (
|
return (
|
||||||
<div className="flex justify-center">
|
<div className="flex justify-center sm-datepicker">
|
||||||
<DatePicker
|
<DatePicker
|
||||||
nextIcon={<></>}
|
nextIcon={<></>}
|
||||||
prevIcon={<></>}
|
prevIcon={<></>}
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import FieldIcon from "@/app/component/FieldIcon";
|
|||||||
import { Button } from "@mui/material";
|
import { Button } from "@mui/material";
|
||||||
import PlusBlueP from "@/components/icons/PlusBlueP";
|
import PlusBlueP from "@/components/icons/PlusBlueP";
|
||||||
import ClockP from "@/components/icons/ClockP";
|
import ClockP from "@/components/icons/ClockP";
|
||||||
|
import TimePickerInput from "@/app/component/TimePickerInput";
|
||||||
|
|
||||||
function Form() {
|
function Form() {
|
||||||
const [data, setData] = useState({
|
const [data, setData] = useState({
|
||||||
@@ -38,7 +39,7 @@ function Form() {
|
|||||||
list={turnsPerDay}
|
list={turnsPerDay}
|
||||||
/>
|
/>
|
||||||
</ContentText>
|
</ContentText>
|
||||||
<ContentText text="تعداد نوبت در هر روز">
|
<ContentText text="زمان هر نوبت">
|
||||||
<AutoCompleteSelect
|
<AutoCompleteSelect
|
||||||
updateData={updateSelect}
|
updateData={updateSelect}
|
||||||
label="انتخاب کنید..."
|
label="انتخاب کنید..."
|
||||||
@@ -50,7 +51,7 @@ function Form() {
|
|||||||
<div className="hidden lg:flex min-w-[152px]"></div>
|
<div className="hidden lg:flex min-w-[152px]"></div>
|
||||||
</div>
|
</div>
|
||||||
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:flex items-end justify-center gap-[16px] mt-[32px]">
|
<div className="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:flex items-end justify-center gap-[16px] mt-[32px]">
|
||||||
<ContentText text="تعداد نوبت در هر روز">
|
<ContentText text="روز هفته">
|
||||||
<AutoCompleteSelect
|
<AutoCompleteSelect
|
||||||
updateData={updateSelect}
|
updateData={updateSelect}
|
||||||
label="انتخاب کنید..."
|
label="انتخاب کنید..."
|
||||||
@@ -59,7 +60,7 @@ function Form() {
|
|||||||
/>
|
/>
|
||||||
</ContentText>
|
</ContentText>
|
||||||
<ContentText text="زمان شروع">
|
<ContentText text="زمان شروع">
|
||||||
<FieldIcon
|
<TimePickerInput
|
||||||
placeholder="انتخاب کنید..."
|
placeholder="انتخاب کنید..."
|
||||||
changeData={changeData}
|
changeData={changeData}
|
||||||
icon={<ClockP />}
|
icon={<ClockP />}
|
||||||
@@ -67,7 +68,7 @@ function Form() {
|
|||||||
/>
|
/>
|
||||||
</ContentText>
|
</ContentText>
|
||||||
<ContentText text="زمان پایان">
|
<ContentText text="زمان پایان">
|
||||||
<FieldIcon
|
<TimePickerInput
|
||||||
placeholder="انتخاب کنید..."
|
placeholder="انتخاب کنید..."
|
||||||
changeData={changeData}
|
changeData={changeData}
|
||||||
icon={<ClockP />}
|
icon={<ClockP />}
|
||||||
|
|||||||
@@ -14,8 +14,13 @@ function ContentModal({
|
|||||||
handleClose,
|
handleClose,
|
||||||
}) {
|
}) {
|
||||||
const [value, setValue] = useState(0);
|
const [value, setValue] = useState(0);
|
||||||
|
const [isVacation, setIsVacation] = useState(false);
|
||||||
|
|
||||||
const handleChange = (event) => setValue(+event.target.value);
|
const handleChange = (event) => {
|
||||||
|
const valueRadio = +event.target.value;
|
||||||
|
setIsVacation(valueRadio);
|
||||||
|
setValue(valueRadio);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal open={open} onClose={handleClose}>
|
<Modal open={open} onClose={handleClose}>
|
||||||
@@ -36,6 +41,7 @@ function ContentModal({
|
|||||||
<Radios value={value} handleChange={handleChange} />
|
<Radios value={value} handleChange={handleChange} />
|
||||||
<Form
|
<Form
|
||||||
handleClose={handleClose}
|
handleClose={handleClose}
|
||||||
|
isVacation={isVacation}
|
||||||
dataChange={dataChange}
|
dataChange={dataChange}
|
||||||
setData={setData}
|
setData={setData}
|
||||||
value={value}
|
value={value}
|
||||||
|
|||||||
@@ -2,27 +2,38 @@ import { Button } from "@mui/material";
|
|||||||
import ContentText from "@/components/panel/ContentText";
|
import ContentText from "@/components/panel/ContentText";
|
||||||
import TimePickerField from "@/app/component/TimePickerField";
|
import TimePickerField from "@/app/component/TimePickerField";
|
||||||
|
|
||||||
function Form({ handleClose, setData, dataChange, data, value }) {
|
function Form({ handleClose, isVacation, setData, dataChange, data, value }) {
|
||||||
|
// console.log(isVacation);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="flex flex-col gap-[32px] md:gap-[36px] lg:gap-[40px] min-w-fit md:min-w-[420px]">
|
<div className="flex flex-col gap-[32px] md:gap-[36px] lg:gap-[40px] min-w-fit md:min-w-[420px]">
|
||||||
<ContentText text="زمان شروع">
|
<div className="flex relative flex-col gap-[32px] md:gap-[36px] lg:gap-[40px]">
|
||||||
<TimePickerField
|
<ContentText text="زمان شروع">
|
||||||
dataChange={dataChange}
|
<TimePickerField
|
||||||
disable={value === 1}
|
dataChange={dataChange}
|
||||||
setData={setData}
|
isDisable={isVacation}
|
||||||
timeStart={true}
|
disable={value === 1}
|
||||||
data={data}
|
setData={setData}
|
||||||
/>
|
timeStart={true}
|
||||||
</ContentText>
|
data={data}
|
||||||
<ContentText text="زمان پایان">
|
/>
|
||||||
<TimePickerField
|
</ContentText>
|
||||||
dataChange={dataChange}
|
<ContentText text="زمان پایان">
|
||||||
disable={value === 1}
|
<TimePickerField
|
||||||
setData={setData}
|
dataChange={dataChange}
|
||||||
timeStart={false}
|
isDisable={isVacation}
|
||||||
data={data}
|
disable={value === 1}
|
||||||
/>
|
setData={setData}
|
||||||
</ContentText>
|
timeStart={false}
|
||||||
|
data={data}
|
||||||
|
/>
|
||||||
|
</ContentText>
|
||||||
|
<div
|
||||||
|
className={`
|
||||||
|
absolute transition-all duration-500 right-0 top-0 w-full h-full bg-[rgba(255,255,255,.85)] dark:bg-[rgba(34,36,51,.85)]
|
||||||
|
${isVacation ? "max-w-full" : "max-w-0"}`}
|
||||||
|
></div>
|
||||||
|
</div>
|
||||||
<div className="flex flex-wrap items-center justify-center gap-[16px]">
|
<div className="flex flex-wrap items-center justify-center gap-[16px]">
|
||||||
<Button
|
<Button
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
|
|||||||
@@ -18,3 +18,6 @@ export const convertToJalali = (date) => {
|
|||||||
|
|
||||||
return `${jalaliYear}/${jalaliMonth}/${jalaliDay}`;
|
return `${jalaliYear}/${jalaliMonth}/${jalaliDay}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const handleTwoLength = (value) =>
|
||||||
|
String(value).length === 1 ? `0${value}` : value;
|
||||||
|
|||||||
Reference in New Issue
Block a user