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

View File

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

View File

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

View File

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

8
src/types.d.ts vendored
View File

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