/** * Records users by id */ export const users: Record = { myfatemi04: { id: '3baeaed6-05cb-4c03-9b43-1d74beafdbb7', email: '2022mfatemi@tjhsst.edu', username: 'myfatemi04', first_name: 'Michael', last_name: 'Fatemi', }, }; /** * Records groups by id */ export const groups: Record = {}; /** * Records pools by id */ export const pools: Record = {}; /** * * @param userID The userID to find * @returns The group IDs with that userID as a member */ export function getGroupsWithUser(userID: string) { let groupIDs = []; for (let group of Object.values(groups)) { if (group.member_ids.includes(userID)) { groupIDs.push(group.id); } } return groupIDs; } /** * * @param userID The userID to find * @returns The post IDs with that userID as the author */ export function getPoolsWithUser(userID: string) { let poolIDs: string[] = []; for (let post of Object.values(pools)) { if (post.author_id == userID) { poolIDs.push(post.id); } } return poolIDs; } export function getUserByID(userID: string): Carpool.User | undefined { return users[userID]; } export function getPoolByID(poolID: string): Carpool.Pool | undefined { return pools[poolID]; } export function getGroupByID(groupID: string): Carpool.Group | undefined { return groups[groupID]; }