update types to use Mongo-style "_id"

This commit is contained in:
Michael Fatemi 2021-04-10 21:22:48 -04:00
parent 6cd56843b4
commit a8605241fe
5 changed files with 13 additions and 13 deletions

View File

@ -10,7 +10,7 @@ const maybePluralize = (count: number, noun: string, suffix = 's') =>
const SAMPLE_POOLS: Carpool.Pool[] = [
{
id: '1234',
_id: '1234',
title: 'TJ Carpool',
description: 'Carpool from TJ track to homes',
start_time: '4/10/2021 3:00 PM',
@ -90,7 +90,7 @@ export default function Group() {
{pools.map((pool, index) => {
return (
<Card style={{ margin: '0.5em' }} key={index}>
<a href={'/Pool/' + pool.id} className="card-title">
<a href={'/pool/' + pool._id} className="card-title">
{pool.title}
</a>
<p className="text-left">

View File

@ -76,7 +76,7 @@ export default function Pool() {
const onRegister = useCallback(() => {
if (user) {
let userID = user.id;
let userID = user._id;
makeAPIPostCall('/join_pool', { id }).then(() => {
if (pool) {
setPool({
@ -122,7 +122,7 @@ export default function Pool() {
style={{ marginTop: '0.5rem' }}
onClick={onRegister}
>
{pool.participant_ids.includes(user.id)
{pool.participant_ids.includes(user._id)
? 'Unregister'
: 'Register'}
</Button>

View File

@ -97,7 +97,7 @@ const Pools = () => {
className="card card-body text-left"
style={{ backgroundColor: background }}
>
<a href={'/Pool/' + pool.id} className="card-title">
<a href={'/pool/' + pool._id} className="card-title">
{pool.title}
</a>
<p className="text-left">
@ -105,7 +105,7 @@ const Pools = () => {
</p>
<p className="text-left">Start Time: {pool.start_time}</p>
<p className="text-left">End Time: {pool.end_time}</p>
<p className="" style={{color: '#9E6105'}}>
<p className="" style={{ color: '#9E6105' }}>
{maybePluralize(pool.comments.length, 'comment')}
</p>
</div>

View File

@ -56,7 +56,7 @@ const Profile = () => {
className={classes.root + 'd-inline-flex'}
style={{ margin: '0.5rem' }}
>
<CardActionArea href={'/pool/' + pool.id}>
<CardActionArea href={'/pool/' + pool._id}>
<CardContent>
<Typography gutterBottom variant="h5" component="h2">
{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/pool/' + pool._id;
navigator.clipboard.writeText(link);
}}
>
Share
</Button>
<Button
href={'/pool/' + pool.id}
href={'/pool/' + pool._id}
size="small"
color="primary"
>

8
src/types.d.ts vendored
View File

@ -1,6 +1,6 @@
declare namespace Carpool {
export interface Group {
id: string;
_id: string;
name: string;
member_ids: string[];
creator_id: string;
@ -8,14 +8,14 @@ declare namespace Carpool {
// Omits the email attribute
export interface PublicUser {
id: string;
_id: string;
username: string;
first_name: string;
last_name: string;
}
export interface User {
id: string;
_id: string;
email: string;
username: string;
first_name: string;
@ -31,7 +31,7 @@ declare namespace Carpool {
export type Status = 'pending' | 'cancelled' | 'completed' | 'interrupted';
export interface Pool {
id: string;
_id: string;
title: string;
description: string;
participant_ids: string[];