-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
a93c328
commit 591d35a
Showing
11 changed files
with
487 additions
and
304 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
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
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,85 +1,117 @@ | ||
import { Alert, Button, Drawer, DrawerBody, Text,DrawerContent, DrawerHeader, DrawerOverlay, Flex, useDisclosure } from "@chakra-ui/react"; | ||
import { SubjectObjectVal, SubjectOjectType } from "~/types/typedef"; | ||
import SubjectCard from "./CourseCard"; | ||
import { ArrowUpIcon } from "@chakra-ui/icons"; | ||
import { useMemo } from "react"; | ||
import { BiExit } from "react-icons/bi"; | ||
import Link from "next/link"; | ||
import { | ||
Alert, | ||
Button, | ||
Drawer, | ||
DrawerBody, | ||
Text, | ||
DrawerContent, | ||
DrawerHeader, | ||
DrawerOverlay, | ||
Flex, | ||
useDisclosure | ||
} from '@chakra-ui/react'; | ||
import { SubjectObjectVal, SubjectOjectType } from '~/types/typedef'; | ||
import SubjectCard from './CourseCard'; | ||
import { ArrowUpIcon } from '@chakra-ui/icons'; | ||
import { useMemo } from 'react'; | ||
import { BiExit } from 'react-icons/bi'; | ||
import Link from 'next/link'; | ||
|
||
export default function CourseCart ( | ||
{ subjects, removeCartItemHandle }: | ||
{ subjects: SubjectOjectType,removeCartItemHandle: (subj: string)=>void } | ||
) { | ||
const { isOpen, onOpen, onClose } = useDisclosure() | ||
const isEmpty = useMemo(()=> Object.values(subjects).filter(s=>s.isInCart).length == 0,[subjects]) | ||
export default function CourseCart({ | ||
subjects, | ||
removeCartItemHandle | ||
}: { | ||
subjects: SubjectOjectType; | ||
removeCartItemHandle: (subj: string) => void; | ||
}) { | ||
const { isOpen, onOpen, onClose } = useDisclosure(); | ||
const isEmpty = useMemo( | ||
() => Object.values(subjects).filter((s) => s.isInCart).length == 0, | ||
[subjects] | ||
); | ||
|
||
return <> | ||
<Flex w={'100%'} position={'fixed'} | ||
bottom={0} | ||
py={'1rem'} borderTop={'1px solid'} | ||
borderColor={'var(--border-color)'} | ||
justifyContent={'center'} | ||
bg={'var(--bg-color)'} | ||
zIndex={2} | ||
alignContent={'center'} | ||
flexDir={'column'} | ||
alignItems={'center'} | ||
> | ||
<Flex flexDir={'column'} gap={2}> | ||
|
||
<Button variant={'outline'} size={'sm'} position={'relative'} | ||
onClick={onOpen} | ||
> | ||
View Your Courses | ||
<ArrowUpIcon /> | ||
{!isEmpty && <Flex position={'absolute'} | ||
width={'8px'} height={'8px'} bg={'red'} | ||
rounded={'full'} | ||
top={-1} | ||
right={-1} | ||
> | ||
{' '} | ||
</Flex>} | ||
</Button> | ||
<Link href={`/discussions?active_route=View&discussion_id=4NgpCTfJ2cX8Tkzdbs3C`}> | ||
<Text fontSize={'sm'} color={'blue.200'} textDecoration={'underline'} | ||
_hover={{ | ||
cursor: 'pointer', | ||
color: 'blue.300' | ||
}} | ||
> | ||
{"Don't know how to use? View this post"} | ||
</Text> | ||
</Link> | ||
return ( | ||
<> | ||
<Flex | ||
w={'100%'} | ||
position={'fixed'} | ||
bottom={0} | ||
py={'1rem'} | ||
borderTop={'1px solid'} | ||
borderColor={'var(--border-color)'} | ||
justifyContent={'center'} | ||
bg={'var(--bg-color)'} | ||
zIndex={2} | ||
alignContent={'center'} | ||
flexDir={'column'} | ||
alignItems={'center'}> | ||
<Flex flexDir={'column'} gap={2}> | ||
<Button variant={'outline'} size={'sm'} position={'relative'} onClick={onOpen}> | ||
View Your Courses | ||
<ArrowUpIcon /> | ||
{!isEmpty && ( | ||
<Flex | ||
position={'absolute'} | ||
width={'8px'} | ||
height={'8px'} | ||
bg={'red'} | ||
rounded={'full'} | ||
top={-1} | ||
right={-1}> | ||
{' '} | ||
</Flex> | ||
)} | ||
</Button> | ||
<Link | ||
href={`/discussions?active_route=View&discussion_id=4NgpCTfJ2cX8Tkzdbs3C`}> | ||
<Text | ||
fontSize={'sm'} | ||
color={'blue.200'} | ||
textDecoration={'underline'} | ||
_hover={{ | ||
cursor: 'pointer', | ||
color: 'blue.300' | ||
}}> | ||
{"Don't know how to use? View this post"} | ||
</Text> | ||
</Link> | ||
</Flex> | ||
</Flex> | ||
</Flex> | ||
|
||
{/* Drawer */} | ||
<Drawer placement={'bottom'} onClose={onClose} isOpen={isOpen} size={'xl'}> | ||
<DrawerOverlay /> | ||
<DrawerContent> | ||
<DrawerHeader borderBottomWidth='1px'> | ||
Your Courses | ||
<Button colorScheme="red" size={'sm'} float={'right'} onClick={onClose}> | ||
<BiExit /> | ||
</Button> | ||
</DrawerHeader> | ||
<DrawerBody maxH={'80vh'} overflowY={'auto'}> | ||
<Flex mb={'5rem'} flexDir={'column'} justifyContent={'center'}> | ||
{isEmpty && <Text>No, Course added so far</Text>} | ||
{Object.entries(subjects) | ||
.filter(e=> e[1].isInCart) | ||
.map(([subjName,subj]:[string,SubjectObjectVal],i)=>{ | ||
return <SubjectCard | ||
key={i} | ||
name={subjName} | ||
subject = {subj} | ||
onRemove={removeCartItemHandle} | ||
/> | ||
})} | ||
</Flex> | ||
</DrawerBody> | ||
</DrawerContent> | ||
</Drawer> | ||
</> | ||
{/* Drawer */} | ||
<Drawer | ||
placement={'bottom'} | ||
onClose={onClose} | ||
isOpen={isOpen} | ||
size={'xl'} | ||
allowPinchZoom> | ||
<DrawerOverlay /> | ||
<DrawerContent> | ||
<DrawerHeader borderBottomWidth="1px"> | ||
Your Courses | ||
<Button colorScheme="red" size={'sm'} float={'right'} onClick={onClose}> | ||
<BiExit /> | ||
</Button> | ||
</DrawerHeader> | ||
<DrawerBody maxH={'80vh'} overflowY={'auto'}> | ||
<Flex mb={'5rem'} flexDir={'column'} justifyContent={'center'}> | ||
{isEmpty && <Text>No, Course added so far</Text>} | ||
{Object.entries(subjects) | ||
.filter((e) => e[1].isInCart) | ||
.map(([subjName, subj]: [string, SubjectObjectVal], i) => { | ||
return ( | ||
<SubjectCard | ||
key={i} | ||
name={subjName} | ||
subject={subj} | ||
onRemove={removeCartItemHandle} | ||
/> | ||
); | ||
})} | ||
</Flex> | ||
</DrawerBody> | ||
</DrawerContent> | ||
</Drawer> | ||
</> | ||
); | ||
} |
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 |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { BiLoader } from 'react-icons/bi'; | ||
import Loader from '../design/Loader'; | ||
import { Flex } from '@chakra-ui/react'; | ||
|
||
const LoadingOverlay = () => { | ||
return ( | ||
<Flex | ||
position={'fixed'} | ||
top={2} | ||
right={2} | ||
bottom={0} | ||
left={2} | ||
bg={'var(--bg-dark)'} | ||
zIndex={9999} | ||
justifyContent={'center'} | ||
alignContent={'center'} | ||
alignItems={'center'}> | ||
<Flex | ||
p={5} | ||
bg={'black'} | ||
rounded={'md'} | ||
gap={2} | ||
alignItems={'center'} | ||
border={'2px solid'} | ||
borderColor={'var(--border-color)'}> | ||
<Loader | ||
style={{ | ||
display: 'flex', | ||
flexDirection: 'column', | ||
alignItems: 'center', | ||
gap: '0.5rem', | ||
justifyContent: 'center' | ||
}}> | ||
<BiLoader className="spinner" /> | ||
Wait, Updating Subjects | ||
</Loader> | ||
</Flex>{' '} | ||
</Flex> | ||
); | ||
}; | ||
|
||
export default LoadingOverlay; |
Oops, something went wrong.