update pay function
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
import Assistant from '@/components/dashboard/ai-assistant';
|
||||
import { Providers } from '@/components/providers';
|
||||
import {
|
||||
getProducts,
|
||||
getSubscription,
|
||||
getUser,
|
||||
getUserDetails
|
||||
} from '@/utils/supabase/queries';
|
||||
import { createClient } from '@/utils/supabase/server';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
export default async function AiAssistant() {
|
||||
const supabase = createClient();
|
||||
const [user, userDetails, products, subscription] = await Promise.all([
|
||||
getUser(supabase),
|
||||
getUserDetails(supabase),
|
||||
getProducts(supabase),
|
||||
getSubscription(supabase)
|
||||
]);
|
||||
|
||||
if (!user) {
|
||||
return redirect('/dashboard/signin');
|
||||
}
|
||||
|
||||
return (
|
||||
<Providers>
|
||||
<Assistant
|
||||
userDetails={userDetails}
|
||||
user={user}
|
||||
products={products}
|
||||
subscription={subscription}
|
||||
/>
|
||||
</Providers>
|
||||
);
|
||||
}
|
||||
36
boilerplate-chakra-pro-main/app/dashboard/ai-chat/page.tsx
Normal file
36
boilerplate-chakra-pro-main/app/dashboard/ai-chat/page.tsx
Normal file
@@ -0,0 +1,36 @@
|
||||
import {
|
||||
getProducts,
|
||||
getSubscription,
|
||||
getUser,
|
||||
getUserDetails
|
||||
} from '@/utils/supabase/queries';
|
||||
|
||||
import Chat from '@/components/dashboard/ai-chat';
|
||||
import { Providers } from '@/components/providers';
|
||||
import { createClient } from '@/utils/supabase/server';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
export default async function AiChat() {
|
||||
const supabase = createClient();
|
||||
const [user, userDetails, products, subscription] = await Promise.all([
|
||||
getUser(supabase),
|
||||
getUserDetails(supabase),
|
||||
getProducts(supabase),
|
||||
getSubscription(supabase)
|
||||
]);
|
||||
|
||||
if (!user) {
|
||||
return redirect('/dashboard/signin');
|
||||
}
|
||||
|
||||
return (
|
||||
<Providers>
|
||||
<Chat
|
||||
userDetails={userDetails}
|
||||
user={user}
|
||||
products={products}
|
||||
subscription={subscription}
|
||||
/>
|
||||
</Providers>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import Generator from '@/components/dashboard/ai-generator';
|
||||
import { Providers } from '@/components/providers';
|
||||
import {
|
||||
getProducts,
|
||||
getSubscription,
|
||||
getUser,
|
||||
getUserDetails
|
||||
} from '@/utils/supabase/queries';
|
||||
import { createClient } from '@/utils/supabase/server';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
export default async function AiGenerator() {
|
||||
const supabase = createClient();
|
||||
const [user, userDetails, products, subscription] = await Promise.all([
|
||||
getUser(supabase),
|
||||
getUserDetails(supabase),
|
||||
getProducts(supabase),
|
||||
getSubscription(supabase)
|
||||
]);
|
||||
|
||||
if (!user) {
|
||||
return redirect('/dashboard/signin');
|
||||
}
|
||||
|
||||
return (
|
||||
<Providers>
|
||||
<Generator
|
||||
userDetails={userDetails}
|
||||
user={user}
|
||||
products={products}
|
||||
subscription={subscription}
|
||||
/>
|
||||
</Providers>
|
||||
);
|
||||
}
|
||||
35
boilerplate-chakra-pro-main/app/dashboard/main/page.tsx
Normal file
35
boilerplate-chakra-pro-main/app/dashboard/main/page.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import { Providers } from '@/components/providers';
|
||||
|
||||
import Main from '@/components/dashboard/main';
|
||||
import {
|
||||
getProducts,
|
||||
getSubscription,
|
||||
getUser,
|
||||
getUserDetails
|
||||
} from '@/utils/supabase/queries';
|
||||
import { createClient } from '@/utils/supabase/server';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
export default async function MainPage() {
|
||||
const supabase = createClient();
|
||||
const [user, userDetails, products, subscription] = await Promise.all([
|
||||
getUser(supabase),
|
||||
getUserDetails(supabase),
|
||||
getProducts(supabase),
|
||||
getSubscription(supabase)
|
||||
]);
|
||||
if (!user) {
|
||||
return redirect('/dashboard/signin');
|
||||
}
|
||||
|
||||
return (
|
||||
<Providers>
|
||||
<Main
|
||||
userDetails={userDetails}
|
||||
user={user}
|
||||
products={products}
|
||||
subscription={subscription}
|
||||
/>
|
||||
</Providers>
|
||||
);
|
||||
}
|
||||
14
boilerplate-chakra-pro-main/app/dashboard/page.tsx
Normal file
14
boilerplate-chakra-pro-main/app/dashboard/page.tsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import { getUser } from '@/utils/supabase/queries';
|
||||
import { redirect } from 'next/navigation';
|
||||
import { createClient } from '@/utils/supabase/server';
|
||||
|
||||
export default async function Dashboard() {
|
||||
const supabase = createClient();
|
||||
const [user] = await Promise.all([getUser(supabase)]);
|
||||
|
||||
if (!user) {
|
||||
return redirect('/dashboard/signin');
|
||||
} else {
|
||||
redirect('/dashboard/main');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
import PremiumGenerator from '@/components/dashboard/premium-generator';
|
||||
import { Providers } from '@/components/providers';
|
||||
import {
|
||||
getProducts,
|
||||
getSubscription,
|
||||
getUser,
|
||||
getUserDetails
|
||||
} from '@/utils/supabase/queries';
|
||||
import { createClient } from '@/utils/supabase/server';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
export default async function PremiumGeneratorPage() {
|
||||
const supabase = createClient();
|
||||
const [user, userDetails, products, subscription] = await Promise.all([
|
||||
getUser(supabase),
|
||||
getUserDetails(supabase),
|
||||
getProducts(supabase),
|
||||
getSubscription(supabase)
|
||||
]);
|
||||
|
||||
if (!user) {
|
||||
return redirect('/dashboard/signin');
|
||||
}
|
||||
|
||||
if (!subscription) {
|
||||
redirect('/dashboard/main');
|
||||
}
|
||||
return (
|
||||
<Providers>
|
||||
{subscription ? (
|
||||
<PremiumGenerator
|
||||
userDetails={userDetails}
|
||||
user={user}
|
||||
products={products}
|
||||
subscription={subscription}
|
||||
/>
|
||||
) : (
|
||||
<p>NICE TRY BUDDY</p>
|
||||
)}
|
||||
</Providers>
|
||||
);
|
||||
}
|
||||
35
boilerplate-chakra-pro-main/app/dashboard/settings/page.tsx
Normal file
35
boilerplate-chakra-pro-main/app/dashboard/settings/page.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import Settings from '@/components/dashboard/settings';
|
||||
import { Providers } from '@/components/providers';
|
||||
import {
|
||||
getProducts,
|
||||
getSubscription,
|
||||
getUser,
|
||||
getUserDetails
|
||||
} from '@/utils/supabase/queries';
|
||||
import { createClient } from '@/utils/supabase/server';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
export default async function SettingsPage() {
|
||||
const supabase = createClient();
|
||||
const [user, userDetails, products, subscription] = await Promise.all([
|
||||
getUser(supabase),
|
||||
getUserDetails(supabase),
|
||||
getProducts(supabase),
|
||||
getSubscription(supabase)
|
||||
]);
|
||||
|
||||
if (!user) {
|
||||
return redirect('/dashboard/signin');
|
||||
}
|
||||
|
||||
return (
|
||||
<Providers>
|
||||
<Settings
|
||||
userDetails={userDetails}
|
||||
user={user}
|
||||
products={products}
|
||||
subscription={subscription}
|
||||
/>
|
||||
</Providers>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
import DefaultAuth from '@/components/auth';
|
||||
import AuthUI from '@/components/auth/AuthUI';
|
||||
import { Providers } from '@/components/providers';
|
||||
import {
|
||||
getAuthTypes,
|
||||
getDefaultSignInView,
|
||||
getRedirectMethod,
|
||||
getViewTypes
|
||||
} from '@/utils/auth-helpers/settings';
|
||||
import { createClient } from '@/utils/supabase/server';
|
||||
import { cookies } from 'next/headers';
|
||||
import { redirect } from 'next/navigation';
|
||||
import illustration from '/public/img/auth/auth.png';
|
||||
|
||||
export default async function SignIn({
|
||||
params,
|
||||
searchParams
|
||||
}: {
|
||||
params: { id: string };
|
||||
searchParams: { disable_button: boolean };
|
||||
}) {
|
||||
const { allowOauth, allowEmail, allowPassword } = getAuthTypes();
|
||||
const viewTypes = getViewTypes();
|
||||
const redirectMethod = getRedirectMethod();
|
||||
|
||||
// Declare 'viewProp' and initialize with the default value
|
||||
let viewProp: string;
|
||||
|
||||
// Assign url id to 'viewProp' if it's a valid string and ViewTypes includes it
|
||||
if (typeof params.id === 'string' && viewTypes.includes(params.id)) {
|
||||
viewProp = params.id;
|
||||
} else {
|
||||
const preferredSignInView =
|
||||
cookies().get('preferredSignInView')?.value || null;
|
||||
viewProp = getDefaultSignInView(preferredSignInView);
|
||||
return redirect(`/dashboard/signin/${viewProp}`);
|
||||
}
|
||||
|
||||
// Check if the user is already logged in and redirect to the account page if so
|
||||
const supabase = createClient();
|
||||
|
||||
const {
|
||||
data: { user }
|
||||
} = await supabase.auth.getUser();
|
||||
|
||||
if (user && viewProp !== 'update_password') {
|
||||
return redirect('/dashboard/main');
|
||||
} else if (!user && viewProp === 'update_password') {
|
||||
return redirect('/dashboard/signin');
|
||||
}
|
||||
return (
|
||||
<Providers>
|
||||
<DefaultAuth
|
||||
viewProp={viewProp}
|
||||
illustrationBackground={illustration.src}
|
||||
>
|
||||
<div>
|
||||
<AuthUI
|
||||
viewProp={viewProp}
|
||||
user={user}
|
||||
allowPassword={allowPassword}
|
||||
allowEmail={allowEmail}
|
||||
redirectMethod={redirectMethod}
|
||||
disableButton={searchParams.disable_button}
|
||||
allowOauth={allowOauth}
|
||||
/>
|
||||
</div>
|
||||
</DefaultAuth>
|
||||
</Providers>
|
||||
);
|
||||
}
|
||||
11
boilerplate-chakra-pro-main/app/dashboard/signin/page.tsx
Normal file
11
boilerplate-chakra-pro-main/app/dashboard/signin/page.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
import { getDefaultSignInView } from '@/utils/auth-helpers/settings';
|
||||
import { cookies } from 'next/headers';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
export default function SignIn() {
|
||||
const preferredSignInView =
|
||||
cookies().get('preferredSignInView')?.value || null;
|
||||
const defaultView = getDefaultSignInView(preferredSignInView);
|
||||
|
||||
return redirect(`/dashboard/signin/${defaultView}`);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
import Subscription from '@/components/dashboard/subscription';
|
||||
import { Providers } from '@/components/providers';
|
||||
import {
|
||||
getProducts,
|
||||
getSubscription,
|
||||
getUser,
|
||||
getUserDetails
|
||||
} from '@/utils/supabase/queries';
|
||||
import { createClient } from '@/utils/supabase/server';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
export default async function SubscriptionPage() {
|
||||
const supabase = createClient();
|
||||
const [user, userDetails, products, subscription] = await Promise.all([
|
||||
getUser(supabase),
|
||||
getUserDetails(supabase),
|
||||
getProducts(supabase),
|
||||
getSubscription(supabase)
|
||||
]);
|
||||
|
||||
if (!user) {
|
||||
return redirect('/dashboard/signin');
|
||||
}
|
||||
return (
|
||||
<Providers>
|
||||
<Subscription
|
||||
userDetails={userDetails}
|
||||
user={user}
|
||||
products={products}
|
||||
subscription={subscription}
|
||||
/>
|
||||
</Providers>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
import UsersList from '@/components/dashboard/users-list';
|
||||
import { Providers } from '@/components/providers';
|
||||
import {
|
||||
getProducts,
|
||||
getSubscription,
|
||||
getUser,
|
||||
getUserDetails
|
||||
} from '@/utils/supabase/queries';
|
||||
import { createClient } from '@/utils/supabase/server';
|
||||
import { redirect } from 'next/navigation';
|
||||
|
||||
export default async function UserList() {
|
||||
const supabase = createClient();
|
||||
const [user, userDetails, products, subscription] = await Promise.all([
|
||||
getUser(supabase),
|
||||
getUserDetails(supabase),
|
||||
getProducts(supabase),
|
||||
getSubscription(supabase)
|
||||
]);
|
||||
|
||||
if (!user) {
|
||||
return redirect('/dashboard/signin');
|
||||
}
|
||||
|
||||
return (
|
||||
<Providers>
|
||||
<UsersList
|
||||
userDetails={userDetails}
|
||||
user={user}
|
||||
products={products}
|
||||
subscription={subscription}
|
||||
/>
|
||||
</Providers>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user