💄 ajout de redirection sur la page mon compte

feature/page-admin
Eric 4 years ago
parent cb95d93831
commit 9d41546603

@ -43,8 +43,8 @@ const options = {
}
},
pages: {
signIn: '/mon-compte',
// signOut: '/auth/signout',
signIn: '/',
signOut: '/mon-compte',
error: '/auth/error', // Error code passed in query string as ?error=
verifyRequest: '/verify-request', // (used for check email message)
// newUser: '/auth/new-user' // New users will be directed here on first sign in (leave the property out if not of interest)

@ -43,6 +43,16 @@ type FormData = {
export async function getServerSideProps(context) {
const session = await getSession(context)
if (!session) {
return {
redirect: {
destination: '/',
permanent: false
}
}
}
const user = await prisma.user.findUnique({
where: {
email: session?.user.email
@ -60,33 +70,29 @@ export async function getServerSideProps(context) {
return {
props: {
user: JSON.parse(JSON.stringify(user)),
userGains: JSON.parse(JSON.stringify(userGains)),
userGains,
},
}
}
type Props = {
user: User;
userGains: Gain;
userGains: any;
}
const MonCompte = (props: Props) => {
const { data: session, status } = useSession();
useEffect(() => {
console.log('user', props.user);
console.log('userGains', props.userGains);
}, [])
const validationSchema = Yup.object().shape({
name: Yup.string()
.trim()
@ -110,6 +116,8 @@ const MonCompte = (props: Props) => {
});
const onSubmit: SubmitHandler<FormData> = data => console.log(data);
return (
<>
<Head>
@ -191,27 +199,25 @@ const MonCompte = (props: Props) => {
<h1 className="fw-light">Mes cadeaux</h1>
<hr />
{!props.userGains && <p>Pas encore de cadeau gagné</p>}
</div>
<table className="table">
<thead>
<tr>
<th scope="col">#</th>
<th scope="col">Mes codes joué</th>
<th scope="col">Mes cadeaux</th>
<th scope="col">Handle</th>
</tr>
</thead>
<tbody>
{props.userGains.map((info: any) => {
<table className="table">
<thead>
<tr>
<th scope="row"></th>
<td>Mark</td>
<td>Otto</td>
<td>@mdo</td>
<th scope="col">#</th>
<th scope="col">Mes codes joué</th>
<th scope="col">Mes cadeaux</th>
</tr>
})}
</tbody>
</table>
</thead>
<tbody>
{props.userGains.map((info: any) => {
return <tr>
<th scope="row"></th>
<td>{info.codeCadeau}</td>
<td>{info.produit.nomProduit}</td>
</tr>
})}
</tbody>
</table>
</div>
</div>

Loading…
Cancel
Save