mirror of
https://github.com/AykutSarac/jsoncrack.com.git
synced 2025-01-20 05:12:54 +08:00
feat: update account ui
This commit is contained in:
parent
4661578d8f
commit
b9b6c1d381
@ -1,49 +1,20 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import styled from "styled-components";
|
import {
|
||||||
import { Modal, Group, Button, Badge, Avatar, Grid, Divider, ModalProps } from "@mantine/core";
|
Modal,
|
||||||
|
Group,
|
||||||
|
Button,
|
||||||
|
Avatar,
|
||||||
|
Text,
|
||||||
|
Divider,
|
||||||
|
ModalProps,
|
||||||
|
Paper,
|
||||||
|
Badge,
|
||||||
|
} from "@mantine/core";
|
||||||
import { useUser as useSupaUser } from "@supabase/auth-helpers-react";
|
import { useUser as useSupaUser } from "@supabase/auth-helpers-react";
|
||||||
import dayjs from "dayjs";
|
|
||||||
import { IoRocketSharp } from "react-icons/io5";
|
import { IoRocketSharp } from "react-icons/io5";
|
||||||
import useModal from "src/store/useModal";
|
import useModal from "src/store/useModal";
|
||||||
import useUser from "src/store/useUser";
|
import useUser from "src/store/useUser";
|
||||||
|
|
||||||
const StyledTitle = styled.div`
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
color: ${({ theme }) => theme.TEXT_POSITIVE};
|
|
||||||
flex: 1;
|
|
||||||
font-weight: 700;
|
|
||||||
|
|
||||||
&::after {
|
|
||||||
background: ${({ theme }) => theme.TEXT_POSITIVE};
|
|
||||||
height: 1px;
|
|
||||||
|
|
||||||
content: "";
|
|
||||||
-webkit-box-flex: 1;
|
|
||||||
-ms-flex: 1 1 auto;
|
|
||||||
flex: 1 1 auto;
|
|
||||||
margin-left: 4px;
|
|
||||||
opacity: 0.6;
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
const StyledContainer = styled.div`
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
gap: 8px;
|
|
||||||
padding: 12px 0;
|
|
||||||
font-size: 12px;
|
|
||||||
line-height: 16px;
|
|
||||||
font-weight: 600;
|
|
||||||
color: ${({ theme }) => theme.INTERACTIVE_NORMAL};
|
|
||||||
|
|
||||||
& > div {
|
|
||||||
font-weight: 400;
|
|
||||||
font-size: 14px;
|
|
||||||
color: ${({ theme }) => theme.INTERACTIVE_ACTIVE};
|
|
||||||
}
|
|
||||||
`;
|
|
||||||
|
|
||||||
export const AccountModal: React.FC<ModalProps> = ({ opened, onClose }) => {
|
export const AccountModal: React.FC<ModalProps> = ({ opened, onClose }) => {
|
||||||
const user = useSupaUser();
|
const user = useSupaUser();
|
||||||
const isPremium = useUser(state => state.premium);
|
const isPremium = useUser(state => state.premium);
|
||||||
@ -53,56 +24,40 @@ export const AccountModal: React.FC<ModalProps> = ({ opened, onClose }) => {
|
|||||||
const logout = useUser(state => state.logout);
|
const logout = useUser(state => state.logout);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal title="Account" opened={opened} onClose={onClose} centered>
|
<Modal title={`Hello, ${user?.user_metadata.name}!`} opened={opened} onClose={onClose} centered>
|
||||||
<StyledTitle>Hello, {user?.user_metadata.name}!</StyledTitle>
|
<Paper p="md">
|
||||||
<Group py="sm">
|
<Group noWrap>
|
||||||
<Grid gutter="xs">
|
<Avatar src={user?.user_metadata.avatar_url} size={94}>
|
||||||
<Grid.Col span={2}>
|
JC
|
||||||
<Avatar
|
</Avatar>
|
||||||
size="lg"
|
<div>
|
||||||
radius="lg"
|
<Text fz="lg" tt="uppercase" fw={700}>
|
||||||
src={user?.user_metadata.avatar_url}
|
{user?.user_metadata.name}
|
||||||
alt={user?.user_metadata.name}
|
</Text>
|
||||||
/>
|
|
||||||
</Grid.Col>
|
<Group noWrap spacing={10} mt={3}>
|
||||||
<Grid.Col span={4}>
|
<Text fz="xs" c="dimmed">
|
||||||
<StyledContainer>
|
{user?.email}
|
||||||
USERNAME
|
</Text>
|
||||||
<div>{user?.user_metadata.name}</div>
|
</Group>
|
||||||
</StyledContainer>
|
|
||||||
</Grid.Col>
|
<Group noWrap spacing={10} mt={5}>
|
||||||
<Grid.Col span={6}>
|
<Text fz="xs" c="dimmed">
|
||||||
<StyledContainer>
|
<Badge
|
||||||
ACCOUNT STATUS
|
size="sm"
|
||||||
<div>
|
variant={isPremium ? "gradient" : "dot"}
|
||||||
{isPremium ? (
|
color={premiumCancelled || !isPremium ? "dark" : "green"}
|
||||||
<Badge color={premiumCancelled ? "teal" : "indigo"}>
|
gradient={{ from: "#8800fe", to: "#ff00cc", deg: 35 }}
|
||||||
Premium {premiumCancelled ? "(Cancelled)" : isOrg && "(Organization)"}
|
>
|
||||||
</Badge>
|
{isPremium ? "Premium" : "Free"}{" "}
|
||||||
) : (
|
{premiumCancelled ? "(Cancelled)" : isOrg && "(Organization)"}
|
||||||
<Badge variant="outline" color="gray">
|
</Badge>
|
||||||
Free
|
</Text>
|
||||||
</Badge>
|
</Group>
|
||||||
)}
|
</div>
|
||||||
</div>
|
</Group>
|
||||||
</StyledContainer>
|
</Paper>
|
||||||
</Grid.Col>
|
|
||||||
<Grid.Col span={6}>
|
|
||||||
<StyledContainer>
|
|
||||||
EMAIL
|
|
||||||
<div>{user?.user_metadata.email}</div>
|
|
||||||
</StyledContainer>
|
|
||||||
</Grid.Col>
|
|
||||||
{user?.created_at && (
|
|
||||||
<Grid.Col span={4}>
|
|
||||||
<StyledContainer>
|
|
||||||
REGISTRATION
|
|
||||||
<div>{dayjs(user.created_at).format("DD MMMM YYYY")}</div>
|
|
||||||
</StyledContainer>
|
|
||||||
</Grid.Col>
|
|
||||||
)}
|
|
||||||
</Grid>
|
|
||||||
</Group>
|
|
||||||
<Divider py="xs" />
|
<Divider py="xs" />
|
||||||
<Group position="right">
|
<Group position="right">
|
||||||
{isPremium && !premiumCancelled ? (
|
{isPremium && !premiumCancelled ? (
|
||||||
|
@ -57,7 +57,10 @@ const UpdateNameModal: React.FC<{
|
|||||||
error: "Error occurred while updating document!",
|
error: "Error occurred while updating document!",
|
||||||
success: `Renamed document to ${name}`,
|
success: `Renamed document to ${name}`,
|
||||||
})
|
})
|
||||||
.then(() => refetch());
|
.then(() => {
|
||||||
|
refetch();
|
||||||
|
setName("");
|
||||||
|
});
|
||||||
|
|
||||||
onClose();
|
onClose();
|
||||||
};
|
};
|
||||||
|
@ -13,7 +13,6 @@ import {
|
|||||||
Divider,
|
Divider,
|
||||||
Anchor,
|
Anchor,
|
||||||
Stack,
|
Stack,
|
||||||
Title,
|
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useForm } from "@mantine/form";
|
import { useForm } from "@mantine/form";
|
||||||
import { useToggle, upperFirst } from "@mantine/hooks";
|
import { useToggle, upperFirst } from "@mantine/hooks";
|
||||||
@ -94,11 +93,14 @@ export function AuthenticationForm(props: PaperProps) {
|
|||||||
if (done) {
|
if (done) {
|
||||||
return (
|
return (
|
||||||
<Paper mih={100}>
|
<Paper mih={100}>
|
||||||
<Title align="center" order={2}>
|
<Text align="center" mt="lg">
|
||||||
Registration successul!
|
Registration successul!
|
||||||
<br />
|
<br />
|
||||||
Please check your inbox for email confirmation.
|
Please check your inbox for email confirmation.
|
||||||
</Title>
|
</Text>
|
||||||
|
<Button radius="sm" size="md" mt="lg" onClick={() => window.location.reload()} fullWidth>
|
||||||
|
Back to login
|
||||||
|
</Button>
|
||||||
</Paper>
|
</Paper>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user