2022-02-19 22:21:55 +04:00
|
|
|
import PropTypes from 'prop-types'
|
2022-03-06 10:11:02 +04:00
|
|
|
import Tabs from '@mui/material/Tabs'
|
|
|
|
|
import Tab from '@mui/material/Tab'
|
|
|
|
|
import Box from '@mui/material/Box'
|
|
|
|
|
import Button from '@mui/material/Button'
|
2022-02-19 22:21:55 +04:00
|
|
|
|
2022-05-05 14:01:36 +04:00
|
|
|
import {Paypal, Liberapay} from '@icons-pack/react-simple-icons'
|
2022-02-19 22:21:55 +04:00
|
|
|
|
2024-10-21 09:55:57 +04:00
|
|
|
import Grid from '@mui/material/Grid2'
|
2024-01-18 20:32:01 +04:00
|
|
|
import CardMethod from './card-method'
|
2022-02-19 22:21:55 +04:00
|
|
|
|
2022-03-06 10:11:02 +04:00
|
|
|
const PAYPAL_ID = process.env.NEXT_PUBLIC_PAYPAL_DONATE_ID
|
2022-05-05 14:01:36 +04:00
|
|
|
const LIBERAPAY_DONATE = process.env.NEXT_PUBLIC_LIBERAPAY_DONATE
|
2022-02-19 22:21:55 +04:00
|
|
|
|
2022-03-06 10:11:02 +04:00
|
|
|
function TabPanel(props) {
|
|
|
|
|
const {children, value, index, ...other} = props
|
2022-02-19 22:21:55 +04:00
|
|
|
|
2022-03-06 10:11:02 +04:00
|
|
|
return (
|
|
|
|
|
<div
|
|
|
|
|
role='tabpanel'
|
|
|
|
|
hidden={value !== index}
|
|
|
|
|
id={`simple-tabpanel-${index}`}
|
|
|
|
|
aria-labelledby={`simple-tab-${index}`}
|
|
|
|
|
{...other}
|
|
|
|
|
>
|
|
|
|
|
{value === index && (
|
|
|
|
|
<Box sx={{p: 3}}>
|
|
|
|
|
{children}
|
|
|
|
|
</Box>
|
|
|
|
|
)}
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
2022-02-19 22:21:55 +04:00
|
|
|
|
2022-03-06 10:11:02 +04:00
|
|
|
TabPanel.propTypes = {
|
|
|
|
|
children: PropTypes.node,
|
|
|
|
|
index: PropTypes.number.isRequired,
|
|
|
|
|
value: PropTypes.number.isRequired,
|
|
|
|
|
}
|
2022-02-19 22:21:55 +04:00
|
|
|
|
2022-03-06 10:11:02 +04:00
|
|
|
function a11yProps(index) {
|
|
|
|
|
return {
|
|
|
|
|
id: `simple-tab-${index}`,
|
|
|
|
|
'aria-controls': `simple-tabpanel-${index}`,
|
2022-02-19 22:21:55 +04:00
|
|
|
}
|
2022-03-06 10:11:02 +04:00
|
|
|
}
|
2022-02-19 22:21:55 +04:00
|
|
|
|
2023-07-22 13:50:24 +04:00
|
|
|
export default function PaymentMethod({paymentMethod, setPaymentMethod}) {
|
2022-03-06 10:11:02 +04:00
|
|
|
const handleChange = (event, newValue) => {
|
|
|
|
|
setPaymentMethod(newValue)
|
|
|
|
|
}
|
2022-02-19 22:21:55 +04:00
|
|
|
|
|
|
|
|
return (
|
2022-03-06 10:11:02 +04:00
|
|
|
<Box sx={{width: '100%'}}>
|
|
|
|
|
<Box sx={{borderBottom: 1, borderColor: 'divider'}}>
|
|
|
|
|
<Tabs scrollButtons allowScrollButtonsMobile value={paymentMethod} aria-label='basic tabs example' variant='fullWidth' onChange={handleChange}>
|
2023-06-29 06:32:42 +04:00
|
|
|
<Tab wrapped label='Liberapay / PayPal' {...a11yProps(0)} />
|
2024-01-18 20:32:01 +04:00
|
|
|
<Tab wrapped label='Carte bancaire' {...a11yProps(1)} />
|
2022-03-06 10:11:02 +04:00
|
|
|
</Tabs>
|
|
|
|
|
</Box>
|
|
|
|
|
<TabPanel value={paymentMethod} index={0}>
|
2022-07-18 01:14:28 +04:00
|
|
|
<Grid container rowSpacing={1}>
|
2023-07-22 13:50:24 +04:00
|
|
|
<Grid md={6} xs={12}>
|
2022-07-18 01:14:28 +04:00
|
|
|
<Button variant='outlined' size='large' endIcon={<Liberapay />} onClick={() => window.open(`https://liberapay.com/${LIBERAPAY_DONATE}/donate`, '_blank')}>
|
|
|
|
|
Faire un don via Liberapay
|
|
|
|
|
</Button>
|
|
|
|
|
</Grid>
|
2023-07-22 13:50:24 +04:00
|
|
|
<Grid md={6} xs={12}>
|
2022-07-18 01:14:28 +04:00
|
|
|
<Button variant='outlined' size='large' endIcon={<Paypal />} onClick={() => window.open(`https://www.paypal.com/donate/?hosted_button_id=${PAYPAL_ID}`, '_blank')}>
|
|
|
|
|
Faire un don via PayPal
|
|
|
|
|
</Button>
|
|
|
|
|
</Grid>
|
|
|
|
|
</Grid>
|
|
|
|
|
</TabPanel>
|
2023-06-25 15:44:04 +04:00
|
|
|
<TabPanel value={paymentMethod} index={1}>
|
2024-01-18 20:32:01 +04:00
|
|
|
<CardMethod />
|
2023-06-25 15:44:04 +04:00
|
|
|
</TabPanel>
|
2022-03-06 10:11:02 +04:00
|
|
|
</Box>
|
2022-02-19 22:21:55 +04:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
PaymentMethod.propTypes = {
|
2022-03-06 10:11:02 +04:00
|
|
|
paymentMethod: PropTypes.number.isRequired,
|
2023-07-22 13:50:24 +04:00
|
|
|
setPaymentMethod: PropTypes.func.isRequired
|
2022-02-19 22:21:55 +04:00
|
|
|
}
|