mirror of
https://github.com/myfatemi04/wheelshare-frontend.git
synced 2025-04-21 11:20:17 -04:00
Merge branch 'main' of https://github.com/myfatemi04/wheelshare-frontend into main
This commit is contained in:
commit
7b6643f5e7
|
@ -9,22 +9,11 @@ import { useParams } from 'react-router-dom';
|
||||||
import { ICarpool } from '../types';
|
import { ICarpool } from '../types';
|
||||||
|
|
||||||
import UISecondaryBox from '../UI/UISecondaryBox';
|
import UISecondaryBox from '../UI/UISecondaryBox';
|
||||||
|
import MemberList from './MemberList';
|
||||||
import UIButton from '../UI/UIButton';
|
import UIButton from '../UI/UIButton';
|
||||||
import { lightgrey } from '../colors';
|
import { lightgrey } from '../colors';
|
||||||
import { getCarpool } from '../api';
|
import { getCarpool } from '../api';
|
||||||
|
|
||||||
function MemberList({ members }: { members: ICarpool['members'] }) {
|
|
||||||
return (
|
|
||||||
<div style={{ display: 'flex', flexDirection: 'column' }}>
|
|
||||||
{members.length > 0
|
|
||||||
? members.map((member) => {
|
|
||||||
return <div key={member.id}>{member.name}</div>;
|
|
||||||
})
|
|
||||||
: 'This carpool has no members.'}
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Carpool() {
|
export default function Carpool() {
|
||||||
const id = +useParams<{ id: string }>().id;
|
const id = +useParams<{ id: string }>().id;
|
||||||
const [carpool, setCarpool] = useState<ICarpool | null>(null);
|
const [carpool, setCarpool] = useState<ICarpool | null>(null);
|
||||||
|
|
49
src/components/Carpool/MemberList.tsx
Normal file
49
src/components/Carpool/MemberList.tsx
Normal file
|
@ -0,0 +1,49 @@
|
||||||
|
import AccountCircleIcon from '@material-ui/icons/AccountCircle';
|
||||||
|
|
||||||
|
export default function MemberList({
|
||||||
|
members,
|
||||||
|
}: {
|
||||||
|
members: {
|
||||||
|
id: number;
|
||||||
|
name: string;
|
||||||
|
}[];
|
||||||
|
}) {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
className="MemberList"
|
||||||
|
style={{
|
||||||
|
display: 'flex',
|
||||||
|
flexDirection: 'column',
|
||||||
|
alignSelf: 'center',
|
||||||
|
alignItems: 'flex-start',
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<h3 style={{ marginBlockEnd: '0' }}>Members</h3>
|
||||||
|
{members.length > 0 ? (
|
||||||
|
<div>
|
||||||
|
{members.map((member, index) => {
|
||||||
|
return index < 2 ? (
|
||||||
|
<div
|
||||||
|
className="member"
|
||||||
|
style={{ display: 'flex', alignItems: 'center' }}
|
||||||
|
>
|
||||||
|
{}
|
||||||
|
<AccountCircleIcon style={{ marginRight: '8px' }} />
|
||||||
|
<div key={member.id}>{member.name}</div>
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
''
|
||||||
|
);
|
||||||
|
})}
|
||||||
|
{members.length > 2
|
||||||
|
? members.length - 2 == 1
|
||||||
|
? members.length - 2 + ' other...'
|
||||||
|
: members.length - 2 + ' others...'
|
||||||
|
: ''}{' '}
|
||||||
|
</div>
|
||||||
|
) : (
|
||||||
|
'This carpool has no members.'
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user