Update authentication methods and UI components, remove redundant file
This commit accomplishes a few modifications including the elimination of `use-toast.tsx` due to redundancy. The authentication methods in `personal-accounts-server-actions.ts` were refactored to improve service integration and data handling. Additionally, UI components were updated for better readability and clarity. Cascading deletion was enabled in the `schema.sql` file for 'invited_by' reference.
This commit is contained in:
@@ -14,20 +14,28 @@
|
||||
"./components": "./src/components/index.ts"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"zod": "^3.22.4",
|
||||
"@kit/ui": "0.1.0",
|
||||
"@kit/stripe": "0.1.0",
|
||||
"@kit/billing": "0.1.0",
|
||||
"@kit/supabase": "^0.1.0",
|
||||
"@kit/shared": "^0.1.0",
|
||||
"lucide-react": "^0.361.0",
|
||||
"@supabase/supabase-js": "^2.39.8"
|
||||
"@kit/stripe": "0.1.0",
|
||||
"@kit/supabase": "^0.1.0",
|
||||
"@kit/ui": "0.1.0",
|
||||
"@supabase/supabase-js": "^2.39.8",
|
||||
"lucide-react": "^0.363.0",
|
||||
"zod": "^3.22.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/billing": "*",
|
||||
"@kit/eslint-config": "0.2.0",
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/shared": "*",
|
||||
"@kit/stripe": "*",
|
||||
"@kit/supabase": "*",
|
||||
"@kit/tailwind-config": "0.1.0",
|
||||
"@kit/tsconfig": "0.1.0"
|
||||
"@kit/tsconfig": "0.1.0",
|
||||
"@kit/ui": "*",
|
||||
"@supabase/supabase-js": "^2.39.8",
|
||||
"lucide-react": "^0.363.0",
|
||||
"zod": "^3.22.4"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
|
||||
@@ -5,29 +5,17 @@ import { LoadingOverlay } from '@kit/ui/loading-overlay';
|
||||
|
||||
type BillingProvider = Database['public']['Enums']['billing_provider'];
|
||||
|
||||
const Fallback = (
|
||||
<LoadingOverlay fullPage={false}>Loading Checkout...</LoadingOverlay>
|
||||
);
|
||||
const Fallback = <LoadingOverlay fullPage={false} />;
|
||||
|
||||
export function EmbeddedCheckout(
|
||||
props: React.PropsWithChildren<{
|
||||
checkoutToken: string;
|
||||
provider: BillingProvider;
|
||||
onClose?: () => void;
|
||||
}>,
|
||||
) {
|
||||
return <LazyCheckout {...props} />;
|
||||
}
|
||||
|
||||
function LazyCheckout(
|
||||
props: React.PropsWithChildren<{
|
||||
checkoutToken: string;
|
||||
provider: BillingProvider;
|
||||
onClose?: () => void;
|
||||
onClose: () => void;
|
||||
}>,
|
||||
) {
|
||||
const CheckoutComponent = useMemo(
|
||||
() => memo(loadCheckoutComponent(props.provider)),
|
||||
() => loadCheckoutComponent(props.provider),
|
||||
[props.provider],
|
||||
);
|
||||
|
||||
@@ -65,28 +53,37 @@ function loadCheckoutComponent(provider: BillingProvider) {
|
||||
}
|
||||
|
||||
function buildLazyComponent<
|
||||
Cmp extends React.ComponentType<
|
||||
React.PropsWithChildren<{
|
||||
onClose?: (() => unknown) | undefined;
|
||||
checkoutToken: string;
|
||||
}>
|
||||
>,
|
||||
Component extends React.ComponentType<{
|
||||
onClose: (() => unknown) | undefined;
|
||||
checkoutToken: string;
|
||||
}>,
|
||||
>(
|
||||
load: () => Promise<{
|
||||
default: Cmp;
|
||||
default: Component;
|
||||
}>,
|
||||
fallback = Fallback,
|
||||
) {
|
||||
let LoadedComponent: ReturnType<typeof lazy> | null = null;
|
||||
let LoadedComponent: ReturnType<typeof lazy<Component>> | null = null;
|
||||
|
||||
const LazyComponent = forwardRef(function LazyDynamicComponent(props, ref) {
|
||||
const LazyComponent = forwardRef<
|
||||
React.ElementRef<'div'>,
|
||||
{
|
||||
onClose: (() => unknown) | undefined;
|
||||
checkoutToken: string;
|
||||
}
|
||||
>(function LazyDynamicComponent(props, ref) {
|
||||
if (!LoadedComponent) {
|
||||
LoadedComponent = lazy(load);
|
||||
}
|
||||
|
||||
return (
|
||||
<Suspense fallback={fallback}>
|
||||
<LoadedComponent {...props} ref={ref} />
|
||||
{/* @ts-ignore */}
|
||||
<LoadedComponent
|
||||
onClose={props.onClose}
|
||||
checkoutToken={props.checkoutToken}
|
||||
ref={ref}
|
||||
/>
|
||||
</Suspense>
|
||||
);
|
||||
});
|
||||
|
||||
@@ -15,16 +15,20 @@
|
||||
"./schema": "./src/schema/index.ts"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"zod": "^3.22.4",
|
||||
"@kit/ui": "0.1.0",
|
||||
"@kit/supabase": "0.1.0",
|
||||
"lucide-react": "^0.361.0"
|
||||
"@kit/ui": "0.1.0",
|
||||
"lucide-react": "^0.363.0",
|
||||
"zod": "^3.22.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/eslint-config": "0.2.0",
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/supabase": "0.1.0",
|
||||
"@kit/tailwind-config": "0.1.0",
|
||||
"@kit/tsconfig": "0.1.0"
|
||||
"@kit/tsconfig": "0.1.0",
|
||||
"@kit/ui": "0.1.0",
|
||||
"lucide-react": "^0.363.0",
|
||||
"zod": "^3.22.4"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
|
||||
@@ -2,3 +2,4 @@ export * from './create-billing-checkout.schema';
|
||||
export * from './create-biling-portal-session.schema';
|
||||
export * from './retrieve-checkout-session.schema';
|
||||
export * from './cancel-subscription-params.schema';
|
||||
export * from './report-billing-usage.schema';
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
import { z } from 'zod';
|
||||
|
||||
export const ReportBillingUsageSchema = z.object({
|
||||
subscriptionId: z.string(),
|
||||
usage: z.object({
|
||||
quantity: z.number(),
|
||||
}),
|
||||
});
|
||||
@@ -6,6 +6,7 @@ import {
|
||||
CreateBillingPortalSessionSchema,
|
||||
RetrieveCheckoutSessionSchema,
|
||||
} from '../schema';
|
||||
import { ReportBillingUsageSchema } from '../schema/report-billing-usage.schema';
|
||||
|
||||
export abstract class BillingStrategyProviderService {
|
||||
abstract createBillingPortalSession(
|
||||
@@ -37,4 +38,10 @@ export abstract class BillingStrategyProviderService {
|
||||
): Promise<{
|
||||
success: boolean;
|
||||
}>;
|
||||
|
||||
abstract reportUsage(
|
||||
params: z.infer<typeof ReportBillingUsageSchema>,
|
||||
): Promise<{
|
||||
success: boolean;
|
||||
}>;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
{
|
||||
"name": "@kit/emails",
|
||||
"private": true,
|
||||
@@ -17,8 +16,8 @@
|
||||
"@react-email/components": "0.0.15"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/eslint-config": "0.2.0",
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/tailwind-config": "0.1.0",
|
||||
"@kit/tsconfig": "0.1.0"
|
||||
},
|
||||
|
||||
@@ -17,15 +17,20 @@
|
||||
"devDependencies": {
|
||||
"@kit/eslint-config": "0.2.0",
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/shared": "*",
|
||||
"@kit/supabase": "*",
|
||||
"@kit/tailwind-config": "0.1.0",
|
||||
"@kit/tsconfig": "0.1.0"
|
||||
"@kit/tsconfig": "0.1.0",
|
||||
"@kit/ui": "*",
|
||||
"@radix-ui/react-icons": "^1.3.0",
|
||||
"lucide-react": "^0.363.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@kit/shared": "0.1.0",
|
||||
"@kit/supabase": "0.1.0",
|
||||
"@kit/ui": "0.1.0",
|
||||
"@kit/shared": "0.1.0",
|
||||
"lucide-react": "^0.360.0",
|
||||
"@radix-ui/react-icons": "^1.3.0"
|
||||
"@radix-ui/react-icons": "^1.3.0",
|
||||
"lucide-react": "^0.363.0"
|
||||
},
|
||||
"prettier": "@kit/prettier-config",
|
||||
"eslintConfig": {
|
||||
|
||||
@@ -16,7 +16,8 @@
|
||||
"@kit/eslint-config": "0.2.0",
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/tailwind-config": "0.1.0",
|
||||
"@kit/tsconfig": "0.1.0"
|
||||
"@kit/tsconfig": "0.1.0",
|
||||
"@kit/ui": "*"
|
||||
},
|
||||
"exports": {
|
||||
".": "./src/index.ts"
|
||||
|
||||
@@ -16,16 +16,16 @@
|
||||
"./mfa": "./src/mfa.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/eslint-config": "0.2.0",
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/supabase": "0.1.0",
|
||||
"@kit/tailwind-config": "0.1.0",
|
||||
"@kit/tsconfig": "0.1.0",
|
||||
"@radix-ui/react-icons": "^1.3.0",
|
||||
"@kit/ui": "0.1.0",
|
||||
"@kit/supabase": "0.1.0",
|
||||
"react-i18next": "14.1.0",
|
||||
"sonner": "^1.4.41",
|
||||
"@tanstack/react-query": "5.28.6"
|
||||
"@radix-ui/react-icons": "^1.3.0",
|
||||
"@tanstack/react-query": "5.28.6",
|
||||
"react-i18next": "^14.1.0",
|
||||
"sonner": "^1.4.41"
|
||||
},
|
||||
"prettier": "@kit/prettier-config",
|
||||
"eslintConfig": {
|
||||
|
||||
@@ -12,19 +12,26 @@
|
||||
"./components": "./src/components/index.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kit/accounts": "*",
|
||||
"@kit/emails": "*",
|
||||
"@kit/eslint-config": "0.2.0",
|
||||
"@kit/mailers": "*",
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/shared": "*",
|
||||
"@kit/supabase": "*",
|
||||
"@kit/tailwind-config": "0.1.0",
|
||||
"@kit/tsconfig": "0.1.0"
|
||||
"@kit/tsconfig": "0.1.0",
|
||||
"@kit/ui": "*",
|
||||
"lucide-react": "^0.363.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@kit/accounts": "0.1.0",
|
||||
"@kit/emails": "0.1.0",
|
||||
"@kit/mailers": "0.1.0",
|
||||
"@kit/shared": "0.1.0",
|
||||
"@kit/supabase": "0.1.0",
|
||||
"@kit/ui": "0.1.0",
|
||||
"@kit/shared": "0.1.0",
|
||||
"@kit/accounts": "0.1.0",
|
||||
"@kit/mailers": "0.1.0",
|
||||
"@kit/emails": "0.1.0",
|
||||
"lucide-react": "^0.360.0"
|
||||
"lucide-react": "^0.363.0"
|
||||
},
|
||||
"prettier": "@kit/prettier-config",
|
||||
"eslintConfig": {
|
||||
|
||||
@@ -16,18 +16,22 @@
|
||||
"./provider": "./src/I18nProvider.tsx"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/eslint-config": "0.2.0",
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/shared": "^0.1.0",
|
||||
"@kit/tailwind-config": "0.1.0",
|
||||
"@kit/tsconfig": "0.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@kit/tsconfig": "0.1.0",
|
||||
"i18next": "^23.10.1",
|
||||
"react-i18next": "^14.1.0",
|
||||
"i18next-browser-languagedetector": "7.2.0",
|
||||
"i18next-resources-to-backend": "^1.2.0",
|
||||
"next": "^14.1.4",
|
||||
"@kit/shared": "^0.1.0"
|
||||
"react-i18next": "^14.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@kit/shared": "^0.1.0",
|
||||
"i18next": "^23.10.1",
|
||||
"i18next-browser-languagedetector": "7.2.0",
|
||||
"i18next-resources-to-backend": "^1.2.0",
|
||||
"react-i18next": "^14.1.0"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
|
||||
@@ -16,8 +16,8 @@
|
||||
"nodemailer": "^6.9.13"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/eslint-config": "0.2.0",
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/tailwind-config": "0.1.0",
|
||||
"@kit/tsconfig": "0.1.0",
|
||||
"@types/nodemailer": "6.4.14"
|
||||
|
||||
@@ -20,8 +20,8 @@
|
||||
"pino": "^8.19.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/eslint-config": "0.2.0",
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/tailwind-config": "0.1.0",
|
||||
"@kit/tsconfig": "0.1.0"
|
||||
},
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
'use client';
|
||||
|
||||
import { createContext } from 'react';
|
||||
|
||||
export const CsrfTokenContext = createContext<string | null>(null);
|
||||
@@ -1,15 +0,0 @@
|
||||
import { useContext } from 'react';
|
||||
|
||||
import { CsrfTokenContext } from '@kit/contexts/csrf.context';
|
||||
|
||||
/**
|
||||
* @description Retrieves the current CSRF token in the CsrfTokenContext context
|
||||
* If not found, it will return an empty string. If required, the API will throw an error
|
||||
*/
|
||||
function useCsrfToken() {
|
||||
const token = useContext(CsrfTokenContext);
|
||||
|
||||
return token ?? '';
|
||||
}
|
||||
|
||||
export default useCsrfToken;
|
||||
@@ -1,19 +0,0 @@
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { useRouter } from 'next/navigation';
|
||||
|
||||
/**
|
||||
* @name useRefreshRoute
|
||||
* @description Refresh the current page. Useful for when you need to
|
||||
* refresh the data on a page after a mutation. This is a temporary
|
||||
* workaround until Next.js adds mutations
|
||||
*/
|
||||
function useRefreshRoute() {
|
||||
const router = useRouter();
|
||||
|
||||
return useCallback(() => {
|
||||
router.refresh();
|
||||
}, [router]);
|
||||
}
|
||||
|
||||
export default useRefreshRoute;
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
{
|
||||
"name": "@kit/stripe",
|
||||
"private": true,
|
||||
@@ -17,20 +16,24 @@
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@kit/billing": "0.1.0",
|
||||
"@kit/ui": "0.1.0",
|
||||
"@kit/shared": "0.1.0",
|
||||
"@kit/supabase": "0.1.0"
|
||||
"@kit/supabase": "0.1.0",
|
||||
"@kit/ui": "0.1.0"
|
||||
},
|
||||
"dependencies": {
|
||||
"stripe": "^14.21.0",
|
||||
"@stripe/react-stripe-js": "^2.6.2",
|
||||
"@stripe/stripe-js": "^3.0.10"
|
||||
"@stripe/stripe-js": "^3.0.10",
|
||||
"stripe": "^14.21.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/billing": "*",
|
||||
"@kit/eslint-config": "0.2.0",
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/shared": "*",
|
||||
"@kit/supabase": "*",
|
||||
"@kit/tailwind-config": "0.1.0",
|
||||
"@kit/tsconfig": "0.1.0"
|
||||
"@kit/tsconfig": "0.1.0",
|
||||
"@kit/ui": "*"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
CancelSubscriptionParamsSchema,
|
||||
CreateBillingCheckoutSchema,
|
||||
CreateBillingPortalSessionSchema,
|
||||
ReportBillingUsageSchema,
|
||||
RetrieveCheckoutSessionSchema,
|
||||
} from '@kit/billing/schema';
|
||||
|
||||
@@ -69,6 +70,16 @@ export class StripeBillingStrategyService
|
||||
};
|
||||
}
|
||||
|
||||
async reportUsage(params: z.infer<typeof ReportBillingUsageSchema>) {
|
||||
const stripe = await this.stripeProvider();
|
||||
|
||||
await stripe.subscriptionItems.createUsageRecord(params.subscriptionId, {
|
||||
quantity: params.usage.quantity,
|
||||
});
|
||||
|
||||
return { success: true };
|
||||
}
|
||||
|
||||
private async stripeProvider(): Promise<Stripe> {
|
||||
return createStripeClient();
|
||||
}
|
||||
|
||||
@@ -23,16 +23,20 @@
|
||||
"./database": "./src/database.types.ts"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@epic-web/invariant": "^1.0.0",
|
||||
"@kit/eslint-config": "0.2.0",
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/tailwind-config": "0.1.0",
|
||||
"@kit/tsconfig": "0.1.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tanstack/react-query": "^5.28.6",
|
||||
"@kit/tsconfig": "0.1.0",
|
||||
"@supabase/ssr": "^0.1.0",
|
||||
"@supabase/supabase-js": "^2.39.8",
|
||||
"@epic-web/invariant": "^1.0.0"
|
||||
"@tanstack/react-query": "5.28.6"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@epic-web/invariant": "^1.0.0",
|
||||
"@supabase/ssr": "^0.1.0",
|
||||
"@supabase/supabase-js": "^2.39.8",
|
||||
"@tanstack/react-query": "^5.28.6"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
|
||||
@@ -10,51 +10,60 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"@radix-ui/react-accordion": "1.1.2",
|
||||
"@radix-ui/react-alert-dialog": "^1.0.5",
|
||||
"@radix-ui/react-avatar": "^1.0.4",
|
||||
"@radix-ui/react-checkbox": "^1.0.4",
|
||||
"@radix-ui/react-dialog": "^1.0.5",
|
||||
"@radix-ui/react-dropdown-menu": "^2.0.6",
|
||||
"@radix-ui/react-label": "^2.0.2",
|
||||
"@radix-ui/react-navigation-menu": "^1.1.4",
|
||||
"@radix-ui/react-popover": "^1.0.7",
|
||||
"@radix-ui/react-radio-group": "^1.1.3",
|
||||
"@radix-ui/react-scroll-area": "^1.0.5",
|
||||
"@radix-ui/react-select": "^2.0.0",
|
||||
"@radix-ui/react-separator": "^1.0.3",
|
||||
"@radix-ui/react-slot": "^1.0.2",
|
||||
"@radix-ui/react-tabs": "^1.0.4",
|
||||
"@radix-ui/react-toast": "^1.1.5",
|
||||
"@radix-ui/react-tooltip": "1.0.7",
|
||||
"@radix-ui/react-radio-group": "^1.1.3",
|
||||
"@radix-ui/react-alert-dialog": "^1.0.5",
|
||||
"@radix-ui/react-navigation-menu": "^1.1.4",
|
||||
"@radix-ui/react-separator": "^1.0.3",
|
||||
"react-top-loading-bar": "2.3.1",
|
||||
"clsx": "^2.1.0",
|
||||
"cmdk": "^0.2.0",
|
||||
"react-top-loading-bar": "2.3.1",
|
||||
"tailwind-merge": "^2.2.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@tanstack/react-table": "^8.10.7",
|
||||
"react-i18next": "^14.1.0",
|
||||
"@radix-ui/react-icons": "1.3.0",
|
||||
"zod": "^3.22.4",
|
||||
"sonner": "^1.4.41",
|
||||
"lucide-react": "0.307.0",
|
||||
"@tanstack/react-table": "^8.10.7",
|
||||
"class-variance-authority": "^0.7.0",
|
||||
"date-fns": "^3.2.0",
|
||||
"react-hook-form": "^7.49.2"
|
||||
"lucide-react": "^0.363.0",
|
||||
"react-hook-form": "^7.49.2",
|
||||
"react-i18next": "^14.1.0",
|
||||
"sonner": "^1.4.41",
|
||||
"zod": "^3.22.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@kit/eslint-config": "0.2.0",
|
||||
"@kit/prettier-config": "0.1.0",
|
||||
"@kit/tailwind-config": "0.1.0",
|
||||
"@kit/tsconfig": "0.1.0",
|
||||
"@radix-ui/react-icons": "^1.3.0",
|
||||
"@tanstack/react-table": "^8.11.3",
|
||||
"@types/react": "^18.2.48",
|
||||
"@types/react-dom": "^18.2.18",
|
||||
"class-variance-authority": "^0.7.0",
|
||||
"date-fns": "^3.2.0",
|
||||
"eslint": "^8.56.0",
|
||||
"lucide-react": "^0.363.0",
|
||||
"prettier": "^3.2.4",
|
||||
"react-day-picker": "^8.10.0",
|
||||
"react-hook-form": "^7.51.1",
|
||||
"react-i18next": "^14.1.0",
|
||||
"sonner": "^1.4.41",
|
||||
"tailwindcss": "3.4.1",
|
||||
"tailwindcss-animate": "^1.0.7",
|
||||
"typescript": "^5.3.3"
|
||||
"typescript": "^5.3.3",
|
||||
"zod": "^3.22.4"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
|
||||
Reference in New Issue
Block a user