Ensure member stops PayPal before pausing

This commit is contained in:
Tanner Collin 2022-03-15 01:31:26 +00:00
parent 39fde2cefc
commit 67b500e626

View File

@ -314,7 +314,7 @@ export function AdminMemberPause(props) {
const [error, setError] = useState(false); const [error, setError] = useState(false);
const [loading, setLoading] = useState(false); const [loading, setLoading] = useState(false);
const [success, setSuccess] = useState(false); const [success, setSuccess] = useState(false);
const [yousure, setYousure] = useState(false); const [told, setTold] = useState(false);
const { id } = useParams(); const { id } = useParams();
useEffect(() => { useEffect(() => {
@ -322,13 +322,11 @@ export function AdminMemberPause(props) {
}, [result.member]); }, [result.member]);
const handlePause = (e) => { const handlePause = (e) => {
if (yousure) {
if (loading) return; if (loading) return;
setLoading(true); setLoading(true);
setSuccess(false); setSuccess(false);
requester('/members/' + id + '/pause/', 'POST', token, {}) requester('/members/' + id + '/pause/', 'POST', token, {})
.then(res => { .then(res => {
setYousure(false);
setSuccess(true); setSuccess(true);
setError(false); setError(false);
refreshResult(); refreshResult();
@ -338,9 +336,6 @@ export function AdminMemberPause(props) {
console.log(err); console.log(err);
setError(true); setError(true);
}); });
} else {
setYousure(true);
}
}; };
const handleUnpause = (e) => { const handleUnpause = (e) => {
@ -372,9 +367,21 @@ export function AdminMemberPause(props) {
Unpause Unpause
</Button> </Button>
: :
<Button onClick={handlePause} loading={loading}> <>
{yousure ? 'You Sure?' : 'Pause'} <p>
<Form.Checkbox
name='told_subscriptions'
value={told}
label='Told member to stop any PayPal subscriptions'
required
onChange={(e, v) => setTold(v.checked)}
/>
</p>
<Button onClick={handlePause} loading={loading} disabled={!told}>
Pause
</Button> </Button>
</>
} }
</p> </p>