-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d270d06
commit 544dce9
Showing
6 changed files
with
64 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,15 +7,18 @@ import { Input } from "@/components/ui/input" | |
import { Label } from "@/components/ui/label" | ||
import { useInstallHook } from "@/hooks/use-install.hook" | ||
import { useLoginMutation } from "@/redux/services/auth.api" | ||
import { useGetGlobalAppVersionQuery } from "@/redux/services/versions.api" | ||
import { Spinner, Typography } from "@material-tailwind/react" | ||
import React, { useState } from "react" | ||
import React, { useEffect, useState } from "react" | ||
|
||
export default function Page() { | ||
const [email, setEmail] = useState("") | ||
const [password, setPassword] = useState("") | ||
const [login, { isLoading }] = useLoginMutation() | ||
const [hasError, setHasError] = useState(false) | ||
|
||
const { data, isLoading: isGlobalLoading } = useGetGlobalAppVersionQuery() | ||
|
||
useInstallHook() | ||
|
||
const handleSubmit = async (e: React.FormEvent) => { | ||
|
@@ -40,6 +43,13 @@ export default function Page() { | |
window.location.href = "/" | ||
} | ||
|
||
useEffect(() => { | ||
if (!isGlobalLoading && data?.isInstalled && data?.isMock) { | ||
setEmail("[email protected]") | ||
setPassword("password") | ||
} | ||
}, [isGlobalLoading, data]) | ||
|
||
return ( | ||
<section className="w-screen h-screen flex items-center"> | ||
<div className="w-full lg:grid lg:min-h-[600px] lg:grid-cols-2 xl:min-h-[800px]"> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,34 +8,50 @@ import { | |
CardFooter, | ||
Typography, | ||
} from "@material-tailwind/react" | ||
import { useState } from "react" | ||
import { useSearchParams } from "next/navigation" | ||
import { useCallback, useEffect, useState } from "react" | ||
|
||
export default function Page() { | ||
const searchParams = useSearchParams() | ||
const isMock = searchParams.get("mock") === "1" | ||
const [first, setFirst] = useState("") | ||
const [last, setLast] = useState("") | ||
const [email, setEmail] = useState("") | ||
const [password, setPassword] = useState("") | ||
|
||
const handleSubmit = async (e: React.FormEvent) => { | ||
e.preventDefault() | ||
const handleSubmit = useCallback( | ||
async (e: React.FormEvent) => { | ||
e.preventDefault() | ||
|
||
const response = await fetch("/api/versions/install", { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ | ||
first: first, | ||
last: last, | ||
email: email, | ||
password: password, | ||
}), | ||
}) | ||
const response = await fetch("/api/versions/install", { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ | ||
first: first, | ||
last: last, | ||
email: email, | ||
password: password, | ||
}), | ||
}) | ||
|
||
if (response.ok) { | ||
window.location.href = "/" | ||
if (response.ok) { | ||
window.location.href = "/" | ||
} | ||
}, | ||
[first, last, email, password] | ||
) | ||
|
||
useEffect(() => { | ||
if (isMock) { | ||
setFirst("Mock") | ||
setLast("User") | ||
setEmail("[email protected]") | ||
setPassword("password") | ||
handleSubmit({ preventDefault: () => {} } as React.FormEvent) | ||
} | ||
} | ||
}, [isMock, setFirst, setLast, setEmail, setPassword, handleSubmit]) | ||
|
||
return ( | ||
<section className="w-screen h-screen flex flex-col items-center mt-12"> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters