86 lines
2.5 KiB
JavaScript
86 lines
2.5 KiB
JavaScript
import PropTypes from 'prop-types'
|
|
import Tabs from '@mui/material/Tabs'
|
|
import Tab from '@mui/material/Tab'
|
|
import Box from '@mui/material/Box'
|
|
import Button from '@mui/material/Button'
|
|
|
|
import {Paypal, Liberapay} from '@icons-pack/react-simple-icons'
|
|
|
|
import Grid from '@mui/material/Unstable_Grid2'
|
|
import CardMethod from './card-method'
|
|
|
|
const PAYPAL_ID = process.env.NEXT_PUBLIC_PAYPAL_DONATE_ID
|
|
const LIBERAPAY_DONATE = process.env.NEXT_PUBLIC_LIBERAPAY_DONATE
|
|
|
|
function TabPanel(props) {
|
|
const {children, value, index, ...other} = props
|
|
|
|
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>
|
|
)
|
|
}
|
|
|
|
TabPanel.propTypes = {
|
|
children: PropTypes.node,
|
|
index: PropTypes.number.isRequired,
|
|
value: PropTypes.number.isRequired,
|
|
}
|
|
|
|
function a11yProps(index) {
|
|
return {
|
|
id: `simple-tab-${index}`,
|
|
'aria-controls': `simple-tabpanel-${index}`,
|
|
}
|
|
}
|
|
|
|
export default function PaymentMethod({paymentMethod, setPaymentMethod}) {
|
|
const handleChange = (event, newValue) => {
|
|
setPaymentMethod(newValue)
|
|
}
|
|
|
|
return (
|
|
<Box sx={{width: '100%'}}>
|
|
<Box sx={{borderBottom: 1, borderColor: 'divider'}}>
|
|
<Tabs scrollButtons allowScrollButtonsMobile value={paymentMethod} aria-label='basic tabs example' variant='fullWidth' onChange={handleChange}>
|
|
<Tab wrapped label='Liberapay / PayPal' {...a11yProps(0)} />
|
|
<Tab wrapped label='Carte bancaire' {...a11yProps(1)} />
|
|
</Tabs>
|
|
</Box>
|
|
<TabPanel value={paymentMethod} index={0}>
|
|
<Grid container rowSpacing={1}>
|
|
<Grid md={6} xs={12}>
|
|
<Button variant='outlined' size='large' endIcon={<Liberapay />} onClick={() => window.open(`https://liberapay.com/${LIBERAPAY_DONATE}/donate`, '_blank')}>
|
|
Faire un don via Liberapay
|
|
</Button>
|
|
</Grid>
|
|
<Grid md={6} xs={12}>
|
|
<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>
|
|
<TabPanel value={paymentMethod} index={1}>
|
|
<CardMethod />
|
|
</TabPanel>
|
|
</Box>
|
|
)
|
|
}
|
|
|
|
PaymentMethod.propTypes = {
|
|
paymentMethod: PropTypes.number.isRequired,
|
|
setPaymentMethod: PropTypes.func.isRequired
|
|
}
|