💄 ajout de redirection sur la page mon compte
This commit is contained in:
1 parent
cb95d93831
commit
9d41546603
2 files changed
+26
-20
No files matched your search
@@ -43,8 +43,8 @@ const options = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
pages: {
|
pages: {
|
||||||
signIn: '/mon-compte',
|
signIn: '/',
|
||||||
// signOut: '/auth/signout',
|
signOut: '/mon-compte',
|
||||||
error: '/auth/error', // Error code passed in query string as ?error=
|
error: '/auth/error', // Error code passed in query string as ?error=
|
||||||
verifyRequest: '/verify-request', // (used for check email message)
|
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)
|
// newUser: '/auth/new-user' // New users will be directed here on first sign in (leave the property out if not of interest)
|
||||||
|
|||||||
+24
-18
@@ -43,6 +43,16 @@ type FormData = {
|
|||||||
export async function getServerSideProps(context) {
|
export async function getServerSideProps(context) {
|
||||||
const session = await getSession(context)
|
const session = await getSession(context)
|
||||||
|
|
||||||
|
if (!session) {
|
||||||
|
return {
|
||||||
|
redirect: {
|
||||||
|
destination: '/',
|
||||||
|
permanent: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const user = await prisma.user.findUnique({
|
const user = await prisma.user.findUnique({
|
||||||
where: {
|
where: {
|
||||||
email: session?.user.email
|
email: session?.user.email
|
||||||
@@ -60,33 +70,29 @@ export async function getServerSideProps(context) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
props: {
|
props: {
|
||||||
user: JSON.parse(JSON.stringify(user)),
|
user: JSON.parse(JSON.stringify(user)),
|
||||||
userGains: JSON.parse(JSON.stringify(userGains)),
|
userGains,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
user: User;
|
user: User;
|
||||||
userGains: Gain;
|
userGains: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MonCompte = (props: Props) => {
|
const MonCompte = (props: Props) => {
|
||||||
|
|
||||||
const { data: session, status } = useSession();
|
const { data: session, status } = useSession();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
|
||||||
console.log('user', props.user);
|
|
||||||
console.log('userGains', props.userGains);
|
|
||||||
}, [])
|
|
||||||
|
|
||||||
const validationSchema = Yup.object().shape({
|
const validationSchema = Yup.object().shape({
|
||||||
name: Yup.string()
|
name: Yup.string()
|
||||||
.trim()
|
.trim()
|
||||||
@@ -110,6 +116,8 @@ const MonCompte = (props: Props) => {
|
|||||||
});
|
});
|
||||||
const onSubmit: SubmitHandler<FormData> = data => console.log(data);
|
const onSubmit: SubmitHandler<FormData> = data => console.log(data);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Head>
|
<Head>
|
||||||
@@ -191,27 +199,25 @@ const MonCompte = (props: Props) => {
|
|||||||
<h1 className="fw-light">Mes cadeaux</h1>
|
<h1 className="fw-light">Mes cadeaux</h1>
|
||||||
<hr />
|
<hr />
|
||||||
{!props.userGains && <p>Pas encore de cadeau gagné</p>}
|
{!props.userGains && <p>Pas encore de cadeau gagné</p>}
|
||||||
</div>
|
|
||||||
<table className="table">
|
<table className="table">
|
||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th scope="col">#</th>
|
<th scope="col">#</th>
|
||||||
<th scope="col">Mes codes joué</th>
|
<th scope="col">Mes codes joué</th>
|
||||||
<th scope="col">Mes cadeaux</th>
|
<th scope="col">Mes cadeaux</th>
|
||||||
<th scope="col">Handle</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{props.userGains.map((info: any) => {
|
{props.userGains.map((info: any) => {
|
||||||
<tr>
|
return <tr>
|
||||||
<th scope="row"></th>
|
<th scope="row"></th>
|
||||||
<td>Mark</td>
|
<td>{info.codeCadeau}</td>
|
||||||
<td>Otto</td>
|
<td>{info.produit.nomProduit}</td>
|
||||||
<td>@mdo</td>
|
|
||||||
</tr>
|
</tr>
|
||||||
})}
|
})}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in new issue
Block a user