Skip to content
This repository was archived by the owner on Feb 23, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ import ImageUpload from '@/components/misc/form/imageUpload';
import { Checkbox } from '@/components/ui/checkbox';
import { Label } from '@/components/ui/label';
import { LuRadio } from 'react-icons/lu';
import { cn } from '@/lib/utils/utils';
import FeatureButton from '@/components/ui/feature-button';
import { useSubscription } from '@/lib/hooks/useSubscription';

const CreateLivestreamModal = ({
Expand Down
12 changes: 9 additions & 3 deletions packages/app/app/studio/[organization]/(root)/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ export default async function OrganizationPage({

if (!organization) return notFound();

const hasFeatures = isFeatureAvailable(
organization.expirationDate,
organization.currentStages,
organization.paidStages
);

// Calculate the start of the current day
const startOfDay = new Date();
startOfDay.setHours(0, 0, 0, 0);
Expand All @@ -33,7 +39,7 @@ export default async function OrganizationPage({
<div className="flex w-full flex-col p-2">
<h2 className="text-lg font-bold">Create</h2>
<div className="flex items-center gap-4 p-4">
{isFeatureAvailable(organization.expirationDate) ? (
{hasFeatures ? (
<CreateLivestreamModal
variant="primary"
show={searchParams?.show}
Expand All @@ -50,7 +56,7 @@ export default async function OrganizationPage({
</FeatureButton>
)}

{isFeatureAvailable(organization.expirationDate) ? (
{hasFeatures ? (
<UploadVideoDialog organizationId={organization._id.toString()} />
) : (
<FeatureButton
Expand All @@ -63,7 +69,7 @@ export default async function OrganizationPage({
</FeatureButton>
)}

{isFeatureAvailable(organization.expirationDate) ? (
{hasFeatures ? (
<Link
href={`/studio/${organization.slug}/library?layout=list&page=1&limit=20&clipable=true`}
>
Expand Down
10 changes: 8 additions & 2 deletions packages/app/components/Layout/NavbarStudio.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ const NavbarStudio = ({
return notFound();
}

const hasFeatures = isFeatureAvailable(
organization.expirationDate,
organization.currentStages,
organization.paidStages
);

return (
<NavigationMenu className="h-[72px] w-full sticky top-0 flex items-center p-2 px-4 bg-white md:hidden lg:flex z-[30]">
<Image
Expand All @@ -48,7 +54,7 @@ const NavbarStudio = ({
/>
</div>
<div className="flex items-center justify-end space-x-2">
{isFeatureAvailable(organization.expirationDate) ? (
{hasFeatures ? (
<CreateLivestreamModal
variant="outline"
organization={organization}
Expand All @@ -63,7 +69,7 @@ const NavbarStudio = ({
Create Livestream
</FeatureButton>
)}
{isFeatureAvailable(organization.expirationDate) ? (
{hasFeatures ? (
<UploadVideoDialog organizationId={organization._id.toString()} />
) : (
<FeatureButton
Expand Down
6 changes: 5 additions & 1 deletion packages/app/lib/services/organizationService.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ export async function fetchOrganization({
const response = await fetch(
`${apiUrl()}/organizations/${
organizationId ? organizationId : organizationSlug
}`
}`,
{
cache: 'no-store',
next: { revalidate: 0 }
}
);
const data = (await response.json()).data;

Expand Down
8 changes: 4 additions & 4 deletions packages/app/lib/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}

export const isFeatureAvailable = (expirationDate: Date | null | undefined) => {
return (
expirationDate && new Date(expirationDate).getTime() > new Date().getTime()
);
export const isFeatureAvailable = (expirationDate: Date | null | undefined, currentStages?: number, paidStages?: number) => {
const hasValidSubscription = expirationDate && new Date(expirationDate).getTime() > new Date().getTime();
const hasAvailableStages = typeof currentStages === 'undefined' || typeof paidStages === 'undefined' || currentStages < paidStages;
return hasValidSubscription && hasAvailableStages;
};

export const selectOptionFocusHandle = (
Expand Down
Loading