Add User Info Page

This commit is contained in:
Elias Schneider
2022-05-11 13:50:28 +02:00
parent 80f055899c
commit 3cb7285e8f
11 changed files with 274 additions and 68 deletions

View File

@@ -0,0 +1,43 @@
import { ActionIcon, Avatar, Menu } from "@mantine/core";
import { NextLink } from "@mantine/next";
import { DoorExit, Link } from "tabler-icons-react";
import aw from "../../utils/appwrite.util";
const ActionAvatar = () => {
return (
<Menu
control={
<ActionIcon>
<Avatar size={28} radius="xl" />
</ActionIcon>
}
>
<Menu.Label>My account</Menu.Label>
<Menu.Item
component={NextLink}
href="/account/shares"
icon={<Link size={14} />}
>
Shares
</Menu.Item>
{/* <Menu.Item
component={NextLink}
href="/account/shares"
icon={<Settings size={14} />}
>
Settings
</Menu.Item> */}
<Menu.Item
onClick={async () => {
await aw.account.deleteSession("current");
window.location.reload();
}}
icon={<DoorExit size={14} />}
>
Sign out
</Menu.Item>
</Menu>
);
};
export default ActionAvatar;

View File

@@ -13,10 +13,9 @@ import { NextLink } from "@mantine/next";
import Image from "next/image";
import React, { useContext, useEffect, useState } from "react";
import headerStyle from "../../styles/header.style";
import aw from "../../utils/appwrite.util";
import { IsSignedInContext } from "../../utils/auth.util";
import { useConfig } from "../../utils/config.util";
import ToggleThemeButton from "./ToggleThemeButton";
import ActionAvatar from "./ActionAvatar";
type Link = {
link?: string;
@@ -36,26 +35,21 @@ const Header = () => {
link: "/upload",
label: "Upload",
},
{
label: "Sign out",
action: async () => {
await aw.account.deleteSession("current");
window.location.reload();
},
},
];
const unauthenticatedLinks: Link[] | undefined = [
{
link: "/",
label: "Home",
},
{
link: "/auth/signIn",
label: "Sign in",
},
];
if (!config.DISABLE_HOME_PAGE)
unauthenticatedLinks.unshift({
link: "/",
label: "Home",
});
if (!config.DISABLE_REGISTRATION)
unauthenticatedLinks.push({
link: "/auth/signUp",
@@ -67,11 +61,11 @@ const Header = () => {
const items = links.map((link) => {
if (link) {
// eslint-disable-next-line react-hooks/rules-of-hooks
// useEffect(() => {
// if (window.location.pathname == link.link) {
// setActive(link.link);
// }
// });
useEffect(() => {
if (window.location.pathname == link.link) {
setActive(link.link);
}
});
return (
<NextLink
key={link.label}
@@ -104,9 +98,8 @@ const Header = () => {
<Group spacing={5} className={classes.links}>
{items}
<Space w={5} />
<ToggleThemeButton />
{isSignedIn && <ActionAvatar />}
</Group>
<Burger
opened={opened}
onClick={() => toggleOpened()}

View File

@@ -32,7 +32,10 @@ const CreateUploadModalBody = ({
const modals = useModals();
const validationSchema = yup.object().shape({
link: yup.string().required().min(2).max(50),
emails: mode == "email" ? yup.array().of(yup.string().email()).min(1) : yup.array(),
emails:
mode == "email"
? yup.array().of(yup.string().email()).min(1)
: yup.array(),
password: yup.string().min(3).max(100),
maxVisitors: yup.number().min(1),
});

View File

@@ -42,6 +42,7 @@ const FileList = ({
height={30}
alt={file.name}
objectFit="cover"
style={{ borderRadius: 3 }}
src={`data:image/png;base64,${new Buffer(file.preview).toString(
"base64"
)}`}