Plan stuff WIPWIPWIP
This commit is contained in:
parent
8752680233
commit
ac56fa36ba
8 changed files with 111 additions and 62 deletions
|
@ -175,6 +175,20 @@ class Api {
|
|||
}
|
||||
}
|
||||
|
||||
async getAccount(baseUrl, token) {
|
||||
const url = accountUrl(baseUrl);
|
||||
console.log(`[Api] Fetching user account ${url}`);
|
||||
const response = await fetch(url, {
|
||||
headers: maybeWithBearerAuth({}, token)
|
||||
});
|
||||
if (response.status !== 200) {
|
||||
throw new Error(`Unexpected server response ${response.status}`);
|
||||
}
|
||||
const account = await response.json();
|
||||
console.log(`[Api] Account`, account);
|
||||
return account;
|
||||
}
|
||||
|
||||
async deleteAccount(baseUrl, token) {
|
||||
const url = accountUrl(baseUrl);
|
||||
console.log(`[Api] Deleting user account ${url}`);
|
||||
|
@ -202,20 +216,6 @@ class Api {
|
|||
}
|
||||
}
|
||||
|
||||
async getAccountSettings(baseUrl, token) {
|
||||
const url = accountSettingsUrl(baseUrl);
|
||||
console.log(`[Api] Fetching user account ${url}`);
|
||||
const response = await fetch(url, {
|
||||
headers: maybeWithBearerAuth({}, token)
|
||||
});
|
||||
if (response.status !== 200) {
|
||||
throw new Error(`Unexpected server response ${response.status}`);
|
||||
}
|
||||
const account = await response.json();
|
||||
console.log(`[Api] Account`, account);
|
||||
return account;
|
||||
}
|
||||
|
||||
async updateAccountSettings(baseUrl, token, payload) {
|
||||
const url = accountSettingsUrl(baseUrl);
|
||||
const body = JSON.stringify(payload);
|
||||
|
|
|
@ -52,6 +52,8 @@ const Basics = () => {
|
|||
const Stats = () => {
|
||||
const { t } = useTranslation();
|
||||
const { account } = useOutletContext();
|
||||
const admin = account?.role === "admin"
|
||||
const accountType = account?.plan?.name ?? "Free";
|
||||
return (
|
||||
<Card sx={{p: 3}} aria-label={t("xxxxxxxxx")}>
|
||||
<Typography variant="h5" sx={{marginBottom: 2}}>
|
||||
|
@ -62,7 +64,7 @@ const Stats = () => {
|
|||
<div>
|
||||
{account?.role === "admin"
|
||||
? <>Unlimited <Tooltip title={"You are Admin"}><span style={{cursor: "default"}}>👑</span></Tooltip></>
|
||||
: "Free"}
|
||||
: accountType}
|
||||
</div>
|
||||
</Pref>
|
||||
<Pref labelId={"dailyMessages"} title={t("Daily messages")}>
|
||||
|
|
|
@ -96,7 +96,7 @@ const Layout = () => {
|
|||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const acc = await api.getAccountSettings("http://localhost:2586", session.token());
|
||||
const acc = await api.getAccount("http://localhost:2586", session.token());
|
||||
if (acc) {
|
||||
setAccount(acc);
|
||||
if (acc.language) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue