|
1 | 1 | 'use client';
|
2 | 2 |
|
3 | 3 | import { useEffect, useState } from 'react';
|
4 |
| -import { getAllCases } from '../../api/supabase/queries/cases'; |
| 4 | +import { UUID } from 'crypto'; |
5 | 5 | import { CaseListing } from '../../types/schemaTypes';
|
| 6 | +import { getNCases } from '../../api/supabase/queries/cases'; |
| 7 | +import ListingCard from '../../components/ListingCard/ListingCard'; |
| 8 | +import { |
| 9 | + CardColumn, |
| 10 | + CaseDetailDisplay, |
| 11 | + CaseDetails, |
| 12 | + MainDisplay, |
| 13 | + PageContainer, |
| 14 | +} from './styles'; |
| 15 | +import { H1, H2 } from '../../styles/text'; |
6 | 16 |
|
7 | 17 | export default function Page() {
|
8 |
| - const [data, setData] = useState<CaseListing[]>([]); |
| 18 | + const [caseData, setCaseData] = useState<CaseListing[]>([]); |
| 19 | + const [selectedCard, setSelectedCard] = useState<UUID>(); |
9 | 20 |
|
| 21 | + // react hooks |
10 | 22 | useEffect(() => {
|
11 |
| - getAllCases().then(casesData => { |
12 |
| - setData(casesData); |
| 23 | + getNCases(20).then(casesData => { |
| 24 | + setCaseData(casesData); |
13 | 25 | });
|
14 | 26 | }, []);
|
15 | 27 |
|
| 28 | + // page structure |
16 | 29 | return (
|
17 |
| - <div> |
18 |
| - <table> |
19 |
| - <thead> |
20 |
| - <tr> |
21 |
| - <th>id</th> |
22 |
| - <th>summary</th> |
23 |
| - <th>languages</th> |
24 |
| - <th>country</th> |
25 |
| - <th>legalServerId</th> |
26 |
| - <th>clientInitials</th> |
27 |
| - <th>timeToComplete</th> |
28 |
| - <th>isRemote</th> |
29 |
| - <th>clientLocation</th> |
30 |
| - <th>program</th> |
31 |
| - <th>upcomingHearingDate</th> |
32 |
| - <th>needsInterpreter</th> |
33 |
| - <th>interestIds</th> |
34 |
| - </tr> |
35 |
| - </thead> |
36 |
| - <tbody> |
37 |
| - {data.map(d => ( |
38 |
| - <tr key={d.id}> |
39 |
| - <td>{d.id}</td> |
40 |
| - <td>{d.summary}</td> |
41 |
| - <td>{JSON.stringify(d.languages)}</td> |
42 |
| - <td>{d.country}</td> |
43 |
| - <td>{d.legal_server_id}</td> |
44 |
| - <td>{d.client_initials}</td> |
45 |
| - <td>{d.time_to_complete}</td> |
46 |
| - <td>{d.is_remote}</td> |
47 |
| - <td>{d.client_location}</td> |
48 |
| - <td>{d.program}</td> |
49 |
| - <td>{d.upcoming_hearing_date}</td> |
50 |
| - <td>{JSON.stringify(d.needs_interpreter)}</td> |
51 |
| - <td>{JSON.stringify(d.interest_ids)}</td> |
52 |
| - </tr> |
| 30 | + <PageContainer> |
| 31 | + <H1>Browse Available Cases</H1> |
| 32 | + <MainDisplay> |
| 33 | + <CardColumn> |
| 34 | + {caseData.map(c => ( |
| 35 | + <ListingCard |
| 36 | + key={c.id} |
| 37 | + caseData={c} |
| 38 | + isSelected={c.id === selectedCard} |
| 39 | + onClick={() => setSelectedCard(c.id)} |
| 40 | + /> |
53 | 41 | ))}
|
54 |
| - </tbody> |
55 |
| - </table> |
56 |
| - </div> |
| 42 | + </CardColumn> |
| 43 | + <CaseDetailDisplay> |
| 44 | + {/* proof of concept -- to turn into component later */} |
| 45 | + <CaseDetails> |
| 46 | + <H2>Case details.</H2> |
| 47 | + </CaseDetails> |
| 48 | + </CaseDetailDisplay> |
| 49 | + </MainDisplay> |
| 50 | + </PageContainer> |
57 | 51 | );
|
58 | 52 | }
|
0 commit comments