feat: render service description as structured sections from backend
Matches the admin's new repeater (emoji + title + items per section) instead of a single plain-text block. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -57,7 +57,7 @@ const ModalBuy = ({ isOpen, setIsOpen, configId }: ModalBuyProps) => {
|
|||||||
const hasExtraDescription = Boolean(
|
const hasExtraDescription = Boolean(
|
||||||
data?.data?.result?.has_extra_description
|
data?.data?.result?.has_extra_description
|
||||||
);
|
);
|
||||||
const extraDescription = data?.data?.result?.extra_description ?? "";
|
const extraDescriptionSections = data?.data?.result?.extra_description ?? [];
|
||||||
const advancedVerificationFromApi =
|
const advancedVerificationFromApi =
|
||||||
data?.data?.result?.requires_advanced_verification;
|
data?.data?.result?.requires_advanced_verification;
|
||||||
const hasAdvancedVerificationApiFlag =
|
const hasAdvancedVerificationApiFlag =
|
||||||
@@ -246,7 +246,7 @@ const ModalBuy = ({ isOpen, setIsOpen, configId }: ModalBuyProps) => {
|
|||||||
<ModalDnsServiceInfo
|
<ModalDnsServiceInfo
|
||||||
isOpen={isInfoOpen}
|
isOpen={isInfoOpen}
|
||||||
setIsOpen={setIsInfoOpen}
|
setIsOpen={setIsInfoOpen}
|
||||||
description={extraDescription}
|
sections={extraDescriptionSections}
|
||||||
/>
|
/>
|
||||||
<MuiModal
|
<MuiModal
|
||||||
isOpenModal={isOpen}
|
isOpenModal={isOpen}
|
||||||
|
|||||||
@@ -1,16 +1,40 @@
|
|||||||
import { Dispatch, SetStateAction } from "react";
|
import { Dispatch, SetStateAction } from "react";
|
||||||
import MuiModal from "../../../../../common/modal";
|
import MuiModal from "../../../../../common/modal";
|
||||||
|
|
||||||
|
interface DescriptionSection {
|
||||||
|
emoji?: string;
|
||||||
|
title?: string;
|
||||||
|
items?: string[];
|
||||||
|
}
|
||||||
|
|
||||||
interface ModalDnsServiceInfoProps {
|
interface ModalDnsServiceInfoProps {
|
||||||
isOpen: boolean;
|
isOpen: boolean;
|
||||||
setIsOpen: Dispatch<SetStateAction<boolean>>;
|
setIsOpen: Dispatch<SetStateAction<boolean>>;
|
||||||
description?: string | null;
|
sections?: DescriptionSection[];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Section = ({
|
||||||
|
emoji,
|
||||||
|
title,
|
||||||
|
children,
|
||||||
|
}: {
|
||||||
|
emoji?: string;
|
||||||
|
title?: string;
|
||||||
|
children: React.ReactNode;
|
||||||
|
}) => (
|
||||||
|
<div className="w-full flex flex-col gap-2 bg-gray-900/60 border border-gray-700 rounded-lg p-3">
|
||||||
|
<div className="flex flex-row-reverse items-center gap-1.5 text-secondTheme font-bold">
|
||||||
|
{emoji && <span>{emoji}</span>}
|
||||||
|
{title && <span>{title}</span>}
|
||||||
|
</div>
|
||||||
|
{children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
const ModalDnsServiceInfo = ({
|
const ModalDnsServiceInfo = ({
|
||||||
isOpen,
|
isOpen,
|
||||||
setIsOpen,
|
setIsOpen,
|
||||||
description,
|
sections,
|
||||||
}: ModalDnsServiceInfoProps) => {
|
}: ModalDnsServiceInfoProps) => {
|
||||||
return (
|
return (
|
||||||
<MuiModal
|
<MuiModal
|
||||||
@@ -20,9 +44,27 @@ const ModalDnsServiceInfo = ({
|
|||||||
nameService="توضیحات سرویس"
|
nameService="توضیحات سرویس"
|
||||||
>
|
>
|
||||||
<div className="w-full h-full flex flex-col gap-3 max-sm:text-xs max-md:text-sm text-base">
|
<div className="w-full h-full flex flex-col gap-3 max-sm:text-xs max-md:text-sm text-base">
|
||||||
<p className="w-full whitespace-pre-line leading-7 text-gray-200 text-start">
|
{(sections ?? []).map((section, sectionIndex) => (
|
||||||
{description}
|
<Section
|
||||||
</p>
|
key={sectionIndex}
|
||||||
|
emoji={section.emoji}
|
||||||
|
title={section.title}
|
||||||
|
>
|
||||||
|
{section.items && section.items.length > 0 && (
|
||||||
|
<ul className="flex flex-col gap-1.5">
|
||||||
|
{section.items.map((item, itemIndex) => (
|
||||||
|
<li
|
||||||
|
key={itemIndex}
|
||||||
|
className="flex flex-row-reverse items-start gap-2 text-gray-200"
|
||||||
|
>
|
||||||
|
<span className="shrink-0">🔹</span>
|
||||||
|
<span className="text-start leading-6">{item}</span>
|
||||||
|
</li>
|
||||||
|
))}
|
||||||
|
</ul>
|
||||||
|
)}
|
||||||
|
</Section>
|
||||||
|
))}
|
||||||
</div>
|
</div>
|
||||||
</MuiModal>
|
</MuiModal>
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user