TorbatYar/frontend/modules/commercial/components/DomainPolicyPanel.tsx
2026-07-28 20:39:10 +03:30

76 lines
2.8 KiB
TypeScript
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client";
import type { DomainPolicyResult } from "../types";
import { FeatureLock } from "./FeatureLock";
import { CommercialEmptyState } from "./CommercialEmptyState";
export function DomainPolicyPanel({
unlocked,
policy,
tenantId,
}: {
unlocked: boolean;
policy?: DomainPolicyResult | null;
tenantId?: string;
}) {
const dns = policy?.dns_instructions || [];
const reason = policy?.reason;
return (
<section className="space-y-3">
{!unlocked ? (
<div className="rounded-2xl border border-sky-200 bg-sky-50 px-4 py-3 text-sm text-sky-900">
{reason ||
"قبل از اشتراک فعال فقط زیردامنه پلتفرم در دسترس است (سیاست دامنه)."}
</div>
) : (
<div className="rounded-2xl border border-emerald-200 bg-emerald-50 px-4 py-3 text-sm text-emerald-900">
دامنه اختصاصی بر اساس سیاست باز است.
{policy?.ssl_ready ? " · SSL آماده" : " · SSL از سیاست/بک‌اند"}
{policy?.verification_state
? ` · وضعیت تأیید: ${policy.verification_state}`
: null}
</div>
)}
<FeatureLock
locked={!unlocked}
tenantId={tenantId}
featureKey={tenantId ? "custom_domain" : undefined}
reason={reason}
fallback={
<div className="rounded-xl border border-dashed border-gray-200 bg-gray-50 p-4 text-sm text-gray-600">
دستورالعمل DNS و SSL تا باز شدن سیاست نمایش داده نمیشود قفل با دلیل ارتقا.
</div>
}
>
{dns.length ? (
<ul className="space-y-2 rounded-2xl border border-gray-100 bg-white p-4 text-sm">
<li className="font-semibold text-secondary">دستورالعمل DNS</li>
{dns.map((row, idx) => {
if (typeof row === "string") {
return (
<li key={idx} className="font-mono text-xs text-gray-600" dir="ltr">
{row}
</li>
);
}
return (
<li key={idx} className="font-mono text-xs text-gray-600" dir="ltr">
{[row.type, row.host, row.value].filter(Boolean).join(" · ")}
{row.note ? `${row.note}` : ""}
</li>
);
})}
</ul>
) : (
<CommercialEmptyState
title="دستورالعمل DNS از سیاست"
description="پس از ثبت دامنه، رکوردهای DNS از policy parameters می‌آیند."
/>
)}
</FeatureLock>
</section>
);
}