このリポジトリは2023-09-09にアーカイブされています。 ファイルの閲覧とクローンは可能ですが、プッシュ、イシューの作成、プルリクエストはできません。
kikikan/backend/resources/js/child/profile/withdrawal.jsx

83 行
3.0 KiB
React
Raw 通常表示 履歴

2022-02-03 04:39:18 +09:00
import React, { useState, useRef, useEffect, useContext } from 'react';
2021-11-09 16:53:39 +09:00
import { LoadingButton } from '@material-ui/lab';
2022-02-03 04:39:18 +09:00
import { HeaderContext } from '../../context';
2021-12-31 12:33:35 +09:00
import Notification from '../../component/notification';
2021-11-18 18:14:14 +09:00
import Alert from '../../component/alert';
2021-11-09 16:53:39 +09:00
2021-10-31 12:26:19 +09:00
const ChildProfileWithdrawal = () => {
2021-11-09 16:53:39 +09:00
2022-01-28 22:29:58 +09:00
const child_id = localStorage.getItem('child_id');
2022-01-28 20:41:31 +09:00
const [notice, setNotice] = useState(-1);
2021-11-09 16:53:39 +09:00
const [submit, setSubmit] = useState(false);
const [_400error, set400Error] = useState('');
2021-11-11 14:33:17 +09:00
2022-02-03 04:39:18 +09:00
const { isAuthenticate } = useContext(HeaderContext);
2022-01-14 16:33:26 +09:00
const isMountedRef = useRef(true);
useEffect(() => {
isMountedRef.current = false;
return () => {
isMountedRef.current = true;
}
}, [])
const handleSubmit = (e) => {
2021-11-09 16:53:39 +09:00
e.preventDefault();
2022-02-03 04:39:18 +09:00
if(isAuthenticate()){
setSubmit(true);
axios.delete('/api/children/withdrawal', {params:{child_id: child_id}})
.then(response => {
if(isMountedRef.current) return;
setSubmit(false);
setNotice(response.data.notice);
switch(response.data.status_code){
case 200: window.location.href = "/c-account/withdrawal/complete"; break;
case 400: set400Error("失敗しました。"); break;
}
})
}
2021-11-09 16:53:39 +09:00
}
return (
<div className="l-content">
<div className="l-content-w560">
<div className="l-content__ttl">
<div className="l-content__ttl__left">
<h2>退会確認</h2>
</div>
2021-11-11 14:33:17 +09:00
<Notification notice={notice}/>
2021-11-09 16:53:39 +09:00
</div>
<div className="l-content-wrap">
<section className="edit-container">
<div className="edit-wrap">
<div className="edit-content">
<form className="edit-form" onSubmit={handleSubmit} noValidate>
<div className="edit-set-bg ft-xs-16">
<p>本当に退会してもよろしいでしょうか</p>
</div>
<div>
<LoadingButton type="submit" fullWidth
loading = {submit}
className="btn-edit btn-default btn-h75 bg-yellow rounded-20">
<span className={`ft-16 font-weight-bold ${!submit && 'text-black'}`}>退会する</span>
</LoadingButton>
</div>
</form>
</div>
</div>
2021-11-17 23:56:11 +09:00
{ _400error && <Alert type="fail" hide={()=>set400Error('')}>{_400error}</Alert> }
2021-11-09 16:53:39 +09:00
</section>
</div>
</div>
</div>
)
}
2021-10-31 12:26:19 +09:00
export default ChildProfileWithdrawal;