Fix stripe. Remove fetching prices in getServerSideProps
This commit is contained in:
+3
-7
@@ -16,7 +16,7 @@ const Alert = forwardRef(function Alert(props, ref) {
|
||||
return <MuiAlert ref={ref} elevation={6} variant='filled' {...props} />
|
||||
})
|
||||
|
||||
export default function Soutyen({prices, paymentStatus}) {
|
||||
export default function Soutyen({paymentStatus}) {
|
||||
const router = useRouter()
|
||||
const scrollEvent = useRef(null)
|
||||
const [clientSecret, setClientSecret] = useState(null)
|
||||
@@ -60,7 +60,7 @@ export default function Soutyen({prices, paymentStatus}) {
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if (paymentMethod !== 0) {
|
||||
if (paymentMethod !== 2) {
|
||||
setClientEmail('')
|
||||
setClientSecret(null)
|
||||
setSelectedMontant(null)
|
||||
@@ -124,7 +124,7 @@ export default function Soutyen({prices, paymentStatus}) {
|
||||
>
|
||||
<Box sx={{display: 'flex', flexDirection: 'column', minHeight: '100vh'}}>
|
||||
<Box sx={{flexGrow: 1, marginTop: 1, marginBottom: 10}}>
|
||||
<Container sx={{marginTop: 1}}>
|
||||
<Container sx={{marginTop: 3}}>
|
||||
<Typography gutterBottom sx={{fontWeight: 'bold'}} textAlign='center' variant='h4' component='h1'>
|
||||
Soutenir Organisation KA Internationale !
|
||||
</Typography>
|
||||
@@ -138,7 +138,6 @@ export default function Soutyen({prices, paymentStatus}) {
|
||||
setSelectedMontant={setSelectedMontant}
|
||||
validMontant={validMontant}
|
||||
setValidMontant={setValidMontant}
|
||||
prices={prices}
|
||||
isLoading={isLoading}
|
||||
paymentIntent={paymentIntent}
|
||||
clientSecret={clientSecret}
|
||||
@@ -173,13 +172,11 @@ Soutyen.defaultProps = {
|
||||
}
|
||||
|
||||
Soutyen.propTypes = {
|
||||
prices: PropTypes.array.isRequired,
|
||||
paymentStatus: PropTypes.string
|
||||
}
|
||||
|
||||
export async function getServerSideProps({query}) {
|
||||
const {payment_intent, payment_intent_client_secret} = query
|
||||
const prices = await fetch(`${SITE_URL}/stripe/dons-list`)
|
||||
let payment
|
||||
if (payment_intent && payment_intent_client_secret) {
|
||||
const paymentResponse = await fetch(`${SITE_URL}/stripe/check-payment`, {
|
||||
@@ -198,7 +195,6 @@ export async function getServerSideProps({query}) {
|
||||
|
||||
return {
|
||||
props: {
|
||||
prices: await prices.json(),
|
||||
paymentStatus: payment?.status || null
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user