Skip to content

Enhance payment system #3112

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 19 commits into from
Jun 18, 2025
Merged
Show file tree
Hide file tree
Changes from 18 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 @@ -10,8 +10,6 @@
CardHeader,
CardTitle,
} from '@tuturuuu/ui/card';
import { Progress } from '@tuturuuu/ui/progress';
import { Separator } from '@tuturuuu/ui/separator';
import {
BrainIcon,
CheckCircleIcon,
Expand All @@ -21,7 +19,9 @@
TrendingUpIcon,
XCircleIcon,
ZapIcon,
} from 'lucide-react';
} from '@tuturuuu/ui/icons';
import { Progress } from '@tuturuuu/ui/progress';
import { Separator } from '@tuturuuu/ui/separator';

Check warning on line 24 in apps/calendar/src/app/[locale]/(root)/scheduler/components/AlgorithmInsights.tsx

View check run for this annotation

Codecov / codecov/patch

apps/calendar/src/app/[locale]/(root)/scheduler/components/AlgorithmInsights.tsx#L22-L24

Added lines #L22 - L24 were not covered by tests
import { useMemo } from 'react';

interface AlgorithmInsightsProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,16 @@
CardHeader,
CardTitle,
} from '@tuturuuu/ui/card';
import { Tooltip, TooltipContent, TooltipTrigger } from '@tuturuuu/ui/tooltip';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
import {
AlertTriangleIcon,
CalendarIcon,
ClockIcon,
SparklesIcon,
TrendingUpIcon,
} from 'lucide-react';
} from '@tuturuuu/ui/icons';
import { Tooltip, TooltipContent, TooltipTrigger } from '@tuturuuu/ui/tooltip';
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';

Check warning on line 21 in apps/calendar/src/app/[locale]/(root)/scheduler/components/ScheduleDisplay.tsx

View check run for this annotation

Codecov / codecov/patch

apps/calendar/src/app/[locale]/(root)/scheduler/components/ScheduleDisplay.tsx#L18-L21

Added lines #L18 - L21 were not covered by tests
import { useMemo } from 'react';

dayjs.extend(relativeTime);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@
CardHeader,
CardTitle,
} from '@tuturuuu/ui/card';
import {
CalendarIcon,
CheckCircleIcon,
ClockIcon,
PlusIcon,
Trash2Icon,
ZapIcon,
} from '@tuturuuu/ui/icons';

Check warning on line 20 in apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskList.tsx

View check run for this annotation

Codecov / codecov/patch

apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskList.tsx#L13-L20

Added lines #L13 - L20 were not covered by tests
import { Input } from '@tuturuuu/ui/input';
import { Label } from '@tuturuuu/ui/label';
import { Progress } from '@tuturuuu/ui/progress';
Expand All @@ -22,14 +30,6 @@
} from '@tuturuuu/ui/select';
import { Tooltip, TooltipContent, TooltipTrigger } from '@tuturuuu/ui/tooltip';
import dayjs from 'dayjs';
import {
CalendarIcon,
CheckCircleIcon,
ClockIcon,
PlusIcon,
Trash2Icon,
ZapIcon,
} from 'lucide-react';
import { useMemo } from 'react';

interface TaskListProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
DialogHeader,
DialogTitle,
} from '@tuturuuu/ui/dialog';
import { CalendarIcon, ClockIcon, PlusIcon, TagIcon } from '@tuturuuu/ui/icons';

Check warning on line 13 in apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx

View check run for this annotation

Codecov / codecov/patch

apps/calendar/src/app/[locale]/(root)/scheduler/components/TaskModal.tsx#L13

Added line #L13 was not covered by tests
import { Input } from '@tuturuuu/ui/input';
import { Label } from '@tuturuuu/ui/label';
import {
Expand All @@ -22,7 +23,6 @@
import { Separator } from '@tuturuuu/ui/separator';
import { Textarea } from '@tuturuuu/ui/textarea';
import dayjs from 'dayjs';
import { CalendarIcon, ClockIcon, PlusIcon, TagIcon } from 'lucide-react';
import { useState } from 'react';

interface TaskModalProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
TrendingUpIcon,
UsersIcon,
ZapIcon,
} from 'lucide-react';
} from '@tuturuuu/ui/icons';

Check warning on line 27 in apps/calendar/src/app/[locale]/(root)/scheduler/components/TemplateScenarios.tsx

View check run for this annotation

Codecov / codecov/patch

apps/calendar/src/app/[locale]/(root)/scheduler/components/TemplateScenarios.tsx#L27

Added line #L27 was not covered by tests

interface TemplateScenarioProps {
onLoadTemplate: (template: TemplateScenario) => void;
Expand Down
12 changes: 6 additions & 6 deletions apps/calendar/src/app/[locale]/(root)/scheduler/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,18 @@
CardHeader,
CardTitle,
} from '@tuturuuu/ui/card';
import { Input } from '@tuturuuu/ui/input';
import { Label } from '@tuturuuu/ui/label';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@tuturuuu/ui/tabs';
import { TooltipProvider } from '@tuturuuu/ui/tooltip';
import dayjs from 'dayjs';
import {
BrainIcon,
CalendarIcon,
ClockIcon,
SettingsIcon,
SparklesIcon,
} from 'lucide-react';
} from '@tuturuuu/ui/icons';
import { Input } from '@tuturuuu/ui/input';
import { Label } from '@tuturuuu/ui/label';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@tuturuuu/ui/tabs';
import { TooltipProvider } from '@tuturuuu/ui/tooltip';
import dayjs from 'dayjs';

Check warning on line 39 in apps/calendar/src/app/[locale]/(root)/scheduler/page.tsx

View check run for this annotation

Codecov / codecov/patch

apps/calendar/src/app/[locale]/(root)/scheduler/page.tsx#L34-L39

Added lines #L34 - L39 were not covered by tests
import { useState } from 'react';

function SchedulerPage() {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
set check_function_bodies = off;

CREATE OR REPLACE FUNCTION public.check_ws_creator(ws_id uuid)
RETURNS boolean
LANGUAGE plpgsql
AS $function$BEGIN
RETURN (
(
SELECT creator_id FROM public.workspaces WHERE id = check_ws_creator.ws_id
) = auth.uid()
AND NOT EXISTS (
SELECT 1 FROM public.workspace_subscription
WHERE public.workspace_subscription.ws_id = check_ws_creator.ws_id
)
);
END;$function$
;

drop policy "only allow owner of the user to buy subscription" on "public"."workspace_subscription";

create policy "only allow owner of the user to buy subscription"
on "public"."workspace_subscription"
as permissive
for insert
to authenticated
with check ((EXISTS ( SELECT 1
FROM workspaces
WHERE ((workspaces.id = workspace_subscription.ws_id) AND (workspaces.creator_id = auth.uid())))));

drop policy "allow select for users that are in the workspace" on "public"."workspace_subscription";

create policy "allow select for users that are in the workspace"
on "public"."workspace_subscription"
as permissive
for select
to authenticated
using ((EXISTS ( SELECT 1
FROM workspace_members wm
WHERE ((wm.user_id = auth.uid()) AND (wm.ws_id = workspace_subscription.ws_id)))));

create policy "allow delete access for creator workspace"
on "public"."workspace_subscription"
as permissive
for delete
to authenticated
using ((EXISTS ( SELECT 1
FROM workspaces
WHERE ((workspaces.id = workspace_subscription.ws_id) AND (workspaces.creator_id = auth.uid())))));
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
create table "public"."workspace_subscription_products" (
"id" uuid not null,
"created_at" timestamp with time zone not null default now(),
"name" text,
"description" text,
"price" real,
"recurring_interval" text default 'month'::text
);

alter table "public"."workspace_subscription" add column "product_id" uuid;

CREATE UNIQUE INDEX workspace_subscription_products_pkey ON public.workspace_subscription_products USING btree (id);

alter table "public"."workspace_subscription_products" add constraint "workspace_subscription_products_pkey" PRIMARY KEY using index "workspace_subscription_products_pkey";

alter table "public"."workspace_subscription" add constraint "workspace_subscription_product_id_fkey" FOREIGN KEY (product_id) REFERENCES workspace_subscription_products(id) not valid;

alter table "public"."workspace_subscription" validate constraint "workspace_subscription_product_id_fkey";

grant delete on table "public"."workspace_subscription_products" to "anon";

grant insert on table "public"."workspace_subscription_products" to "anon";

grant references on table "public"."workspace_subscription_products" to "anon";

grant select on table "public"."workspace_subscription_products" to "anon";

grant trigger on table "public"."workspace_subscription_products" to "anon";

grant truncate on table "public"."workspace_subscription_products" to "anon";

grant update on table "public"."workspace_subscription_products" to "anon";

grant delete on table "public"."workspace_subscription_products" to "authenticated";

grant insert on table "public"."workspace_subscription_products" to "authenticated";

grant references on table "public"."workspace_subscription_products" to "authenticated";

grant select on table "public"."workspace_subscription_products" to "authenticated";

grant trigger on table "public"."workspace_subscription_products" to "authenticated";

grant truncate on table "public"."workspace_subscription_products" to "authenticated";

grant update on table "public"."workspace_subscription_products" to "authenticated";

grant delete on table "public"."workspace_subscription_products" to "service_role";

grant insert on table "public"."workspace_subscription_products" to "service_role";

grant references on table "public"."workspace_subscription_products" to "service_role";

grant select on table "public"."workspace_subscription_products" to "service_role";

grant trigger on table "public"."workspace_subscription_products" to "service_role";

grant truncate on table "public"."workspace_subscription_products" to "service_role";

grant update on table "public"."workspace_subscription_products" to "service_role";


12 changes: 12 additions & 0 deletions apps/db/supabase/migrations/20250618161718_new_migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
alter table "public"."workspace_subscription_products" enable row level security;


create policy "allow view for all products"
on "public"."workspace_subscription_products"
as permissive
for select
to authenticated
using (true);



2 changes: 1 addition & 1 deletion apps/upskii/src/components/request-education-banner.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
'use client';

import { RequestAccessButton } from './request-access-button';
import { BookOpenText, Sparkles } from '@tuturuuu/ui/icons';
import clsx from 'clsx';

Check warning on line 5 in apps/upskii/src/components/request-education-banner.tsx

View check run for this annotation

Codecov / codecov/patch

apps/upskii/src/components/request-education-banner.tsx#L4-L5

Added lines #L4 - L5 were not covered by tests
import { BookOpenText, Sparkles } from 'lucide-react';

interface EducationBannerProps {
workspaceName: string;
Expand Down
2 changes: 1 addition & 1 deletion apps/web/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -44,4 +44,4 @@ NEXT_PUBLIC_PROXY_API_KEY=YOUR_NEXT_PUBLIC_PROXY_API_KEY

# Payment Polar.sh
POLAR_WEBHOOK_SECRET=YOUR_POLAR_WEBHOOK_SECRET
NEXT_PUBLIC_POLAR_ACCESS_TOKEN=YOUR_NEXT_PUBLIC_POLAR_ACCESS_TOKEN
NEXT_PUBLIC_POLAR_ACCESS_TOKEN=YOUR_NEXT_PUBLIC_POLAR_ACCESS_TOKEN
Loading