💄 ajout de redirection sur la page mon compte

This commit is contained in:
eric committed 2022-12-02 04:12:00 +01:00
1 parent cb95d93831
commit 9d41546603
2 files changed
+39 -33

No files matched your search

+37 -31
View File
@@ -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>