Skip to content

Commit

Permalink
final backend piece is here
Browse files Browse the repository at this point in the history
  • Loading branch information
NullDefault committed Feb 9, 2021
1 parent 886b867 commit a510ca2
Show file tree
Hide file tree
Showing 5 changed files with 197 additions and 11 deletions.
8 changes: 5 additions & 3 deletions src/components/adminInterfaces/BlogInterface.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
FormLabel,
Heading,
Input,
Image,
ListItem,
Modal,
ModalBody,
Expand Down Expand Up @@ -96,13 +97,13 @@ export const BlogInterface = () => {

<FormControl id="summary" isInvalid={summary === ''}>
<FormLabel>Blog summary.</FormLabel>
<Input type="url" value={summary} onChange={e => setSummary(e.currentTarget.value)} />
<Input value={summary} onChange={e => setSummary(e.currentTarget.value)} />
<FormHelperText>Short summary of the blog post.</FormHelperText>
</FormControl>

<FormControl id="imgUrl" isInvalid={imgUrl === ''}>
<FormLabel>Link to blog image.</FormLabel>
<Input type="url" placeholder="https://<yourlink>/your-image.png" value={imgUrl}
<Input placeholder="https://<yourlink>/your-image.png" value={imgUrl}
onChange={e => setImgUrl(e.currentTarget.value)} />
<FormHelperText> URL link to the image you would like to be a part of the blog post. </FormHelperText>
</FormControl>
Expand Down Expand Up @@ -149,8 +150,9 @@ export const BlogInterface = () => {
Summary: {summary}
</ListItem>
<ListItem>
ImgUrl: {imgUrl}
Image:
</ListItem>
<Image src={imgUrl} />
<ListItem>
BodyText:
<p>
Expand Down
8 changes: 6 additions & 2 deletions src/components/adminInterfaces/InterfaceItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export const InterfaceItem = (props) => {
{item.email} - {item.sentAt.toDate().toDateString()}
</Box>
);
} else {
} else if (props.type === 'team'){
return item.name + ' | ' + item.team;
}
else {
return item.title;
}
};
Expand All @@ -48,7 +51,8 @@ export const InterfaceItem = (props) => {
let type;
if (props.type === 'inbox') {
type = item.msgType + 's';
} else {
}
else {
type = props.type;
}

Expand Down
182 changes: 182 additions & 0 deletions src/components/adminInterfaces/TeamInterface.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
import {
Alert,
AlertIcon,
Box,
Button,
FormControl,
FormHelperText,
FormLabel,
Heading, Image,
Input,
ListItem,
Modal,
ModalBody,
ModalCloseButton,
ModalContent,
ModalFooter,
ModalHeader,
ModalOverlay,
Text,
Textarea,
UnorderedList,
useColorModeValue,
useDisclosure,
VStack,
} from '@chakra-ui/react';
import { tedxRed } from '../../utils/tedxColors';
import React, { useState } from 'react';
import { db } from '../../firebase';
import { FirebaseDocumentList } from './FirebaseDocumentList';

export const TeamInterface = () => {
const color = useColorModeValue('black', 'white');
const [status, setStatus] = useState(<div />);
const [refreshTrigger, updateTrigger] = useState(0);
const { isOpen, onOpen, onClose } = useDisclosure();

const [name, setName] = useState('');
const [bio, setBio] = useState('');
const [imgUrl, setImgUrl] = useState('');
const [team, setTeam] = useState('');
const [year, setYear] = useState('');

const postBlog = () => {
onClose();
db.collection('team').add({
name: name,
bio: bio,
picUrl: imgUrl,
team: team.toLowerCase(),
year: year,
}).then(function(docRef) {
let successAlert = <Alert status="success">
<AlertIcon />
Team member added with the ID: {docRef.id}
</Alert>;
setStatus(successAlert);
updateTrigger(refreshTrigger + 1);
}).catch(function(error) {
let successError = <Alert status="error">
<AlertIcon />
Error adding team member: {error}
</Alert>;
setStatus(successError);
});
setName('');
setBio('');
setImgUrl('');
setTeam('');
setYear('');
};

const cancel = () => {
onClose();
};

const openModal = () => {
if (!(name === '' || imgUrl === '' || bio === '' || team === '' || year === '')) {
onOpen();
}
};


return (
<Box p={6} borderRadius="xl" textAlign="left" color={color} border="2px" borderColor="gray.300">
<VStack>
<Heading as="h1" size="lg" color={tedxRed} pb={4}>
Add New Team Member
</Heading>

<FormControl id="title" isInvalid={name === ''}>
<FormLabel>Name</FormLabel>
<Input value={name} onChange={e => setName(e.currentTarget.value)} />
<FormHelperText>Member full name.</FormHelperText>
</FormControl>

<FormControl id="summary" isInvalid={team === ''}>
<FormLabel>Team</FormLabel>
<Input value={team} onChange={e => setTeam(e.currentTarget.value)} />
<FormHelperText>Team they belong to.</FormHelperText>
</FormControl>


<FormControl id="author" isInvalid={year === ''}>
<FormLabel>Year</FormLabel>
<Input type="number" value={year} onChange={e => setYear(e.currentTarget.value)} />
<FormHelperText>Their graduating year.</FormHelperText>
</FormControl>

<FormControl id="imgUrl" isInvalid={imgUrl === ''}>
<FormLabel>Link to member picture</FormLabel>
<Input type="url" placeholder="https://<yourlink>/your-image.png" value={imgUrl}
onChange={e => setImgUrl(e.currentTarget.value)} />
<FormHelperText> URL link to the profile picture of the team member. </FormHelperText>
</FormControl>

<FormControl id="bodyText" isInvalid={bio === ''}>
<FormLabel>Member short bio</FormLabel>
<Textarea placeholder="Main content of the post." value={bio}
onChange={e => setBio(e.currentTarget.value)} />
<FormHelperText>Make it welcoming and playful!</FormHelperText>
</FormControl>

<Text pb={4}>
{status ? status : ''}
</Text>
<Button
loadingText="Submitting"
colorScheme="red"
variant="solid"
size="lg"
onClick={() => {
openModal();
}}
>
Submit
</Button>
<Modal isOpen={isOpen} onClose={onClose}>
<ModalOverlay />
<ModalContent>
<ModalHeader>Are you sure?</ModalHeader>
<ModalCloseButton />
<ModalBody>
Please confirm you would like to add a new team member with the following data:
<UnorderedList ml='12%' mt='4%'>
<ListItem>
Name: {name}
</ListItem>
<ListItem>
Team: {team}
</ListItem>
<ListItem>
Year: {year}
</ListItem>
<ListItem>
Profile picture:
</ListItem>
<Image src={imgUrl}/>
<ListItem>
Bio:
<p>
{bio}
</p>
</ListItem>
</UnorderedList>
</ModalBody>
<ModalFooter>
<Button colorScheme="blue" mr={3} onClick={postBlog}>
Confirm
</Button>
<Button variant="ghost" onClick={cancel}>Cancel</Button>
</ModalFooter>
</ModalContent>
</Modal>

<Heading as="h1" size="lg" color={tedxRed} py={8}>
Current Team Members
</Heading>
<FirebaseDocumentList type="team" key={refreshTrigger} />
</VStack>
</Box>
);
};
8 changes: 3 additions & 5 deletions src/pages/admin.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@ import {
VStack,
} from '@chakra-ui/react';
import { tedxRed } from '../utils/tedxColors';
import { TalksInterface } from '../components/adminInterfaces/TalksInterface';
import { useEffect } from 'react';
import { auth } from '../firebase';
import { useHistory } from 'react-router-dom';
import { TalksInterface } from '../components/adminInterfaces/TalksInterface';
import { VideosInterface } from '../components/adminInterfaces/VideosInterface';
import { InboxInterface } from '../components/adminInterfaces/InboxInterface';
import { TicketInterface } from '../components/adminInterfaces/TicketInterface';
import { TeamInterface } from '../components/adminInterfaces/TeamInterface';
import { BlogInterface } from '../components/adminInterfaces/BlogInterface';
import { SponsorInterface } from '../components/adminInterfaces/SponsorInterface';

Expand Down Expand Up @@ -114,10 +115,7 @@ export const Admin = () => {
<AccordionIcon />
</AccordionButton>
<AccordionPanel pb={4}>
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim
veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea
commodo consequat.
<TeamInterface/>
</AccordionPanel>
</AccordionItem>

Expand Down
2 changes: 1 addition & 1 deletion src/pages/landing.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export const Landing = () => {
<VStack spacing={4}>
<Logo h="40vmin" pointerEvents="none" />
<Heading as="h1" size="2xl" color={tedxRed} pb={12}>
Coming Soon
Event News Coming Soon
</Heading>
</VStack>
</Grid>
Expand Down

0 comments on commit a510ca2

Please sign in to comment.