mirror of
https://github.com/myfatemi04/wheelshare-frontend.git
synced 2025-04-21 19:29:51 -04:00
Improve profile
This commit is contained in:
parent
4dcf697b50
commit
d1a263ce38
|
@ -1,13 +1,13 @@
|
||||||
import React, { useState, useEffect } from 'react';
|
import Button from '@material-ui/core/Button';
|
||||||
import { API_ENDPOINT } from '../api/api';
|
|
||||||
import { makeStyles } from '@material-ui/core/styles';
|
|
||||||
import Card from '@material-ui/core/Card';
|
import Card from '@material-ui/core/Card';
|
||||||
import CardActionArea from '@material-ui/core/CardActionArea';
|
import CardActionArea from '@material-ui/core/CardActionArea';
|
||||||
import CardActions from '@material-ui/core/CardActions';
|
import CardActions from '@material-ui/core/CardActions';
|
||||||
import CardContent from '@material-ui/core/CardContent';
|
import CardContent from '@material-ui/core/CardContent';
|
||||||
import CardMedia from '@material-ui/core/CardMedia';
|
import { makeStyles } from '@material-ui/core/styles';
|
||||||
import Button from '@material-ui/core/Button';
|
|
||||||
import Typography from '@material-ui/core/Typography';
|
import Typography from '@material-ui/core/Typography';
|
||||||
|
import { useContext, useEffect, useState } from 'react';
|
||||||
|
import { API_ENDPOINT } from '../api/api';
|
||||||
|
import AuthenticationContext from './AuthenticationContext';
|
||||||
|
|
||||||
const useStyles = makeStyles({
|
const useStyles = makeStyles({
|
||||||
root: {
|
root: {
|
||||||
|
@ -17,13 +17,10 @@ const useStyles = makeStyles({
|
||||||
height: 140,
|
height: 140,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const Profile = () => {
|
const Profile = () => {
|
||||||
const [state, setState] = useState({
|
const { user, isLoggedIn } = useContext(AuthenticationContext);
|
||||||
user: {
|
const [groups, setGroups] = useState<Carpool.Group[]>([]);
|
||||||
username: 'HyperionLegion',
|
|
||||||
},
|
|
||||||
groups: [],
|
|
||||||
});
|
|
||||||
const [pools, setPools] = useState([
|
const [pools, setPools] = useState([
|
||||||
{
|
{
|
||||||
id: 1,
|
id: 1,
|
||||||
|
@ -76,16 +73,6 @@ const Profile = () => {
|
||||||
]);
|
]);
|
||||||
const classes = useStyles();
|
const classes = useStyles();
|
||||||
|
|
||||||
const callAPI = () => {
|
|
||||||
fetch(`${process.env.REACT_APP_API_ENDPOINT}/profile/`)
|
|
||||||
.then((response) => response.json())
|
|
||||||
.then((data) => {
|
|
||||||
if (data !== undefined) {
|
|
||||||
setState(data);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
console.log(process.env);
|
console.log(process.env);
|
||||||
fetch(`${API_ENDPOINT}/my_pools`)
|
fetch(`${API_ENDPOINT}/my_pools`)
|
||||||
|
@ -96,6 +83,11 @@ const Profile = () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
|
if (!user) {
|
||||||
|
return <h1>Please Sign In</h1>;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className=""
|
className=""
|
||||||
|
@ -103,13 +95,13 @@ const Profile = () => {
|
||||||
>
|
>
|
||||||
<h1
|
<h1
|
||||||
className="d-flex justify-content-center p-4"
|
className="d-flex justify-content-center p-4"
|
||||||
style={{ backgroundColor: '#F1EAE8', fontFamily: 'Courier New' }}
|
style={{ backgroundColor: '#F1EAE8' }}
|
||||||
>
|
>
|
||||||
Profile
|
Profile
|
||||||
</h1>
|
</h1>
|
||||||
<div className="container" style={{ fontFamily: 'Courier New' }}>
|
<div className="container">
|
||||||
<h2>
|
<h2>
|
||||||
<u>{state.user.username}'s Pools</u>
|
<u>{user.username}'s Pools</u>
|
||||||
</h2>
|
</h2>
|
||||||
<div className="">
|
<div className="">
|
||||||
{pools.map((pool) => {
|
{pools.map((pool) => {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user