-
Notifications
You must be signed in to change notification settings - Fork 31
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
Showing
17 changed files
with
241 additions
and
1,897 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
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { useInfo } from "src/hooks/useInfo"; | ||
import { Outlet, useLocation, useNavigate } from "react-router-dom"; | ||
import React from "react"; | ||
import Loading from "src/components/Loading"; | ||
|
||
export function AppsRedirect() { | ||
const { data: info } = useInfo(); | ||
const location = useLocation(); | ||
const navigate = useNavigate(); | ||
|
||
// TODO: re-add login redirect: https://github.com/getAlby/nostr-wallet-connect/commit/59b041886098dda4ff38191e3dd704ec36360673 | ||
React.useEffect(() => { | ||
if (!info || info.running) { | ||
return; | ||
} | ||
navigate("/"); | ||
}, [info, location, navigate]); | ||
|
||
if (!info) { | ||
return <Loading />; | ||
} | ||
|
||
return <Outlet />; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useInfo } from "src/hooks/useInfo"; | ||
import { useLocation, useNavigate } from "react-router-dom"; | ||
import React from "react"; | ||
import Loading from "src/components/Loading"; | ||
|
||
export function HomeRedirect() { | ||
const { data: info } = useInfo(); | ||
const location = useLocation(); | ||
const navigate = useNavigate(); | ||
|
||
React.useEffect(() => { | ||
if (!info) { | ||
return; | ||
} | ||
let to: string | undefined; | ||
if (info.setupCompleted && info.running) { | ||
to = "/apps"; | ||
} else if (info.setupCompleted && !info.running) { | ||
to = "/start"; | ||
} else { | ||
to = "/welcome"; | ||
} | ||
navigate(to); | ||
}, [info, location, navigate]); | ||
|
||
if (!info) { | ||
return <Loading />; | ||
} | ||
} |
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 |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { useInfo } from "src/hooks/useInfo"; | ||
import { useLocation, useNavigate } from "react-router-dom"; | ||
import React from "react"; | ||
import Loading from "src/components/Loading"; | ||
|
||
export function StartRedirect({ children }: React.PropsWithChildren) { | ||
const { data: info } = useInfo(); | ||
const location = useLocation(); | ||
const navigate = useNavigate(); | ||
|
||
// TODO: re-add login redirect: https://github.com/getAlby/nostr-wallet-connect/commit/59b041886098dda4ff38191e3dd704ec36360673 | ||
React.useEffect(() => { | ||
if (!info || (info.setupCompleted && !info.running)) { | ||
return; | ||
} | ||
navigate("/"); | ||
}, [info, location, navigate]); | ||
|
||
if (!info) { | ||
return <Loading />; | ||
} | ||
|
||
return children; | ||
} |
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 |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import { Link } from "react-router-dom"; | ||
|
||
export function Welcome() { | ||
return ( | ||
<div className="flex flex-col justify-center items-center gap-10"> | ||
<p>Welcome to NWC!</p> | ||
<p>NWC is ... and allows you to ...</p> | ||
<Link to="/about" className="text-purple-500"> | ||
Learn more | ||
</Link> | ||
|
||
<Link to="/setup" className="text-green-500"> | ||
Get Started | ||
</Link> | ||
</div> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import React from "react"; | ||
import { useNavigate } from "react-router-dom"; | ||
import { useInfo } from "src/hooks/useInfo"; | ||
import useSetupStore from "src/state/SetupStore"; | ||
|
||
export function SetupPassword() { | ||
const store = useSetupStore(); | ||
const [confirmPassword, setConfirmPassword] = React.useState(""); | ||
const navigate = useNavigate(); | ||
const { data: info } = useInfo(); | ||
|
||
function onSubmit(e: React.FormEvent) { | ||
e.preventDefault(); | ||
if (store.unlockPassword !== confirmPassword) { | ||
alert("Password doesn't match!"); | ||
return; | ||
} | ||
navigate("/setup/node"); | ||
} | ||
|
||
return ( | ||
<> | ||
{info?.setupCompleted && ( | ||
<p className="mb-4 text-red-500"> | ||
Your node is already setup! only continue if you actually want to | ||
change your connection settings. | ||
</p> | ||
)} | ||
<form onSubmit={onSubmit}> | ||
<div> | ||
<label | ||
htmlFor="unlock-password" | ||
className="block font-medium text-gray-900 dark:text-white" | ||
> | ||
Choose an unlock password | ||
</label> | ||
<p className="text-sm"> | ||
This will encrypt your node information for next time you start NWC. | ||
You'll also be asked to confirm your password when you setup a new | ||
app connection. | ||
</p> | ||
<input | ||
name="unlock-password" | ||
onChange={(e) => store.setUnlockPassword(e.target.value)} | ||
value={store.unlockPassword} | ||
type="password" | ||
id="unlock-password" | ||
className="mb-4 dark:bg-surface-00dp block w-full rounded-lg border border-gray-300 bg-gray-50 p-2.5 text-sm text-gray-900 focus:ring-2 focus:ring-purple-700 dark:border-gray-700 dark:text-white dark:placeholder-gray-400 dark:ring-offset-gray-800 dark:focus:ring-purple-600" | ||
/> | ||
<label | ||
htmlFor="confirm-password" | ||
className="block font-medium text-gray-900 dark:text-white" | ||
> | ||
Confirm password | ||
</label> | ||
<input | ||
name="confirm-password" | ||
onChange={(e) => setConfirmPassword(e.target.value)} | ||
value={confirmPassword} | ||
type="password" | ||
id="confirm-password" | ||
className="mb-4 dark:bg-surface-00dp block w-full rounded-lg border border-gray-300 bg-gray-50 p-2.5 text-sm text-gray-900 focus:ring-2 focus:ring-purple-700 dark:border-gray-700 dark:text-white dark:placeholder-gray-400 dark:ring-offset-gray-800 dark:focus:ring-purple-600" | ||
/> | ||
</div> | ||
<button>Submit</button> | ||
</form> | ||
</> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import { create } from "zustand"; | ||
|
||
interface SetupStore { | ||
readonly unlockPassword: string; | ||
setUnlockPassword(unlockPassword: string): void; | ||
} | ||
|
||
const useSetupStore = create<SetupStore>((set) => ({ | ||
unlockPassword: "", | ||
setUnlockPassword: (unlockPassword) => set({ unlockPassword }), | ||
})); | ||
|
||
export default useSetupStore; |
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
Oops, something went wrong.