Skip to content

Commit

Permalink
Fix handler on each stat
Browse files Browse the repository at this point in the history
  • Loading branch information
afasyah committed Nov 27, 2022
1 parent c678ef2 commit 45d9454
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
9 changes: 5 additions & 4 deletions src/Approved.jsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
import React, { useEffect } from "react";
import React, { useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import { toast } from "react-toastify";
import discord from './asset/discord.svg';
import CookiesHelper from "./helpers/cookies-helper";
import { isRegistAnounced } from "./helpers/registration-close-helper";
import Status from "./Status";

const Approved = () => {
const navigate = useNavigate()
const user = CookiesHelper.get('user') && JSON.parse(CookiesHelper.get('user'));
const [ anounced, setAnounced ] = useState(isRegistAnounced());

useEffect(() => {
if (user) {
if (user.status.status !== 2) {
navigate('/status');
}
if (!anounced) navigate('/status/onprogress')
else if (user.status.status !== 2) navigate('/status')
} else {
toast.error('Unauthorized, please login');
navigate('/login');
Expand Down
8 changes: 4 additions & 4 deletions src/Mistake.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@ import React, { useEffect, useState } from "react";
import { useNavigate } from "react-router-dom";
import { toast } from "react-toastify";
import CookiesHelper from "./helpers/cookies-helper";
import { isResubmitClosed } from "./helpers/registration-close-helper";
import { isRegistAnounced, isResubmitClosed } from "./helpers/registration-close-helper";
import Status from "./Status";

const Mistake = () => {
const navigate = useNavigate()
const user = CookiesHelper.get('user') && JSON.parse(CookiesHelper.get('user'));
const [ resubmitClosed, setResubmitClosed ] = useState(isResubmitClosed());
const [ anounced, setAnounced ] = useState(isRegistAnounced());

useEffect(() => {
if (user) {
if (user.status.status !== 1) {
navigate('/status');
}
if (!anounced) navigate('/status/onprogress')
else if (user.status.status !== 1) navigate('/status')
} else {
toast.error('Unauthorized, please login');
navigate('/login');
Expand Down

0 comments on commit 45d9454

Please sign in to comment.