|
| 1 | +import * as React from "react" |
| 2 | + |
| 3 | +import { convertBytes } from "helpers/util" |
| 4 | +import { Icon } from "@chakra-ui/icons" |
| 5 | +import { FileSearch } from "components/FileSearch" |
| 6 | +import { Page } from "layouts/Page" |
| 7 | +import Router from "next/router" |
| 8 | +import PlusIcon from "assets/icons/plus.svg" |
| 9 | +import { Authenticated } from "components/Authenticated" |
| 10 | +import { |
| 11 | + Box, |
| 12 | + Divider, |
| 13 | + Flex, |
| 14 | + Heading, |
| 15 | + Text, |
| 16 | + Stack, |
| 17 | + Stat, |
| 18 | + StatLabel, |
| 19 | + StatNumber, |
| 20 | + ToastId, |
| 21 | + useToast, |
| 22 | + Button, |
| 23 | + useDisclosure, |
| 24 | + Modal, |
| 25 | + ModalOverlay, |
| 26 | + ModalContent, |
| 27 | + ModalHeader, |
| 28 | + ModalCloseButton, |
| 29 | + ModalBody, |
| 30 | + FormControl, |
| 31 | + FormLabel, |
| 32 | + Input, |
| 33 | + ModalFooter, |
| 34 | + Checkbox |
| 35 | +} from "@chakra-ui/react" |
| 36 | +import api from "helpers/api" |
| 37 | +import { useForm } from "react-hook-form" |
| 38 | + |
| 39 | +const Albums: React.FC = () => { |
| 40 | + const toast = useToast() |
| 41 | + const { isOpen, onOpen, onClose } = useDisclosure() |
| 42 | + const albumForm = useForm() |
| 43 | + |
| 44 | + return <Authenticated> |
| 45 | + <Page title="Albums"> |
| 46 | + <Flex mt="7em" justify="center"> |
| 47 | + <Box w={{ base: "90vw", md: "70vw" }} maxW="1200px"> |
| 48 | + <Stack spacing={4}> |
| 49 | + <Heading>Albums</Heading> |
| 50 | + <Text as="h2" fontSize="sm" color="gray.400"> |
| 51 | + Create albums to share with others |
| 52 | + </Text> |
| 53 | + |
| 54 | + <Button |
| 55 | + onClick={onOpen} |
| 56 | + bg="primary.500" |
| 57 | + _hover={{ |
| 58 | + bg: "primary.600" |
| 59 | + }} |
| 60 | + color="white" |
| 61 | + position="fixed" |
| 62 | + bottom="3em" |
| 63 | + right="3em" |
| 64 | + borderRadius="50px" |
| 65 | + w="60px" |
| 66 | + h="60px" |
| 67 | + zIndex={4}> |
| 68 | + <Icon w={5} h={5} as={PlusIcon} /> |
| 69 | + </Button> |
| 70 | + <Modal isOpen={isOpen} onClose={onClose}> |
| 71 | + <ModalOverlay /> |
| 72 | + <ModalContent> |
| 73 | + <form onSubmit={albumForm.handleSubmit((data) => console.log(data))}> |
| 74 | + <ModalHeader>Create Album</ModalHeader> |
| 75 | + <ModalCloseButton /> |
| 76 | + <ModalBody > |
| 77 | + <FormControl> |
| 78 | + <FormLabel>Name</FormLabel> |
| 79 | + <Input |
| 80 | + placeholder={"Album Name"} |
| 81 | + {...albumForm.register("name")} |
| 82 | + /> |
| 83 | + </FormControl> |
| 84 | + <FormControl mt={3}> |
| 85 | + <FormLabel>Description</FormLabel> |
| 86 | + <Input |
| 87 | + placeholder={"Album Description"} |
| 88 | + {...albumForm.register("description")} |
| 89 | + /> |
| 90 | + |
| 91 | + </FormControl> |
| 92 | + <FormControl mt={3}> |
| 93 | + <Checkbox {...albumForm.register("public")}>Public</Checkbox> |
| 94 | + </FormControl> |
| 95 | + </ModalBody> |
| 96 | + <ModalFooter> |
| 97 | + <Button variant='ghost' mr={3} onClick={onClose}> |
| 98 | + Cancel |
| 99 | + </Button> |
| 100 | + <Button colorScheme="primary" type="submit">Create</Button> |
| 101 | + </ModalFooter> |
| 102 | + </form> |
| 103 | + </ModalContent> |
| 104 | + </Modal> |
| 105 | + </Stack> |
| 106 | + </Box> |
| 107 | + </Flex> |
| 108 | + {/* <Flex mt="7em" minH="100vh" justify="center" mb={5}> |
| 109 | + <Box w={{ base: "90vw", md: "70vw" }} maxW="1200px"> |
| 110 | + <Stack spacing={4}> |
| 111 | + <Heading>Uploads</Heading> |
| 112 | + <input type="file" ref={shadowUploader} onChange={uploadCallback} style={{ display: "none" }} multiple /> |
| 113 | + <Button |
| 114 | + onClick={uploadButtonCallback} |
| 115 | + bg="primary.500" |
| 116 | + _hover={{ |
| 117 | + bg: "primary.600" |
| 118 | + }} |
| 119 | + color="white" |
| 120 | + position="fixed" |
| 121 | + bottom="3em" |
| 122 | + right="3em" |
| 123 | + borderRadius="50px" |
| 124 | + w="60px" |
| 125 | + h="60px" |
| 126 | + zIndex={4}> |
| 127 | + <Icon w={5} h={5} as={UploadIcon} /> |
| 128 | + </Button> |
| 129 | + <Divider /> |
| 130 | + <Box> |
| 131 | + <Stat> |
| 132 | + <StatLabel>Usage</StatLabel> |
| 133 | + <StatNumber>{usage}</StatNumber> |
| 134 | + </Stat> |
| 135 | + </Box> |
| 136 | + <Divider /> |
| 137 | + <FileSearch |
| 138 | + key={searchReload} |
| 139 | + onSearch={(page, query) => api.upload.list(page.toString(), "@me", query)} |
| 140 | + onDelete={deleteCallback} |
| 141 | + onFileDetails={fileId => Router.push(`/user/uploads/${fileId}`)} /> |
| 142 | + </Stack> |
| 143 | + </Box> |
| 144 | + </Flex> */} |
| 145 | + </Page> |
| 146 | + </Authenticated > |
| 147 | +} |
| 148 | + |
| 149 | +export default Albums |
0 commit comments