48 lines
1.3 KiB
JavaScript
48 lines
1.3 KiB
JavaScript
"use client";
|
|
|
|
import AppContext from "@ctx/AppContext";
|
|
import { useContext } from "react";
|
|
import { BottomSheet } from "react-spring-bottom-sheet";
|
|
import { toast } from "react-toastify";
|
|
|
|
const BottomSheetDeleteAddress = ({ id }) => {
|
|
const CTX = useContext(AppContext);
|
|
const cart = CTX.state.cart;
|
|
|
|
const handleDelete = async (id) => {
|
|
try {
|
|
const data = await Chapar.post(
|
|
`${process.env.NEXT_PUBLIC_API_URL}/user/address/${id}`
|
|
);
|
|
} catch ({ error, status }) {
|
|
toast.error(`${error?.response?.data?.message}`, {
|
|
position: "bottom-right",
|
|
closeOnClick: true,
|
|
});
|
|
}
|
|
};
|
|
|
|
return (
|
|
<BottomSheet
|
|
open={CTX.state.bottomSheetDeleteAddressOpen}
|
|
onDismiss={() => CTX.setBottomSheetDeleteAddressOpen(false)}
|
|
className={"z-50 relative"}
|
|
>
|
|
<div className="text-center p-3">
|
|
<p className="mb-0 text-sm pb-3">آیا از حذف آدرس اطمینان دارید ؟ </p>
|
|
</div>
|
|
|
|
<div className="xs:w-full lg:w-3/12 mx-auto p-3 ">
|
|
<button
|
|
className="btn bg-red-500 text-white text-sm w-full py-3 rounded-3xl"
|
|
onClick={() => handleDelete()}
|
|
>
|
|
حذف آدرس
|
|
</button>
|
|
</div>
|
|
</BottomSheet>
|
|
);
|
|
};
|
|
|
|
export default BottomSheetDeleteAddress;
|