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:
2026-09-22 00:14:02 +03:30
parent 897146ee12
commit e1a84105c7

View File

@@ -47,6 +47,7 @@ const ModalBuy = ({ isOpen, setIsOpen, configId }: ModalBuyProps) => {
const [isInfoOpen, setIsInfoOpen] = useState(false); const [isInfoOpen, setIsInfoOpen] = useState(false);
const [needsShahkarVerification, setNeedsShahkarVerification] = useState(false); const [needsShahkarVerification, setNeedsShahkarVerification] = useState(false);
const [nationalCode, setNationalCode] = useState(""); const [nationalCode, setNationalCode] = useState("");
const [hasReadDescription, setHasReadDescription] = useState(false);
const payablePrice = toNumber( const payablePrice = toNumber(
price === 0 ? data?.data?.result?.price || 0 : price price === 0 ? data?.data?.result?.price || 0 : price
); );
@@ -103,6 +104,7 @@ const ModalBuy = ({ isOpen, setIsOpen, configId }: ModalBuyProps) => {
setPrice(0); setPrice(0);
setNeedsShahkarVerification(false); setNeedsShahkarVerification(false);
setNationalCode(""); setNationalCode("");
setHasReadDescription(false);
} }
}, [isOpen, setFieldValue]); }, [isOpen, setFieldValue]);
const mutation = useMutation({ const mutation = useMutation({
@@ -194,6 +196,11 @@ const ModalBuy = ({ isOpen, setIsOpen, configId }: ModalBuyProps) => {
return; return;
} }
if (hasExtraDescription && !hasReadDescription) {
toast.error("لطفا ابتدا توضیحات سرویس را مطالعه و تایید کنید");
return;
}
if (needsShahkarVerification && nationalCode.trim().length !== 10) { if (needsShahkarVerification && nationalCode.trim().length !== 10) {
toast.error("لطفا کد ملی ۱۰ رقمی را به‌درستی وارد کنید"); toast.error("لطفا کد ملی ۱۰ رقمی را به‌درستی وارد کنید");
return; return;
@@ -282,7 +289,8 @@ const ModalBuy = ({ isOpen, setIsOpen, configId }: ModalBuyProps) => {
submitOnClick={submitHandler} submitOnClick={submitHandler}
disabled={ disabled={
isLoading || isLoading ||
isFetching isFetching ||
(hasExtraDescription && !hasReadDescription)
} }
nameService={ nameService={
isLoading || isFetching isLoading || isFetching
@@ -337,6 +345,17 @@ const ModalBuy = ({ isOpen, setIsOpen, configId }: ModalBuyProps) => {
توضیحات سرویس توضیحات سرویس
</Button> </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"> <Alert type="danger">
{" "} {" "}
کاربر گرامی لطفا از خاموش بودن vpn خود اطمینان حاصل فرمایید تا در کاربر گرامی لطفا از خاموش بودن vpn خود اطمینان حاصل فرمایید تا در