mirror of
https://github.com/ClaytonWWilson/CS307-Team24.git
synced 2025-12-16 18:28:47 +00:00
commit
0bbc453d54
@ -34,7 +34,6 @@ exports.getAllTopics = (req, res) => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
exports.deleteTopic = (req, res) => {
|
exports.deleteTopic = (req, res) => {
|
||||||
// TODO: handle add and delete by topic id
|
|
||||||
const topic = db.doc(`/topics/${req.params.topicId}`);
|
const topic = db.doc(`/topics/${req.params.topicId}`);
|
||||||
topic.get().then((doc) => {
|
topic.get().then((doc) => {
|
||||||
if (!doc.exists) {
|
if (!doc.exists) {
|
||||||
|
|||||||
@ -36,6 +36,7 @@ const theme = createMuiTheme(themeObject);
|
|||||||
|
|
||||||
const token = localStorage.FBIdToken;
|
const token = localStorage.FBIdToken;
|
||||||
if (token) {
|
if (token) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const decodedToken = jwtDecode(token);
|
const decodedToken = jwtDecode(token);
|
||||||
if (decodedToken.exp * 1000 < Date.now()) {
|
if (decodedToken.exp * 1000 < Date.now()) {
|
||||||
|
|||||||
@ -6,66 +6,63 @@ import axios from 'axios';
|
|||||||
import { makeStyles, styled } from '@material-ui/core/styles';
|
import { makeStyles, styled } from '@material-ui/core/styles';
|
||||||
import Grid from '@material-ui/core/Grid';
|
import Grid from '@material-ui/core/Grid';
|
||||||
import Card from '@material-ui/core/Card';
|
import Card from '@material-ui/core/Card';
|
||||||
import CardMedia from '@material-ui/core/CardMedia';
|
|
||||||
import CardContent from '@material-ui/core/CardContent';
|
|
||||||
import Chip from '@material-ui/core/Chip';
|
import Chip from '@material-ui/core/Chip';
|
||||||
import Paper from '@material-ui/core/Paper';
|
|
||||||
import Typography from "@material-ui/core/Typography";
|
import Typography from "@material-ui/core/Typography";
|
||||||
import AddCircle from '@material-ui/icons/AddCircle';
|
import AddCircle from '@material-ui/icons/AddCircle';
|
||||||
|
import TextField from '@material-ui/core/TextField';
|
||||||
|
|
||||||
// component
|
// component
|
||||||
import Profile from '../components/profile/Profile';
|
|
||||||
import Userline from '../Userline';
|
import Userline from '../Userline';
|
||||||
import noImage from '../images/no-img.png';
|
import noImage from '../images/no-img.png';
|
||||||
|
|
||||||
|
|
||||||
const PostCard = styled(Card)({
|
|
||||||
background: 'linear-gradient(45deg, #1da1f2 90%)',
|
|
||||||
border: 3,
|
|
||||||
borderRadius: 3,
|
|
||||||
height:325,
|
|
||||||
width: 345,
|
|
||||||
padding: '0 30px',
|
|
||||||
});
|
|
||||||
|
|
||||||
const MyChip = styled(Chip)({
|
const MyChip = styled(Chip)({
|
||||||
margin: 2,
|
margin: 2,
|
||||||
color: 'primary'
|
color: 'primary'
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
const styles = (theme) => ({
|
|
||||||
...theme
|
|
||||||
});
|
|
||||||
|
|
||||||
const handleDelete = () => {
|
|
||||||
alert("Delete this topic!");
|
|
||||||
}
|
|
||||||
|
|
||||||
const handleAddCircle = () => {
|
|
||||||
alert("Add topic");
|
|
||||||
}
|
|
||||||
|
|
||||||
class user extends Component {
|
class user extends Component {
|
||||||
state = {
|
state = {
|
||||||
profile: null,
|
profile: null,
|
||||||
topics: null
|
imageUrl: null,
|
||||||
|
topics: null,
|
||||||
|
newTopic: null
|
||||||
};
|
};
|
||||||
|
|
||||||
|
handleDelete = (topic) => {
|
||||||
|
alert(`Delete topic: ${topic}!`);
|
||||||
|
}
|
||||||
|
|
||||||
|
handleAddCircle = () => {
|
||||||
|
axios.post('/putTopic', {
|
||||||
|
topic: this.state.newTopic
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
location.reload();
|
||||||
|
})
|
||||||
|
.catch(function (err) {
|
||||||
|
console.log(err);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
handleChange(event) {
|
||||||
|
this.setState({
|
||||||
|
newTopic: event.target.value
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
axios
|
axios
|
||||||
.get("/user")
|
.get("/user")
|
||||||
.then(res => {
|
.then(res => {
|
||||||
console.log(res.data.credentials.handle);
|
|
||||||
this.setState({
|
this.setState({
|
||||||
profile: res.data.credentials.handle
|
profile: res.data.credentials.handle,
|
||||||
|
imageUrl: res.data.credentials.imageUrl
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(err => console.log(err));
|
.catch(err => console.log(err));
|
||||||
axios
|
axios
|
||||||
.get("/getAllTopics")
|
.get("/getAllTopics")
|
||||||
.then(res => {
|
.then(res => {
|
||||||
console.log(res.data[1]);
|
|
||||||
this.setState({
|
this.setState({
|
||||||
topics: res.data
|
topics: res.data
|
||||||
})
|
})
|
||||||
@ -83,22 +80,40 @@ class user extends Component {
|
|||||||
let topicsMarkup = this.state.topics ? (
|
let topicsMarkup = this.state.topics ? (
|
||||||
this.state.topics.map(topic => <MyChip
|
this.state.topics.map(topic => <MyChip
|
||||||
label={{topic}.topic.topic}
|
label={{topic}.topic.topic}
|
||||||
onDelete={handleDelete}/>)
|
key={{topic}.topic.topicId}
|
||||||
|
onDelete={ (topic) => this.handleDelete(topic)}/>)
|
||||||
) : (<p> loading topics...</p>);
|
) : (<p> loading topics...</p>);
|
||||||
|
|
||||||
|
let imageMarkup = this.state.imageUrl ? (
|
||||||
|
<img
|
||||||
|
src={this.state.imageUrl}
|
||||||
|
height="250"
|
||||||
|
width="250"
|
||||||
|
/>
|
||||||
|
) : (<img src={noImage}/>);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid container spacing={16}>
|
<Grid container spacing={16}>
|
||||||
<Grid item sm={8} xs={12}>
|
<Grid item sm={8} xs={12}>
|
||||||
<p>Post</p>
|
<p>Post</p>
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid item sm={4} xs={12}>
|
<Grid item sm={4} xs={12}>
|
||||||
<img src={noImage}/>
|
{imageMarkup}
|
||||||
{profileMarkup}
|
{profileMarkup}
|
||||||
{topicsMarkup}
|
{topicsMarkup}
|
||||||
<MyChip
|
<TextField
|
||||||
icon={<AddCircle />}
|
id="newTopic"
|
||||||
|
label="new topic"
|
||||||
|
defaultValue=""
|
||||||
|
margin="normal"
|
||||||
|
variant="outlined"
|
||||||
|
value={this.state.newTopic}
|
||||||
|
onChange={ (event) => this.handleChange(event)}
|
||||||
|
/>
|
||||||
|
<AddCircle
|
||||||
|
color="primary"
|
||||||
clickable
|
clickable
|
||||||
onClick={handleAddCircle}
|
onClick={this.handleAddCircle}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -106,12 +121,4 @@ class user extends Component {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Userline.PropTypes = {
|
|
||||||
handle: PropTypes.object.isRequired
|
|
||||||
};
|
|
||||||
|
|
||||||
const mapStateToProps = (state) => ({
|
|
||||||
user: state.user
|
|
||||||
});
|
|
||||||
|
|
||||||
export default user;
|
export default user;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user