Prevent form submit if loading

master
Tanner Collin 4 years ago
parent 1ebb1f64ad
commit ee520b8c3f
  1. 3
      webclient/src/Account.js
  2. 6
      webclient/src/Admin.js
  3. 2
      webclient/src/InstructorClasses.js
  4. 2
      webclient/src/InstructorCourses.js
  5. 2
      webclient/src/LoginSignup.js
  6. 2
      webclient/src/Transactions.js

@ -14,6 +14,7 @@ function LogoutEverywhere(props) {
const handleClick = () => {
if (yousure) {
if (loading) return;
setLoading(true);
requester('/rest-auth/logout/', 'POST', token, {})
.then(res => {
@ -58,6 +59,7 @@ function ChangePasswordForm(props) {
const handleChange = (e) => handleValues(e, e.currentTarget);
const handleSubmit = (e) => {
if (loading) return;
setLoading(true);
requester('/password/change/', 'POST', token, input)
.then(res => {
@ -122,6 +124,7 @@ export function AccountForm(props) {
const handleCheck = (e, v) => setInput({ ...input, [v.name]: v.checked });
const handleSubmit = (e) => {
if (loading) return;
setLoading(true);
requester('/members/' + member.id + '/', 'PATCH', token, input)
.then(res => {

@ -54,6 +54,7 @@ export function AdminTransactions(props) {
const { id } = useParams();
const handleSubmit = (e) => {
if (loading) return;
setLoading(true);
setSuccess(false);
const data = { ...input, member_id: id };
@ -118,6 +119,7 @@ function AdminCardDetail(props) {
const handleCheck = (e, v) => setInput({ ...input, [v.name]: v.checked });
const handleSubmit = (e) => {
if (loading) return;
setLoading(true);
setSuccess(false);
const data = { ...input, member_id: result.member.id };
@ -226,6 +228,7 @@ export function AdminMemberCards(props) {
const handleCheck = (e, v) => setInput({ ...input, [v.name]: v.checked });
const handleSubmit = (e) => {
if (loading) return;
setLoading(true);
setSuccess(false);
const data = { ...input, member_id: result.member.id };
@ -328,6 +331,7 @@ export function AdminMemberPause(props) {
const handlePause = (e) => {
if (yousure) {
if (loading) return;
setLoading(true);
setSuccess(false);
requester('/members/' + id + '/pause/', 'POST', token, {})
@ -348,6 +352,7 @@ export function AdminMemberPause(props) {
};
const handleUnpause = (e) => {
if (loading) return;
setLoading(true);
setSuccess(false);
requester('/members/' + id + '/unpause/', 'POST', token, {})
@ -405,6 +410,7 @@ export function AdminMemberForm(props) {
const handleCheck = (e, v) => setInput({ ...input, [v.name]: v.checked });
const handleSubmit = (e) => {
if (loading) return;
setLoading(true);
setSuccess(false);
requester('/members/' + id + '/', 'PATCH', token, input)

@ -151,6 +151,7 @@ export function InstructorClassDetail(props) {
const { id } = useParams();
const handleSubmit = (e) => {
if (loading) return;
setLoading(true);
setSuccess(false);
requester('/sessions/'+id+'/', 'PUT', token, input)
@ -202,6 +203,7 @@ export function InstructorClassList(props) {
const [success, setSuccess] = useState(false);
const handleSubmit = (e) => {
if (loading) return;
setLoading(true);
setSuccess(false);
const data = { ...input, course: course.id };

@ -79,6 +79,7 @@ export function InstructorCourseDetail(props) {
const { id } = useParams();
const handleSubmit = (e) => {
if (loading) return;
setLoading(true);
setSuccess(false);
const data = { ...input, is_old: false };
@ -131,6 +132,7 @@ export function InstructorCourseList(props) {
const [success, setSuccess] = useState(false);
const handleSubmit = (e) => {
if (loading) return;
setLoading(true);
setSuccess(false);
const data = { ...input, is_old: false };

@ -13,6 +13,7 @@ export function LoginForm(props) {
const handleChange = (e) => handleValues(e, e.currentTarget);
const handleSubmit = (e) => {
if (loading) return;
setLoading(true);
const data = { ...input, username: input.username.toLowerCase() };
requester('/rest-auth/login/', 'POST', '', data)
@ -68,6 +69,7 @@ export function SignupForm(props) {
);
const handleSubmit = (e) => {
if (loading) return;
setLoading(true);
input.username = genUsername();
requester('/registration/', 'POST', '', input)

@ -148,6 +148,7 @@ function EditTransaction(props) {
const { id } = useParams();
const handleSubmit = (e) => {
if (loading) return;
setLoading(true);
setSuccess(false);
const data = { ...input, report_type: null, report_memo: '' };
@ -199,6 +200,7 @@ function ReportTransaction(props) {
const handleCheck = (e, v) => setInput({ ...input, [v.name]: v.checked });
const handleSubmit = (e) => {
if (loading) return;
setLoading(true);
setSuccess(false);
requester('/transactions/'+id+'/report/', 'POST', token, input)

Loading…
Cancel
Save