Skip to content

Commit

Permalink
feat: disable redirect during dev
Browse files Browse the repository at this point in the history
  • Loading branch information
proffapt committed Jun 29, 2024
1 parent ee0f007 commit 9efa665
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 38 deletions.
1 change: 0 additions & 1 deletion frontend/.env.example

This file was deleted.

6 changes: 3 additions & 3 deletions frontend/src/constants.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export const BACKEND_URL = import.meta.env.VITE_DEV
? "http://localhost:5173"
: "https://naarad-api.metakgp.org";
export const BACKEND_URL = import.meta.env.PROD
? "https://naarad-api.metakgp.org"
: "http://localhost:5173";
81 changes: 47 additions & 34 deletions frontend/src/pages/Register.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,14 @@ export const Register: Component = () => {
const [getIsLoad, setIsLoad] = createSignal(true);
const [getIsErr, setIsErr] = createSignal(false);

const PROD = import.meta.env.PROD;

onMount(() => {
if (!PROD) {
setTimeout(() => {
setMsg("This is a dummy message for development alksdfjalksdfjalskdjflaksjfdlaksjdflkasjfda");
}, 3000);
}
fetch(BACKEND_URL + "/register", {
method: "GET",
credentials: "include",
Expand All @@ -23,48 +30,54 @@ export const Register: Component = () => {
setStatus("User Registration Successful");
setMsg("Credentials sent to your institute email");

toast.custom(
(t) => (
<RedirectToast
duration={3000}
redirect_url="https://naarad.metakgp.org/login"
url_name="Naarad Login"
t={t}
/>
),
{ duration: 3000 }
);
if (PROD) {
toast.custom(
(t) => (
<RedirectToast
duration={3000}
redirect_url="https://naarad.metakgp.org/login"
url_name="Naarad Login"
t={t}
/>
),
{ duration: 3000 }
);
}
} else if (data.status === 409) {
setIsLoad(false);
setStatus("User Already Registered");
setMsg("Search your institute email for credentials");

toast.custom(
(t) => (
<RedirectToast
duration={3000}
redirect_url="https://naarad.metakgp.org/login"
url_name="Naarad Login"
t={t}
/>
),
{ duration: 3000 }
);
if (PROD) {
toast.custom(
(t) => (
<RedirectToast
duration={3000}
redirect_url="https://naarad.metakgp.org/login"
url_name="Naarad Login"
t={t}
/>
),
{ duration: 3000 }
);
}
} else if (data.status == 401) {
setIsLoad(true);
setStatus("Redirecting to Heimdall");

toast.custom(
(t) => (
<RedirectToast
duration={3000}
redirect_url="https://heimdall.metakgp.org?redirect_url=https://naarad.metakgp.org/signup"
url_name="Heimdall"
t={t}
/>
),
{ duration: 3000 }
);
if (PROD) {
toast.custom(
(t) => (
<RedirectToast
duration={3000}
redirect_url="https://heimdall.metakgp.org?redirect_url=https://naarad.metakgp.org/signup"
url_name="Heimdall"
t={t}
/>
),
{ duration: 3000 }
);
}
} else {
setIsLoad(false);
setIsErr(true);
Expand Down Expand Up @@ -107,7 +120,7 @@ export const Register: Component = () => {
<div class="reg-footer">
<p class="reg-footer">
Made with ❤️ and {"</>"}
<br/>
<br />
<a
href="https://github.com/metakgp/naarad"
target="_blank"
Expand Down

0 comments on commit 9efa665

Please sign in to comment.