mirror of
https://github.com/fosrl/pangolin.git
synced 2026-03-01 16:26:39 +00:00
🛂 check for subscription status
This commit is contained in:
@@ -43,6 +43,7 @@ import {
|
|||||||
} from "./Credenza";
|
} from "./Credenza";
|
||||||
import { usePaidStatus } from "@app/hooks/usePaidStatus";
|
import { usePaidStatus } from "@app/hooks/usePaidStatus";
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
|
import { PaidFeaturesAlert } from "./PaidFeaturesAlert";
|
||||||
|
|
||||||
export type AuthPageCustomizationProps = {
|
export type AuthPageCustomizationProps = {
|
||||||
orgId: string;
|
orgId: string;
|
||||||
@@ -86,7 +87,7 @@ export default function AuthPageBrandingForm({
|
|||||||
}: AuthPageCustomizationProps) {
|
}: AuthPageCustomizationProps) {
|
||||||
const env = useEnvContext();
|
const env = useEnvContext();
|
||||||
const api = createApiClient(env);
|
const api = createApiClient(env);
|
||||||
const { hasSaasSubscription } = usePaidStatus();
|
const { isPaidUser } = usePaidStatus();
|
||||||
|
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
@@ -117,14 +118,15 @@ export default function AuthPageBrandingForm({
|
|||||||
branding?.resourceSubtitle ??
|
branding?.resourceSubtitle ??
|
||||||
`Choose your preferred authentication method for {{resourceName}}`,
|
`Choose your preferred authentication method for {{resourceName}}`,
|
||||||
primaryColor: branding?.primaryColor ?? `#f36117` // default pangolin primary color
|
primaryColor: branding?.primaryColor ?? `#f36117` // default pangolin primary color
|
||||||
}
|
},
|
||||||
|
disabled: !isPaidUser
|
||||||
});
|
});
|
||||||
|
|
||||||
async function updateBranding() {
|
async function updateBranding() {
|
||||||
const isValid = await form.trigger();
|
const isValid = await form.trigger();
|
||||||
const brandingData = form.getValues();
|
const brandingData = form.getValues();
|
||||||
|
|
||||||
if (!isValid) return;
|
if (!isValid || !isPaidUser) return;
|
||||||
try {
|
try {
|
||||||
const updateRes = await api.put(
|
const updateRes = await api.put(
|
||||||
`/org/${orgId}/login-page-branding`,
|
`/org/${orgId}/login-page-branding`,
|
||||||
@@ -154,6 +156,8 @@ export default function AuthPageBrandingForm({
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function deleteBranding() {
|
async function deleteBranding() {
|
||||||
|
if (!isPaidUser) return;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const updateRes = await api.delete(
|
const updateRes = await api.delete(
|
||||||
`/org/${orgId}/login-page-branding`
|
`/org/${orgId}/login-page-branding`
|
||||||
@@ -194,6 +198,8 @@ export default function AuthPageBrandingForm({
|
|||||||
</SettingsSectionDescription>
|
</SettingsSectionDescription>
|
||||||
</SettingsSectionHeader>
|
</SettingsSectionHeader>
|
||||||
|
|
||||||
|
<PaidFeaturesAlert />
|
||||||
|
|
||||||
<SettingsSectionBody>
|
<SettingsSectionBody>
|
||||||
<SettingsSectionForm>
|
<SettingsSectionForm>
|
||||||
<Form {...form}>
|
<Form {...form}>
|
||||||
@@ -293,7 +299,7 @@ export default function AuthPageBrandingForm({
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{hasSaasSubscription && (
|
{build === "saas" && (
|
||||||
<>
|
<>
|
||||||
<Separator />
|
<Separator />
|
||||||
|
|
||||||
@@ -446,7 +452,7 @@ export default function AuthPageBrandingForm({
|
|||||||
type="submit"
|
type="submit"
|
||||||
form="confirm-delete-branding-form"
|
form="confirm-delete-branding-form"
|
||||||
loading={isDeletingBranding}
|
loading={isDeletingBranding}
|
||||||
disabled={isDeletingBranding}
|
disabled={isDeletingBranding || !isPaidUser}
|
||||||
>
|
>
|
||||||
{t("authPageBrandingDeleteConfirm")}
|
{t("authPageBrandingDeleteConfirm")}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -460,7 +466,11 @@ export default function AuthPageBrandingForm({
|
|||||||
variant="destructive"
|
variant="destructive"
|
||||||
type="button"
|
type="button"
|
||||||
loading={isUpdatingBranding || isDeletingBranding}
|
loading={isUpdatingBranding || isDeletingBranding}
|
||||||
disabled={isUpdatingBranding || isDeletingBranding}
|
disabled={
|
||||||
|
isUpdatingBranding ||
|
||||||
|
isDeletingBranding ||
|
||||||
|
!isPaidUser
|
||||||
|
}
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
setIsDeleteModalOpen(true);
|
setIsDeleteModalOpen(true);
|
||||||
}}
|
}}
|
||||||
@@ -474,7 +484,11 @@ export default function AuthPageBrandingForm({
|
|||||||
type="submit"
|
type="submit"
|
||||||
form="auth-page-branding-form"
|
form="auth-page-branding-form"
|
||||||
loading={isUpdatingBranding || isDeletingBranding}
|
loading={isUpdatingBranding || isDeletingBranding}
|
||||||
disabled={isUpdatingBranding || isDeletingBranding}
|
disabled={
|
||||||
|
isUpdatingBranding ||
|
||||||
|
isDeletingBranding ||
|
||||||
|
!isPaidUser
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{t("saveAuthPageBranding")}
|
{t("saveAuthPageBranding")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -43,8 +43,8 @@ import DomainPicker from "@app/components/DomainPicker";
|
|||||||
import { finalizeSubdomainSanitize } from "@app/lib/subdomain-utils";
|
import { finalizeSubdomainSanitize } from "@app/lib/subdomain-utils";
|
||||||
import { InfoPopup } from "@app/components/ui/info-popup";
|
import { InfoPopup } from "@app/components/ui/info-popup";
|
||||||
import { Alert, AlertDescription } from "@app/components/ui/alert";
|
import { Alert, AlertDescription } from "@app/components/ui/alert";
|
||||||
import { useSubscriptionStatusContext } from "@app/hooks/useSubscriptionStatusContext";
|
|
||||||
import { build } from "@server/build";
|
import { build } from "@server/build";
|
||||||
|
import { usePaidStatus } from "@app/hooks/usePaidStatus";
|
||||||
|
|
||||||
// Auth page form schema
|
// Auth page form schema
|
||||||
const AuthPageFormSchema = z.object({
|
const AuthPageFormSchema = z.object({
|
||||||
@@ -74,7 +74,7 @@ function AuthPageSettings({
|
|||||||
const t = useTranslations();
|
const t = useTranslations();
|
||||||
const { env } = useEnvContext();
|
const { env } = useEnvContext();
|
||||||
|
|
||||||
const subscription = useSubscriptionStatusContext();
|
const { hasSaasSubscription } = usePaidStatus();
|
||||||
|
|
||||||
// Auth page domain state
|
// Auth page domain state
|
||||||
const [loginPage, setLoginPage] = useState(defaultLoginPage);
|
const [loginPage, setLoginPage] = useState(defaultLoginPage);
|
||||||
@@ -176,10 +176,7 @@ function AuthPageSettings({
|
|||||||
try {
|
try {
|
||||||
// Handle auth page domain
|
// Handle auth page domain
|
||||||
if (data.authPageDomainId) {
|
if (data.authPageDomainId) {
|
||||||
if (
|
if (build === "enterprise" || hasSaasSubscription) {
|
||||||
build === "enterprise" ||
|
|
||||||
(build === "saas" && subscription?.subscribed)
|
|
||||||
) {
|
|
||||||
const sanitizedSubdomain = data.authPageSubdomain
|
const sanitizedSubdomain = data.authPageSubdomain
|
||||||
? finalizeSubdomainSanitize(data.authPageSubdomain)
|
? finalizeSubdomainSanitize(data.authPageSubdomain)
|
||||||
: "";
|
: "";
|
||||||
@@ -284,7 +281,7 @@ function AuthPageSettings({
|
|||||||
</SettingsSectionDescription>
|
</SettingsSectionDescription>
|
||||||
</SettingsSectionHeader>
|
</SettingsSectionHeader>
|
||||||
<SettingsSectionBody>
|
<SettingsSectionBody>
|
||||||
{build === "saas" && !subscription?.subscribed ? (
|
{!hasSaasSubscription ? (
|
||||||
<Alert variant="info" className="mb-6">
|
<Alert variant="info" className="mb-6">
|
||||||
<AlertDescription>
|
<AlertDescription>
|
||||||
{t("orgAuthPageDisabled")}{" "}
|
{t("orgAuthPageDisabled")}{" "}
|
||||||
@@ -368,6 +365,7 @@ function AuthPageSettings({
|
|||||||
onClick={() =>
|
onClick={() =>
|
||||||
setEditDomainOpen(true)
|
setEditDomainOpen(true)
|
||||||
}
|
}
|
||||||
|
disabled={!hasSaasSubscription}
|
||||||
>
|
>
|
||||||
{form.watch("authPageDomainId")
|
{form.watch("authPageDomainId")
|
||||||
? t("changeDomain")
|
? t("changeDomain")
|
||||||
@@ -381,6 +379,9 @@ function AuthPageSettings({
|
|||||||
onClick={
|
onClick={
|
||||||
clearAuthPageDomain
|
clearAuthPageDomain
|
||||||
}
|
}
|
||||||
|
disabled={
|
||||||
|
!hasSaasSubscription
|
||||||
|
}
|
||||||
>
|
>
|
||||||
<Trash2 size="14" />
|
<Trash2 size="14" />
|
||||||
</Button>
|
</Button>
|
||||||
@@ -398,8 +399,7 @@ function AuthPageSettings({
|
|||||||
|
|
||||||
{env.flags.usePangolinDns &&
|
{env.flags.usePangolinDns &&
|
||||||
(build === "enterprise" ||
|
(build === "enterprise" ||
|
||||||
(build === "saas" &&
|
!hasSaasSubscription) &&
|
||||||
subscription?.subscribed)) &&
|
|
||||||
loginPage?.domainId &&
|
loginPage?.domainId &&
|
||||||
loginPage?.fullDomain &&
|
loginPage?.fullDomain &&
|
||||||
!hasUnsavedChanges && (
|
!hasUnsavedChanges && (
|
||||||
@@ -425,7 +425,11 @@ function AuthPageSettings({
|
|||||||
type="submit"
|
type="submit"
|
||||||
form="auth-page-settings-form"
|
form="auth-page-settings-form"
|
||||||
loading={isSubmitting}
|
loading={isSubmitting}
|
||||||
disabled={isSubmitting || !hasUnsavedChanges}
|
disabled={
|
||||||
|
isSubmitting ||
|
||||||
|
!hasUnsavedChanges ||
|
||||||
|
!hasSaasSubscription
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{t("saveAuthPageDomain")}
|
{t("saveAuthPageDomain")}
|
||||||
</Button>
|
</Button>
|
||||||
@@ -474,7 +478,7 @@ function AuthPageSettings({
|
|||||||
handleDomainSelection(selectedDomain);
|
handleDomainSelection(selectedDomain);
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
disabled={!selectedDomain}
|
disabled={!selectedDomain || !hasSaasSubscription}
|
||||||
>
|
>
|
||||||
{t("selectDomain")}
|
{t("selectDomain")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
Reference in New Issue
Block a user