From 9880c9f1f9c5249f2e49ff26fda0d54abc6ac098 Mon Sep 17 00:00:00 2001 From: Michael Fatemi Date: Sat, 10 Apr 2021 21:53:49 -0400 Subject: [PATCH] use new API --- src/App.tsx | 4 ++-- src/api/api.ts | 4 ++-- src/components/CreateGroup.tsx | 9 ++------- src/components/CreatePool.tsx | 2 +- src/components/Group.tsx | 6 +++--- src/components/Groups.tsx | 2 +- src/components/MyGroups.tsx | 4 ++-- src/components/MyPools.tsx | 4 ++-- src/components/Pool.tsx | 4 ++-- src/components/Pools.tsx | 4 ++-- src/components/Profile.tsx | 8 ++++---- src/components/UpdatePool.tsx | 4 ++-- 12 files changed, 25 insertions(+), 30 deletions(-) diff --git a/src/App.tsx b/src/App.tsx index e49403c..30bccd2 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -30,8 +30,8 @@ function App() { - - + + diff --git a/src/api/api.ts b/src/api/api.ts index 2f5a2d0..275fa73 100644 --- a/src/api/api.ts +++ b/src/api/api.ts @@ -32,11 +32,11 @@ export async function createSession( } export async function getMe(): Promise { - let result = await makeAPIGetCall('/user', { userID: '@me' }); + let result = await makeAPIGetCall('/users/@me'); return result.data.data; } export async function getPublicUser(id: string): Promise { - let result = await makeAPIGetCall('/user', { userID: id }); + let result = await makeAPIGetCall(`/users/${id}`); return result.data.data; } diff --git a/src/components/CreateGroup.tsx b/src/components/CreateGroup.tsx index 6b35574..2f8d789 100644 --- a/src/components/CreateGroup.tsx +++ b/src/components/CreateGroup.tsx @@ -22,14 +22,9 @@ const useStyles = makeStyles((theme) => ({ const CreateGroup = () => { const [title, setTitle] = useState('No Title'); const classes = useStyles(); - useEffect(() => {}, []); + const onClick = () => { - console.log({ - title: title, - }); - makeAPIPostCall('/group', { - title, - }); + makeAPIPostCall('/groups/', { title }); }; return ( diff --git a/src/components/CreatePool.tsx b/src/components/CreatePool.tsx index 1433975..e3e10b3 100644 --- a/src/components/CreatePool.tsx +++ b/src/components/CreatePool.tsx @@ -30,7 +30,7 @@ const CreatePool = () => { const [group, setGroup] = useState(''); const onClick = () => { - makeAPIPostCall('/pool', { + makeAPIPostCall('/pools/', { title, description, start_time: start, diff --git a/src/components/Group.tsx b/src/components/Group.tsx index 6fc6de7..d7fa23f 100644 --- a/src/components/Group.tsx +++ b/src/components/Group.tsx @@ -43,7 +43,7 @@ export default function Group() { const [pools, setPools] = useState(SAMPLE_POOLS); useEffect(() => { - makeAPIGetCall('/group', { groupID: id }).then((res) => { + makeAPIGetCall(`/groups/${id}`).then((res) => { if ('error' in res.data) { setError(true); } else { @@ -51,7 +51,7 @@ export default function Group() { } }); - makeAPIGetCall('/group_pools', { groupID: id }).then((res) => { + makeAPIGetCall(`/groups/${id}/pools`).then((res) => { setPools(res.data.data); }); }, [id]); @@ -90,7 +90,7 @@ export default function Group() { {pools.map((pool, index) => { return ( - + {pool.title}

diff --git a/src/components/Groups.tsx b/src/components/Groups.tsx index 556467e..2c3c0d1 100644 --- a/src/components/Groups.tsx +++ b/src/components/Groups.tsx @@ -12,7 +12,7 @@ const Groups = () => { ]); useEffect(() => { - makeAPIGetCall('/groups').then((res) => { + makeAPIGetCall('/browse/groups').then((res) => { if (res.data.data) { setGroups(res.data.data); } diff --git a/src/components/MyGroups.tsx b/src/components/MyGroups.tsx index 7cfb937..ba7cbf5 100644 --- a/src/components/MyGroups.tsx +++ b/src/components/MyGroups.tsx @@ -12,7 +12,7 @@ const MyGroups = () => { ]); useEffect(() => { - makeAPIGetCall('/groups').then((res) => { + makeAPIGetCall('/browse/groups').then((res) => { if (res.data.data) { setGroups(res.data.data); } @@ -48,7 +48,7 @@ const MyGroups = () => { className="card card-body text-left" style={{ backgroundColor: background }} > - + {group.name} diff --git a/src/components/MyPools.tsx b/src/components/MyPools.tsx index 50a3434..1c2eb17 100644 --- a/src/components/MyPools.tsx +++ b/src/components/MyPools.tsx @@ -56,7 +56,7 @@ const MyPools = () => { ]); useEffect(() => { - makeAPIGetCall('/my_pools').then((res) => { + makeAPIGetCall('/users/@me/pools').then((res) => { if (res.data.data) { setPools(res.data.data); } @@ -94,7 +94,7 @@ const MyPools = () => { className="card card-body text-left" style={{ backgroundColor: background }} > - + {pool.pool_title}

diff --git a/src/components/Pool.tsx b/src/components/Pool.tsx index 0b2d2ab..05813cf 100644 --- a/src/components/Pool.tsx +++ b/src/components/Pool.tsx @@ -77,7 +77,7 @@ export default function Pool() { const onRegister = useCallback(() => { if (user) { let userID = user._id; - makeAPIPostCall('/join_pool', { id }).then(() => { + makeAPIPostCall(`/pools/${id}/join`).then(() => { if (pool) { setPool({ ...pool, @@ -89,7 +89,7 @@ export default function Pool() { }, [user, id, pool]); useEffect(() => { - makeAPIGetCall('/pool', { poolID: id }).then((response) => { + makeAPIGetCall(`/pools/${id}`).then((response) => { if (response.data.data) { setPool(response.data.data); } diff --git a/src/components/Pools.tsx b/src/components/Pools.tsx index 3b964ee..04ba013 100644 --- a/src/components/Pools.tsx +++ b/src/components/Pools.tsx @@ -59,7 +59,7 @@ const Pools = () => { ]); useEffect(() => { - makeAPIGetCall('/my_pools').then((res) => { + makeAPIGetCall(`/users/@me/pools`).then((res) => { if (res.data.data) { setPools(res.data.data); } @@ -95,7 +95,7 @@ const Pools = () => { className="card card-body text-left" style={{ backgroundColor: background }} > - + {pool.title}

diff --git a/src/components/Profile.tsx b/src/components/Profile.tsx index 97ea5c6..54ad93f 100644 --- a/src/components/Profile.tsx +++ b/src/components/Profile.tsx @@ -25,7 +25,7 @@ const Profile = () => { const classes = useStyles(); useEffect(() => { - makeAPIGetCall('/my_pools').then((res) => { + makeAPIGetCall('/users/@me/pools').then((res) => { if (res.data.data) setPools(res.data.data); }); }, []); @@ -56,7 +56,7 @@ const Profile = () => { className={classes.root + 'd-inline-flex'} style={{ margin: '0.5rem' }} > - + {pool.title} @@ -75,14 +75,14 @@ const Profile = () => { size="small" color="primary" onClick={() => { - let link: string = 'localhost:3000/pool/' + pool._id; + let link: string = 'localhost:3000/pools/' + pool._id; navigator.clipboard.writeText(link); }} > Share