feat: require reading the service description before purchase
For categories with has_extra_description, the buy button now stays disabled until the user ticks "توضیحات سرویس را مطالعه کردم" — mirrors the pattern used for the Shahkar/advanced-verification gates. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -47,6 +47,7 @@ const ModalBuy = ({ isOpen, setIsOpen, configId }: ModalBuyProps) => {
|
||||
const [isInfoOpen, setIsInfoOpen] = useState(false);
|
||||
const [needsShahkarVerification, setNeedsShahkarVerification] = useState(false);
|
||||
const [nationalCode, setNationalCode] = useState("");
|
||||
const [hasReadDescription, setHasReadDescription] = useState(false);
|
||||
const payablePrice = toNumber(
|
||||
price === 0 ? data?.data?.result?.price || 0 : price
|
||||
);
|
||||
@@ -103,6 +104,7 @@ const ModalBuy = ({ isOpen, setIsOpen, configId }: ModalBuyProps) => {
|
||||
setPrice(0);
|
||||
setNeedsShahkarVerification(false);
|
||||
setNationalCode("");
|
||||
setHasReadDescription(false);
|
||||
}
|
||||
}, [isOpen, setFieldValue]);
|
||||
const mutation = useMutation({
|
||||
@@ -194,6 +196,11 @@ const ModalBuy = ({ isOpen, setIsOpen, configId }: ModalBuyProps) => {
|
||||
return;
|
||||
}
|
||||
|
||||
if (hasExtraDescription && !hasReadDescription) {
|
||||
toast.error("لطفا ابتدا توضیحات سرویس را مطالعه و تایید کنید");
|
||||
return;
|
||||
}
|
||||
|
||||
if (needsShahkarVerification && nationalCode.trim().length !== 10) {
|
||||
toast.error("لطفا کد ملی ۱۰ رقمی را بهدرستی وارد کنید");
|
||||
return;
|
||||
@@ -281,8 +288,9 @@ const ModalBuy = ({ isOpen, setIsOpen, configId }: ModalBuyProps) => {
|
||||
submitText={data?.data?.result?.max_config === 0 ? undefined : "خرید"}
|
||||
submitOnClick={submitHandler}
|
||||
disabled={
|
||||
isLoading ||
|
||||
isFetching
|
||||
isLoading ||
|
||||
isFetching ||
|
||||
(hasExtraDescription && !hasReadDescription)
|
||||
}
|
||||
nameService={
|
||||
isLoading || isFetching
|
||||
@@ -337,6 +345,17 @@ const ModalBuy = ({ isOpen, setIsOpen, configId }: ModalBuyProps) => {
|
||||
توضیحات سرویس
|
||||
</Button>
|
||||
)}
|
||||
{hasExtraDescription && (
|
||||
<label className="w-full flex flex-row-reverse items-center gap-2 text-xs md:text-sm text-gray-300 cursor-pointer select-none">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={hasReadDescription}
|
||||
onChange={(e) => setHasReadDescription(e.target.checked)}
|
||||
className="w-4 h-4 accent-secondTheme"
|
||||
/>
|
||||
توضیحات سرویس را مطالعه کردم
|
||||
</label>
|
||||
)}
|
||||
<Alert type="danger">
|
||||
{" "}
|
||||
کاربر گرامی لطفا از خاموش بودن vpn خود اطمینان حاصل فرمایید تا در
|
||||
|
||||
Reference in New Issue
Block a user