feature/ga
Eric 4 years ago
parent 9e70d7b16f
commit 1b3f5328b0

@ -200,9 +200,11 @@ const Admin = (props: Props) => {
const changeGiftStatus = async (gain: Gain) => {
const body = { gain }
fetcher('/api/user/update-gift', 'PUT', body)
console.log('g', gain);
setTimeout(() => {
router.refresh();
}, 2000)
setCurrentUserGain(gain)
// setCurrentUserGain(gain)
// router.refresh();
};
@ -278,7 +280,7 @@ const Admin = (props: Props) => {
<div className="row">
<div className="col-md-6 col-sm-12">
<hr />
<h1 className="fw-light">{currentUser?.email || 'utilisateur'} <TfiInfoAlt size={40} /></h1>
<h1 className="fw-light text-truncate">{currentUser?.email || 'utilisateur'} <TfiInfoAlt size={40} /></h1>
<hr />
{currentUser && <form onSubmit={handleSubmit(onSubmit)}>
<div className="form-group">

@ -22,7 +22,7 @@ export default async function getCurrent(req: NextApiRequest, res: NextApiRespon
selectedUserPhoneNumber, } = req.body;
// est-ce la méthode est un POST ou PUT?
if (req.method !== ("POST" || "PUT")) {
if (!(['POST', 'PUT'].indexOf(req.method) > -1)) {
throw new Error(
`The HTTP ${req.method} method is not supported at this route.`
);

@ -7,7 +7,7 @@ export default async function updateOrCreate(req: NextApiRequest, res: NextApiRe
const { address, name, phoneNumber, surname, zipCode } = req.body;
// est-ce la méthode est un POST ou PUT?
if (req.method !== ("POST" || "PUT")) {
if (!(['POST', 'PUT'].indexOf(req.method) > -1)) {
throw new Error(
`The HTTP ${req.method} method is not supported at this route.`
);

@ -10,8 +10,11 @@ export default async function updtateGift(req: NextApiRequest, res: NextApiRespo
const session = await getSession({ req })
const { gain } = req.body;
console.log(req.method);
// est-ce la méthode est un POST ou PUT?
if (req.method !== ("POST" || 'PUT')) {
if (!(['POST', 'PUT'].indexOf(req.method) > -1)) {
throw new Error(
`The HTTP ${req.method} method is not supported at this route.`
);

@ -48,7 +48,7 @@ export async function getServerSideProps(context) {
return {
props: {
user: JSON.parse(JSON.stringify(user)),
userGains,
userGains: JSON.parse(JSON.stringify(userGains)),
},
}
}
@ -223,11 +223,13 @@ const MonCompte = (props: Props) => {
</thead>
<tbody>
{props.userGains.map((info: any, index: number) => {
console.log('ii', info);
return <tr>
<th scope="row">{++index}</th>
<td>{info.codeCadeau}</td>
<td>{info.produit.nomProduit}</td>
<td>{!info.produit.retrait ? '❌ déja récupéré' : '✔️ venir me chercher !'}</td>
<td>{info.retrait ? '❌ déja récupéré' : '✔️ venir me chercher !'}</td>
</tr>
})}
</tbody>

Loading…
Cancel
Save