-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
Showing
198 changed files
with
3,784 additions
and
2,661 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,8 @@ | |
"react-dom": "18.3.1", | ||
"react-router": "6.26.0", | ||
"react-router-dom": "6.26.0", | ||
"sass": "1.77.8" | ||
"sass": "1.77.8", | ||
"dayjs": "1.11.13" | ||
}, | ||
"packageManager": "[email protected]", | ||
"scripts": { | ||
|
This file was deleted.
Oops, something went wrong.
106 changes: 0 additions & 106 deletions
106
app/client/src/modules/account/components/bsky/bsky.component.tsx
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,91 +1,19 @@ | ||
import React, { FormEvent, useCallback, useEffect, useState } from "react"; | ||
import { useAdmin, useApi } from "shared/hooks"; | ||
import { Account } from "shared/types"; | ||
import { TokensComponent } from "modules/admin/tokens.component"; | ||
import React, { useEffect } from "react"; | ||
import { useAccount } from "shared/hooks"; | ||
import { useNavigate } from "react-router-dom"; | ||
|
||
export const AdminComponent: React.FC = () => { | ||
const { getList, remove, add, update, account } = useAdmin(); | ||
const { getVersion } = useApi(); | ||
|
||
const [adminList, setAdminList] = useState<Account[]>([]); | ||
const [accountList, setAccountList] = useState<Account[]>([]); | ||
const [version, setVersion] = useState<string>(); | ||
|
||
const $reloadList = () => | ||
getList().then(({ data }) => setAdminList(data.adminList)); | ||
const { isLogged, setAsAdmin } = useAccount(); | ||
let navigate = useNavigate(); | ||
|
||
useEffect(() => { | ||
$reloadList(); | ||
getVersion().then(({ version }) => setVersion(version)); | ||
account.getList().then(({ data }) => setAccountList(data.accountList)); | ||
}, []); | ||
|
||
const removeAdmin = (email) => () => { | ||
remove(email).then(() => $reloadList()); | ||
}; | ||
|
||
const onSubmit = useCallback(async (event: FormEvent<HTMLFormElement>) => { | ||
event.preventDefault(); | ||
|
||
const data = new FormData(event.target as unknown as HTMLFormElement); | ||
const email = data.get("email") as string; | ||
|
||
if (!email) return; | ||
|
||
add(email).then(() => $reloadList()); | ||
}, []); | ||
|
||
const $update = () => { | ||
update().then(({ status }) => { | ||
if (status === 200) | ||
//TODO is updating! | ||
setTimeout(() => { | ||
window.location.reload(); | ||
}, 10_000); | ||
}); | ||
}; | ||
if (isLogged === null) return; | ||
if (!isLogged) return navigate("/login"); | ||
|
||
if (!adminList.length) return <div>Loading...</div>; | ||
setAsAdmin() | ||
.then(() => navigate("/")) | ||
.catch(() => navigate("/")); | ||
}, [isLogged, setAsAdmin]); | ||
|
||
return ( | ||
<div> | ||
<h1>Admin</h1> | ||
<div> | ||
{adminList.map((user) => ( | ||
<div key={user.accountId}> | ||
{user.email} - {user.username} | ||
<button onClick={removeAdmin(user.email)}>delete</button> | ||
</div> | ||
))} | ||
<br /> | ||
<form onSubmit={onSubmit}> | ||
<input name="email" placeholder="email" /> | ||
<button>add admin</button> | ||
</form> | ||
</div> | ||
<br /> | ||
<hr /> | ||
<h3>Update</h3> | ||
<button onClick={$update}>Update</button> | ||
<br /> | ||
<b>{version}</b> | ||
<br /> | ||
<TokensComponent /> | ||
<h1>Accounts</h1> | ||
<div> | ||
<div>Accounts: ({accountList.length})</div> | ||
{accountList.map((user) => ( | ||
<div key={user.accountId}> | ||
<label title={user.email}> | ||
{user.email.substring(0, 1)}***@*** | ||
{user.email.substring(user.email.length - 1, user.email.length)} | ||
</label> | ||
- {user.username} | ||
</div> | ||
))} | ||
</div> | ||
<br /> | ||
<br /> | ||
</div> | ||
); | ||
return <></>; | ||
}; |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.