Compare commits
5 Commits
2afefc7442
...
700a9261a8
Author | SHA1 | Date | |
---|---|---|---|
700a9261a8 | |||
ffae2f728b | |||
307d2621ce | |||
6b19adf03e | |||
dcfa7a46d8 |
@ -51,5 +51,6 @@
|
|||||||
"create": "बनाएं",
|
"create": "बनाएं",
|
||||||
"operation": "ऑपरेशन",
|
"operation": "ऑपरेशन",
|
||||||
"next": "अगला",
|
"next": "अगला",
|
||||||
"select": "चुनें"
|
"select": "चुनें",
|
||||||
|
"productCode": "प्रोडक्ट कोड"
|
||||||
}
|
}
|
@ -2,8 +2,10 @@ import PropTypes from "prop-types";
|
|||||||
import { AnimatePresence } from "motion/react";
|
import { AnimatePresence } from "motion/react";
|
||||||
import clsx from "clsx";
|
import clsx from "clsx";
|
||||||
import FieldError from "./FieldError";
|
import FieldError from "./FieldError";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
function FormSelect({ props, valid = true, className = "", options }) {
|
function FormSelect({ props, valid = true, className = "", options }) {
|
||||||
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<select
|
<select
|
||||||
@ -14,7 +16,7 @@ function FormSelect({ props, valid = true, className = "", options }) {
|
|||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<option disabled value="">
|
<option disabled value="">
|
||||||
Select
|
{t("select")}
|
||||||
</option>
|
</option>
|
||||||
{options?.map(({ value, label }) => (
|
{options?.map(({ value, label }) => (
|
||||||
<option key={value} value={value}>
|
<option key={value} value={value}>
|
||||||
|
@ -166,10 +166,7 @@ function ChargeEdit() {
|
|||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
{notification.message !== "" && <Notification {...notification} />}
|
{notification.message !== "" && <Notification {...notification} />}
|
||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
<div className="relative">
|
|
||||||
{notification.type === "success" && (
|
|
||||||
<div className="absolute inset-0 bg-[#fff]/50 z-10 rounded-3xl" />
|
|
||||||
)}
|
|
||||||
<FormBox title={t("chargeEdit")}>
|
<FormBox title={t("chargeEdit")}>
|
||||||
<FieldsWrapper>{formFields.map(renderField)}</FieldsWrapper>
|
<FieldsWrapper>{formFields.map(renderField)}</FieldsWrapper>
|
||||||
<Button
|
<Button
|
||||||
@ -180,7 +177,6 @@ function ChargeEdit() {
|
|||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</FormBox>
|
</FormBox>
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -14,11 +14,7 @@ import FieldsWrapper from "../components/FieldsWrapper";
|
|||||||
|
|
||||||
function CheckInOutManagement() {
|
function CheckInOutManagement() {
|
||||||
const [accountNumber, setAccountNumber] = useState("");
|
const [accountNumber, setAccountNumber] = useState("");
|
||||||
const [notification, setNotification] = useState({
|
const [notification, setNotification] = useState({ message: "", type: "" });
|
||||||
visible: false,
|
|
||||||
message: "",
|
|
||||||
type: "",
|
|
||||||
});
|
|
||||||
|
|
||||||
const showToast = useToast();
|
const showToast = useToast();
|
||||||
const { setIsLoading } = useLoading();
|
const { setIsLoading } = useLoading();
|
||||||
@ -64,7 +60,7 @@ function CheckInOutManagement() {
|
|||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
{notification.visible && <Notification notification={notification} />}
|
{ notification.message !== "" && <Notification {...notification} /> }
|
||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
<FormBox title="Check In/Out">
|
<FormBox title="Check In/Out">
|
||||||
<FieldsWrapper>
|
<FieldsWrapper>
|
||||||
@ -80,7 +76,7 @@ function CheckInOutManagement() {
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</FormField>
|
</FormField>
|
||||||
</FieldsWrapper>
|
</FieldsWrapper>
|
||||||
<Button text="Next" onClick={handleNext} />
|
<Button text="Next" onClick={handleNext} />
|
||||||
</FormBox>
|
</FormBox>
|
||||||
</div>
|
</div>
|
||||||
|
@ -166,15 +166,10 @@ function KeySwap() {
|
|||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
{notification.message !== "" && <Notification {...notification} />}
|
{notification.message !== "" && <Notification {...notification} />}
|
||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
<div className="relative">
|
<FormBox title={t("lockerStatus")}>
|
||||||
{notification.type === "success" && (
|
<FieldsWrapper>{formFields.map(renderField)}</FieldsWrapper>
|
||||||
<div className="absolute inset-0 bg-[#fff]/50 z-10 rounded-3xl" />
|
<Button text={t("submit")} onClick={handleKeySwap} />
|
||||||
)}
|
</FormBox>
|
||||||
<FormBox title={t("lockerStatus")}>
|
|
||||||
<FieldsWrapper>{formFields.map(renderField)}</FieldsWrapper>
|
|
||||||
<Button text={t("submit")} onClick={handleKeySwap} />
|
|
||||||
</FormBox>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -3,8 +3,10 @@ import { useNavigate } from "react-router-dom";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import FormBox from "../components/FormBox";
|
import FormBox from "../components/FormBox";
|
||||||
import Button from "../components/Button";
|
import Button from "../components/Button";
|
||||||
import { motion, AnimatePresence } from "motion/react";
|
import FormField from "../components/FormField";
|
||||||
import clsx from "clsx";
|
import FormInput from "../components/FormInput";
|
||||||
|
import FormSelect from "../components/FormSelect";
|
||||||
|
import FieldsWrapper from "../components/FieldsWrapper";
|
||||||
|
|
||||||
function LockerMaintenance() {
|
function LockerMaintenance() {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
@ -19,48 +21,44 @@ function LockerMaintenance() {
|
|||||||
navigate(operation.value);
|
navigate(operation.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const formFields = [
|
||||||
|
{
|
||||||
|
name: "value",
|
||||||
|
label: t("operation"),
|
||||||
|
options: [
|
||||||
|
{ label: t("status"), value: "status" },
|
||||||
|
{ label: t("keySwap"), value: "key-swap" },
|
||||||
|
],
|
||||||
|
type: "select",
|
||||||
|
},
|
||||||
|
];
|
||||||
|
|
||||||
|
const renderField = (field) => {
|
||||||
|
const commonProps = {
|
||||||
|
value: operation[field.name],
|
||||||
|
onChange: (e) => {
|
||||||
|
const newValues = { ...operation };
|
||||||
|
newValues[field.name] = e.target.value;
|
||||||
|
newValues[`${field.name}Valid`] = true;
|
||||||
|
setOperation(newValues);
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const options = field.options;
|
||||||
|
return (
|
||||||
|
<FormField label={field.label}>
|
||||||
|
{field.type === "input" ? (
|
||||||
|
<FormInput props={commonProps} />
|
||||||
|
) : (
|
||||||
|
<FormSelect props={commonProps} options={options} />
|
||||||
|
)}
|
||||||
|
</FormField>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<FormBox title={t("cabinetMaintenance")}>
|
<FormBox title={t("lockerMaintenance")}>
|
||||||
<div className="p-2 pt-7">
|
<FieldsWrapper>{formFields.map(renderField)}</FieldsWrapper>
|
||||||
<div className="flex">
|
|
||||||
<label className="mr-4 text-lg text-black dark:text-primary-dark w-[10%]">
|
|
||||||
{t("operation")}
|
|
||||||
</label>
|
|
||||||
<div className="w-full">
|
|
||||||
<select
|
|
||||||
className={clsx(
|
|
||||||
"w-1/5 h-10 px-2 rounded-full dark:bg-grey dark:text-primary-dark border-2 focus:outline-grey border-grey",
|
|
||||||
!operation.valid && "border-error"
|
|
||||||
)}
|
|
||||||
onChange={(e) =>
|
|
||||||
setOperation({ value: e.target.value, valid: true })
|
|
||||||
}
|
|
||||||
defaultValue={operation.value}
|
|
||||||
value={operation.value}
|
|
||||||
>
|
|
||||||
<option value="" disabled>
|
|
||||||
{t("select")}
|
|
||||||
</option>
|
|
||||||
<option value="status">{t("changeStatus")}</option>
|
|
||||||
<option value="key-swap">{t("keySwap")}</option>
|
|
||||||
</select>
|
|
||||||
<AnimatePresence initial={false}>
|
|
||||||
{!operation.valid && (
|
|
||||||
<motion.div
|
|
||||||
className="w-1/5 text-sm text-error ml-3 pt-1"
|
|
||||||
initial={{ opacity: 0, scale: 0 }}
|
|
||||||
animate={{ opacity: 1, scale: 1 }}
|
|
||||||
exit={{ opacity: 0, scale: 0 }}
|
|
||||||
key="cabinetIdError"
|
|
||||||
>
|
|
||||||
Invalid Operation
|
|
||||||
</motion.div>
|
|
||||||
)}
|
|
||||||
</AnimatePresence>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<Button text={t("next")} onClick={(e) => handleNext(e)} />
|
<Button text={t("next")} onClick={(e) => handleNext(e)} />
|
||||||
</FormBox>
|
</FormBox>
|
||||||
</div>
|
</div>
|
||||||
|
@ -125,17 +125,11 @@ function LockerStatus() {
|
|||||||
<AnimatePresence>
|
<AnimatePresence>
|
||||||
{notification.message !== "" && <Notification {...notification} />}
|
{notification.message !== "" && <Notification {...notification} />}
|
||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
<div className="relative">
|
|
||||||
{notification.type === "success" && (
|
<FormBox title={t("lockerStatus")}>
|
||||||
<div className="absolute inset-0 bg-[#fff]/50 z-10 rounded-3xl" />
|
<FieldsWrapper>{formFields.map(renderField)}</FieldsWrapper>
|
||||||
)}
|
<Button text={t("submit")} onClick={handleSubmit} />
|
||||||
<FormBox title={t("lockerStatus")}>
|
</FormBox>
|
||||||
<FieldsWrapper>
|
|
||||||
{formFields.map(renderField)}
|
|
||||||
</FieldsWrapper>
|
|
||||||
<Button text={t("submit")} onClick={handleSubmit} />
|
|
||||||
</FormBox>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user