Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | "use client";
import React, { useState, ChangeEvent, FormEvent } from "react";
import toast from "react-hot-toast";
import { Button } from "@/components/ui";
interface EditOrderProps {
order: {
status: string;
};
toggleModal: (value: boolean) => void;
}
const EditOrder: React.FC<EditOrderProps> = ({ order, toggleModal }) => {
const [currentStatus, setCurrentStatus] = useState<string>(order?.status);
const handleChange = (e: ChangeEvent<HTMLSelectElement>) => {
setCurrentStatus(e.target.value);
};
const handleSubmit = (e: FormEvent<HTMLButtonElement>) => {
e.preventDefault();
if (!currentStatus) {
toast.error("Please select a status");
return;
}
toggleModal(false);
};
return (
<div className="w-full px-10">
<p className="pb-2 font-medium text-dark">Order Status</p>
<div className="w-full">
<select
className="w-full rounded-[10px] border border-gray-3 bg-gray-1 text-dark py-3.5 px-5 text-custom-sm"
name="status"
id="status"
required
onChange={handleChange}
value={currentStatus}
>
<option value="processing">Processing</option>
<option value="on-hold">On Hold</option>
<option value="delivered">Delivered</option>
<option value="cancelled">Cancelled</option>
</select>
<Button
variant="primary"
size="md"
fullWidth
onClick={handleSubmit}
className="mt-5"
>
Save Changes
</Button>
</div>
</div>
);
};
export default EditOrder;
|