removed unused in demo

This commit is contained in:
Zai Shi 2024-02-28 18:39:40 +01:00
parent 7598511c31
commit 2d0a35e2f5
8 changed files with 34 additions and 98 deletions

View File

@ -1,4 +1,5 @@
import Link from 'next/link';
import CardFrame from 'stack/src/elements/CardFrame';
import { stackServerApp } from 'src/stack';
import ColorModeButton from 'src/components/ColorThemeButton';
import SignOutButton from 'src/components/SignOutButton';
@ -7,37 +8,40 @@ import UserInfoClient from 'src/components/UserInfoClient';
export default async function Page() {
return (
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
<div>
<div>Server:</div>
<UserInfo />
<div style={{ marginBottom: '1rem' }}/>
<div>Client:</div>
<UserInfoClient />
</div>
// <div style={{ display: 'flex', flexDirection: 'column', alignItems: 'center' }}>
// <div>
// <div>Server:</div>
// <UserInfo />
// <div style={{ marginBottom: '1rem' }}/>
// <div>Client:</div>
// <UserInfoClient />
// </div>
<div style={{ marginBottom: '1rem' }}/>
<Link href="/handler/signin">
Sign in
</Link>
<Link href="/handler/signup">
Sign up
</Link>
<div style={{ marginBottom: '1rem' }}/>
<SignOutButton />
<Link href={stackServerApp.urls['signOut']}>
Sign out (server)
</Link>
<div style={{ marginBottom: '1rem' }}/>
<ColorModeButton />
// <div style={{ marginBottom: '1rem' }}/>
// <Link href="/handler/signin">
// Sign in
// </Link>
// <Link href="/handler/signup">
// Sign up
// </Link>
// <div style={{ marginBottom: '1rem' }}/>
// <SignOutButton />
// <Link href={stackServerApp.urls['signOut']}>
// Sign out (server)
// </Link>
// <div style={{ marginBottom: '1rem' }}/>
// <ColorModeButton />
<div style={{ marginBottom: '1rem' }}/>
<Link href="/protected-client">
Protected client
</Link>
<Link href="/protected-server">
Protected server
</Link>
// <div style={{ marginBottom: '1rem' }}/>
// <Link href="/protected-client">
// Protected client
// </Link>
// <Link href="/protected-server">
// Protected server
// </Link>
// </div>
<div style={{ width: '100%', height: '100vh', display: 'flex', justifyContent: 'center', alignItems: 'center' }}>
<h1>Stack Demo</h1>
</div>
);
}

View File

@ -1,7 +0,0 @@
'use client';
import { useUser } from "stack";
export default function ProtectedPage() {
useUser({ or: 'redirect' });
return <div>This is protected. You can see this because you are signed in</div>;
}

View File

@ -1,36 +0,0 @@
/* eslint-disable @typescript-eslint/no-misused-promises */
'use client';
import { useStackApp, validateEmail } from "stack";
import { useState } from "react";
export default function CustomCredentialSignIn() {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [error, setError] = useState('');
const app = useStackApp();
const onSubmit = async () => {
if (!validateEmail(email)) {
setError('Please enter a valid email');
return;
}
if (!password) {
setError('Please enter your password');
return;
}
const errorCode = await app.signInWithCredential({ email, password, redirectUrl: app.urls.userHome });
// It is better to handle each error code separately, but for simplicity, we will just show the error code directly
if (errorCode) {
setError(errorCode);
}
};
return (
<div>
{error}
<input type='email' placeholder="email@example.com" value={email} onChange={(e) => setEmail(e.target.value)} />
<input type='password' placeholder="password" value={password} onChange={(e) => setPassword(e.target.value)} />
<button onClick={onSubmit}>Sign In</button>
</div>
);
}

View File

@ -1,12 +0,0 @@
/* eslint-disable @typescript-eslint/no-misused-promises */
'use client';
import { useStackApp } from "stack";
export default function CustomOAuthSignIn() {
const app = useStackApp();
return <div>
<h1>My Custom Sign In page</h1>
<button onClick={async () => await app.signInWithOauth('google')}>Sign In with Google</button>
</div>;
}

View File

@ -1,10 +0,0 @@
import { SignIn } from "stack";
import { stackServerApp } from "src/stack";
import CustomCredentialSignIn from "./custom-credential";
import CustomOAuthSignIn from "./custom-oauth";
export default function Page() {
return <SignIn fullPage redirectUrl={stackServerApp.urls.home} />;
// return <CustomCredentialSignIn />;
// return <CustomOAuthSignIn />;
}

View File

@ -1,6 +1,6 @@
'use client';
import { useUser, useStackApp } from "stack";
import { useUser } from "stack";
import { runAsynchronously } from "stack-shared/dist/utils/promises";
export default function SignOutButton() {

View File

@ -4,7 +4,4 @@ import { StackServerApp } from "stack";
export const stackServerApp = new StackServerApp({
tokenStore: "nextjs-cookie",
urls: {
signIn: "/signin",
}
});