Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade VZE to NextJS #1603

Open
wants to merge 440 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 117 commits
Commits
Show all changes
440 commits
Select commit Hold shift + click to select a range
9e7ffa3
spelling (falsy)
frankhereford Dec 9, 2024
e731950
spelling (occurred)
frankhereford Dec 9, 2024
71464da
undo spelling correction because of it being in an applied migration …
frankhereford Dec 9, 2024
2272b7e
remove zod-drive types + validation
johnclary Dec 9, 2024
a09871d
merge upstream and fix confs
johnclary Dec 9, 2024
f28ce2f
simplify user payload
johnclary Dec 9, 2024
bc16472
generate user password and handle additional user settings
johnclary Dec 9, 2024
94966f4
let react-hook-form cook
johnclary Dec 9, 2024
035d93a
the city is a lookup table
chiaberry Dec 9, 2024
454085b
include the relationship in the query
chiaberry Dec 10, 2024
242cda8
Merge pull request #1624 from cityofaustin/frank/nextjs-minutiae
frankhereford Dec 10, 2024
185c1fb
create apierror type
johnclary Dec 10, 2024
fc08cea
rework error handling and nix sorting
johnclary Dec 10, 2024
f023519
make user form support create and update
johnclary Dec 10, 2024
08212bf
add user form
johnclary Dec 10, 2024
42f92e0
update user form/modal
johnclary Dec 10, 2024
03bc761
bind port 8085 to 5000 and run in debug mode
johnclary Dec 10, 2024
d3965d4
verious user api updates
johnclary Dec 10, 2024
437068a
run cr3 api in debug mode
johnclary Dec 10, 2024
f666430
update readme
johnclary Dec 10, 2024
e229f56
update readme
johnclary Dec 10, 2024
2d1434d
combine modal and form components
johnclary Dec 10, 2024
ee0dab3
update readme
johnclary Dec 10, 2024
1cbe9ed
use isDirty state and polish labels and stuff
johnclary Dec 10, 2024
d156c03
add charges type and column definitions
chiaberry Dec 10, 2024
c6f1f81
docstrings
johnclary Dec 11, 2024
030fe41
jsonify delete user response
johnclary Dec 11, 2024
910c3a1
add refresh token hook
johnclary Dec 11, 2024
29985c5
wip delete modal
johnclary Dec 11, 2024
efffdc3
fix typo in alert variant name
johnclary Dec 12, 2024
fd8bf16
fix typo in LoginContainer
johnclary Dec 12, 2024
c0f66ce
fix typo
johnclary Dec 12, 2024
539495c
use formatRoleName util
johnclary Dec 12, 2024
ce6a103
docstring
johnclary Dec 12, 2024
48f98a9
show actual error message in users list
johnclary Dec 12, 2024
d07cc5d
lint
johnclary Dec 12, 2024
e05addb
add comment about api gateway headers
johnclary Dec 15, 2024
b479ad4
add better error handling for invalid email
johnclary Dec 15, 2024
391bf93
fix casing in func name
johnclary Dec 15, 2024
a77c9b9
move config to top of readme
johnclary Dec 15, 2024
c9783d0
fix typo
johnclary Dec 15, 2024
8d66933
Merge branch 'john/20120-new-user-form' into john/19974-delete-users
johnclary Dec 16, 2024
63d1002
merge upstream and resolve confs
johnclary Dec 16, 2024
6381c73
Merge branch 'john/19969-users-page' into john/20214-remove-zod
johnclary Dec 16, 2024
4dc3b7a
resolve conf and merge upstream
johnclary Dec 16, 2024
5ee09ed
allow cors delete and fix response content
johnclary Dec 16, 2024
a388f32
delete modal and just use confirm
johnclary Dec 16, 2024
0da3968
enable user delete
johnclary Dec 16, 2024
dc9a4f3
lint
johnclary Dec 16, 2024
574f0ad
revalidate user list and show loading spinner when doing so
johnclary Dec 16, 2024
7dc9b42
enables search input to be cleared
johnclary Dec 16, 2024
125f43e
refine search/filter/pagination layout
johnclary Dec 16, 2024
5bfef1e
Merge pull request #1627 from cityofaustin/20035-select-city-field
chiaberry Dec 16, 2024
7ddad28
Merge branch 'john/20214-remove-zod' into 19964-charges-related-records
chiaberry Dec 16, 2024
204d5a7
empty string as the mutation
chiaberry Dec 16, 2024
61e31e4
introduce property + type and use it everywhere
johnclary Dec 17, 2024
5bc9963
Merge pull request #1629 from cityofaustin/john/20253-force-login-page
johnclary Dec 18, 2024
c79539b
Merge pull request #1628 from cityofaustin/19964-charges-related-records
johnclary Dec 18, 2024
31ad3ed
Merge branch 'john/20214-remove-zod' into john/20120-new-user-form
johnclary Dec 18, 2024
0ab87a8
Merge pull request #1626 from cityofaustin/john/20120-new-user-form
johnclary Dec 18, 2024
cbd2b7a
Merge pull request #1625 from cityofaustin/john/20214-remove-zod
johnclary Dec 18, 2024
c23a872
resolve upstream conflicts
johnclary Dec 18, 2024
1ebec6b
Merge pull request #1617 from cityofaustin/john/19969-users-page
johnclary Dec 18, 2024
171495e
change local dev ports for db, editor, and app
johnclary Dec 18, 2024
f14c8eb
lint
johnclary Dec 18, 2024
1f6cb50
simplify typing on getFromPath
johnclary Dec 18, 2024
5d2147a
Merge branch 'nextjs' into john/19974-delete-users
chiaberry Dec 18, 2024
b74551d
wip remove renderLookupLabel
johnclary Dec 19, 2024
bf5d208
change hasura console port
johnclary Dec 19, 2024
e3fa945
update localhost port in readme
johnclary Dec 19, 2024
f6df240
remove todo
johnclary Dec 19, 2024
2fe9618
Merge pull request #1632 from cityofaustin/john/2310-search-ui
johnclary Dec 19, 2024
a655045
make card width larger on md+
johnclary Dec 19, 2024
37ce3e6
add location stats and cost formatter
johnclary Dec 19, 2024
7386d24
lint
johnclary Dec 19, 2024
7e95be2
Merge pull request #1631 from cityofaustin/john/19974-delete-users
johnclary Dec 20, 2024
b5b4150
rework column 'relationship' prop and make edit components to use it
johnclary Dec 20, 2024
eb53433
remove todo
johnclary Dec 20, 2024
6cf2a79
Merge branch 'nextjs' into john/20316-nested-object-support
johnclary Dec 20, 2024
5f034cf
update city and charges to follow new schema
johnclary Dec 20, 2024
7b75854
uses ts satisfies to add strong typing to configs
johnclary Dec 20, 2024
2bffc04
add message for when there are no records
frankhereford Dec 20, 2024
36b9a3b
use satisfies on loc cols
johnclary Dec 20, 2024
70d3cfa
rework token hook
johnclary Dec 21, 2024
6208281
lint
johnclary Dec 21, 2024
787afa2
disable prefetching in list view
johnclary Dec 21, 2024
36ac568
basic working recommendations without partners input
johnclary Dec 21, 2024
26a9adc
create crash recommendation partner comp
johnclary Dec 21, 2024
7df4148
coordination partners wip
johnclary Dec 21, 2024
9c1e0d0
rec form working end-to-end
johnclary Dec 22, 2024
c948cb5
move a type declaration to its home
johnclary Dec 22, 2024
1a5bb41
docstrings, lint, polish
johnclary Dec 22, 2024
27607c3
rename var and move edit button
johnclary Dec 22, 2024
d12c826
use setValueAs
johnclary Dec 22, 2024
92dc536
docstring
johnclary Dec 22, 2024
af42415
Merge pull request #1636 from cityofaustin/frank/no-records-found-mes…
johnclary Dec 23, 2024
b01d5b3
Merge pull request #1633 from cityofaustin/john/20340-port-confs
johnclary Dec 23, 2024
2195d11
Merge branch 'nextjs' into john/20316-nested-object-support
johnclary Dec 23, 2024
f1df966
Merge branch 'john/20316-nested-object-support' into john/19963-recom…
johnclary Dec 23, 2024
518865d
Merge branch 'nextjs' into john/20391-exp-token
johnclary Dec 23, 2024
c323530
add partner max height/scroll, mostly
johnclary Dec 23, 2024
c0dcd26
useCallback with onSave func
johnclary Dec 23, 2024
c494c2b
fix card title casing
johnclary Dec 23, 2024
e5d4e2e
remove export
johnclary Dec 23, 2024
204b5ba
update todos
johnclary Dec 23, 2024
50bc377
add contextFilters
johnclary Dec 23, 2024
ad5a72f
add contextFilters to TableWrapper
johnclary Dec 23, 2024
579102a
add location crashes to location details page
johnclary Dec 23, 2024
475503f
introduce property + type and use it everywhere
johnclary Dec 17, 2024
7c9bb3f
lint
johnclary Dec 18, 2024
8c22853
simplify typing on getFromPath
johnclary Dec 18, 2024
f16ea66
wip remove renderLookupLabel
johnclary Dec 19, 2024
08e0c01
make card width larger on md+
johnclary Dec 19, 2024
e26566c
add location stats and cost formatter
johnclary Dec 19, 2024
23b70bf
lint
johnclary Dec 19, 2024
58fa664
rework column 'relationship' prop and make edit components to use it
johnclary Dec 20, 2024
cb77ffe
remove todo
johnclary Dec 20, 2024
1ff86bb
update city and charges to follow new schema
johnclary Dec 20, 2024
b35be44
uses ts satisfies to add strong typing to configs
johnclary Dec 20, 2024
1a34085
use satisfies on loc cols
johnclary Dec 20, 2024
78296f0
change local dev ports for db, editor, and app
johnclary Dec 18, 2024
36b62b9
change hasura console port
johnclary Dec 19, 2024
f5cd9b8
update localhost port in readme
johnclary Dec 19, 2024
f27e25e
add record_locator to location crashes view
johnclary Dec 23, 2024
f23bdd5
docstring
johnclary Dec 23, 2024
dec6d2d
add crash_timestamp to location_crashes and nullify cris_crash_id for…
johnclary Dec 23, 2024
a24ab74
add more cols plus date filters
johnclary Dec 23, 2024
5333278
typo
johnclary Dec 23, 2024
518a105
update todos
johnclary Dec 23, 2024
1760424
Merge branch 'john/20316-nested-object-support' into 19965-people-rel…
chiaberry Dec 23, 2024
c4ddb9c
fix default sort col name
johnclary Dec 23, 2024
6499660
add person type
chiaberry Dec 24, 2024
be3ee0b
Merge branch 'john/20316-nested-object-support' into 19965-people-rel…
chiaberry Dec 24, 2024
18ec9e5
add papaparse and zod
johnclary Dec 26, 2024
e2b41c1
add noncr3 nav item and adjust sidebar width
johnclary Dec 26, 2024
3f0987a
basic working noncr3 upload
johnclary Dec 26, 2024
ea32049
Merge branch 'nextjs' into john/19984-upload-non-cr3
johnclary Dec 26, 2024
2b63a42
Merge branch 'john/20316-nested-object-support' into john/19984-uploa…
johnclary Dec 26, 2024
145f17a
editable fields
chiaberry Dec 26, 2024
ca6e6ca
handle upload errors, polish things up
johnclary Dec 26, 2024
1f8cd7b
add the person name
chiaberry Dec 26, 2024
fa0c815
add file download link
johnclary Dec 26, 2024
3266471
use var for latlon bbox
johnclary Dec 26, 2024
322ef40
check for dupe case ids
johnclary Dec 26, 2024
4ab657e
add create-crash-record in sidebar nav
johnclary Dec 27, 2024
a57c6da
add queries for creating crash records
johnclary Dec 27, 2024
5635178
add refetch prop/effect
johnclary Dec 27, 2024
834ab9d
hello create crash record
johnclary Dec 27, 2024
febf56d
create config for this page
johnclary Dec 27, 2024
e6bba53
linting
johnclary Dec 27, 2024
f8d5152
linting
johnclary Dec 27, 2024
5a95612
fix yolo typings on hasura paylaod
johnclary Dec 27, 2024
7ada08c
remove todo
johnclary Dec 27, 2024
ed10690
update readme todos
johnclary Dec 27, 2024
e6aca7e
docstrings
johnclary Dec 27, 2024
ed1774e
rename a var
johnclary Dec 27, 2024
d2e4209
Merge pull request #1638 from cityofaustin/john/20391-exp-token
johnclary Dec 29, 2024
bf76fd5
part ways w/ parters
johnclary Dec 31, 2024
61c1b7e
update -> updates
johnclary Dec 31, 2024
7623385
rename add/del partner vars
johnclary Dec 31, 2024
394fd20
name a var
johnclary Dec 31, 2024
0a0497f
move status and partner fields back to top
johnclary Dec 31, 2024
bab9eff
use the correct foreign keys
chiaberry Dec 31, 2024
c11b93d
order by unit number
chiaberry Dec 31, 2024
4a3abde
leave a comment with the name todo
chiaberry Dec 31, 2024
f1193d8
add a mutation and rename one
johnclary Dec 31, 2024
fec2cfb
add temp crash banner with delete button
johnclary Dec 31, 2024
f8d7fca
add icon to CrashLocationBanner
johnclary Dec 31, 2024
104cc22
hide icon on < lg display
johnclary Dec 31, 2024
c2247d4
remove unused import
johnclary Dec 31, 2024
aae565b
clean up comments
johnclary Dec 31, 2024
7d91417
swap card order
chiaberry Jan 1, 2025
cb6677e
add fk columns to query
chiaberry Jan 1, 2025
01e469d
track noncr3 csv template
johnclary Jan 2, 2025
cc05b0b
correctly check for no file and reset file after parsing
johnclary Jan 2, 2025
3eaf933
Merge branch 'john/19979-location-crashes' into john/20202-page-and-r…
johnclary Jan 2, 2025
be440a9
create types for hasura response and aggregate
johnclary Jan 2, 2025
764ecb0
show record count in pagination controls
johnclary Jan 2, 2025
a48ed2e
create new file for graphql types
johnclary Jan 2, 2025
f24daed
fix field name in rpt_sec_street_name validation
johnclary Jan 3, 2025
2d02adf
fix terrible typos
johnclary Jan 3, 2025
130689d
add placeholder text to datepicker
johnclary Jan 3, 2025
695ee94
allow aggregation on crashes table
johnclary Jan 3, 2025
dcd9cbb
add hidden and exportable settings to columns
johnclary Jan 3, 2025
74c328c
add exportable setting to q config and create useExportQuery hook
johnclary Jan 3, 2025
7e970c5
add export button to TablePaginationControls
johnclary Jan 3, 2025
f2527f8
create export modal component
johnclary Jan 3, 2025
3bb09a5
add export modal to tablewrapper
johnclary Jan 3, 2025
7be5b16
add export settings to crashes configs
johnclary Jan 3, 2025
9f66bfa
remove comment
chiaberry Jan 4, 2025
7e598be
soft del units and people and set updated_by
johnclary Jan 5, 2025
dd63ae9
add number validations and transform addresses to upper
johnclary Jan 5, 2025
c0f0bf9
change sidebar icon
johnclary Jan 5, 2025
c83b760
Merge pull request #1644 from cityofaustin/john/20433-delete-temp-cra…
johnclary Jan 5, 2025
0182878
Merge pull request #1643 from cityofaustin/john/19985-create-crash-re…
johnclary Jan 5, 2025
0af2d68
Merge pull request #1639 from cityofaustin/john/19963-recommendations
johnclary Jan 5, 2025
5561b07
use right fun to set initial date filter to 5ya
johnclary Jan 5, 2025
0055aec
export getYearsAgoDate
johnclary Jan 5, 2025
a229738
add contextFilters to hook dep array
johnclary Jan 5, 2025
23d84ef
resolve tablewrapper prop confs and merge upstream
johnclary Jan 5, 2025
80c85a3
Merge pull request #1640 from cityofaustin/john/19979-location-crashes
johnclary Jan 5, 2025
c8746a4
fix crash type conf and merge upstream
johnclary Jan 5, 2025
10bd43a
Merge pull request #1642 from cityofaustin/19965-people-related-records
johnclary Jan 5, 2025
b95ecd8
resolve sidebar conflicts
johnclary Jan 5, 2025
6831d1e
Merge pull request #1641 from cityofaustin/john/19984-upload-non-cr3
johnclary Jan 5, 2025
0de6f83
resolve confs
johnclary Jan 5, 2025
184b9b8
Merge pull request #1634 from cityofaustin/john/20316-nested-object-s…
johnclary Jan 5, 2025
79428de
add docstrings to tablewrapper props
johnclary Jan 5, 2025
852acdb
add comment about location_id contextFilter
johnclary Jan 5, 2025
057bd97
rework export props and make more tables exportable
johnclary Jan 6, 2025
bcd7a8f
fix tablewrapper confs
johnclary Jan 6, 2025
ec4b1b8
resolve confs
johnclary Jan 6, 2025
353aa3e
remove columns prop
johnclary Jan 6, 2025
53292a2
default to 1ya instead of ytd filter
johnclary Jan 6, 2025
a194d16
add an issue url to todo
johnclary Jan 6, 2025
24e3439
docstring
johnclary Jan 6, 2025
7fbb22b
use a constant
johnclary Jan 6, 2025
2974dca
show an error banner on error
johnclary Jan 6, 2025
6ba0315
remove unsued import
johnclary Jan 6, 2025
c41e404
fix Alert variant name
johnclary Jan 6, 2025
2b784d9
Merge branch 'main' into 20430-crash-details-lookup
chiaberry Jan 6, 2025
5092a6b
add lighting conditions lookup
chiaberry Jan 6, 2025
b732c64
add roadpart to metadata and type and query
chiaberry Jan 6, 2025
d6a6314
Add roadway system
chiaberry Jan 6, 2025
9b5aa2f
Add the secondary address lookup tables config
chiaberry Jan 6, 2025
1434926
remove what i commented out
chiaberry Jan 6, 2025
ab65525
fix typo
roseeichelmann Jan 7, 2025
aacee8d
formatting
roseeichelmann Jan 7, 2025
88577f3
create swap address button component
roseeichelmann Jan 7, 2025
91b26c0
add swap address button to primary address data card
roseeichelmann Jan 7, 2025
24ea67e
add docstring
roseeichelmann Jan 8, 2025
49a7017
add icon to button
roseeichelmann Jan 8, 2025
f6952c3
rework pagination styles and cleanup the dom
johnclary Jan 13, 2025
fae9da1
Merge pull request #1652 from cityofaustin/20430-crash-details-lookup
chiaberry Jan 13, 2025
83567ff
typos
johnclary Jan 13, 2025
7ff577d
close modal after clicking the download button
johnclary Jan 13, 2025
136e4e3
use a file timestamp
johnclary Jan 13, 2025
54c162e
resolve conf and merge upstream
johnclary Jan 13, 2025
97ed824
use border-0 class instead of inline style
johnclary Jan 13, 2025
706e226
fix typo
johnclary Jan 13, 2025
db29ede
pass HeaderActionButton as props
roseeichelmann Jan 13, 2025
9b736ec
update component name
roseeichelmann Jan 13, 2025
2625576
update name
roseeichelmann Jan 13, 2025
daeec62
use abstracted HeaderActionButton instead of conditionally rendering …
roseeichelmann Jan 13, 2025
e5a78a2
unused import
roseeichelmann Jan 13, 2025
e4c4c8c
Merge pull request #1646 from cityofaustin/john/20456-record-export
johnclary Jan 14, 2025
f62c10f
Merge pull request #1645 from cityofaustin/john/20202-page-and-record…
johnclary Jan 14, 2025
d5727c0
import HeaderActionButtonProps
roseeichelmann Jan 14, 2025
9aaf89a
export interface HeaderActionButtonProps
roseeichelmann Jan 14, 2025
a72a20d
Merge pull request #1653 from cityofaustin/rose/swap-address
roseeichelmann Jan 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions app/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": ["next/core-web-vitals", "next/typescript"]
}
36 changes: 36 additions & 0 deletions app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# dependencies
/node_modules
/.pnp
.pnp.js
.yarn/install-state.gz

# testing
/coverage

# next.js
/.next/
/out/

# production
/build

# misc
.DS_Store
*.pem

# debug
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# local env files
.env*.local

# vercel
.vercel

# typescript
*.tsbuildinfo
next-env.d.ts
1 change: 1 addition & 0 deletions app/.nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
20
116 changes: 116 additions & 0 deletions app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
**This** is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).

## Quick start

1. Start your database and graphql engine

2. Use the `env_template` to configure the local environment variables. These can be copied from your existing VZE `.env` file, by replacing `REACT_APP_` with `NEXT_PUBLIC_` in the variable name:

```shell
# run this cmd and then edit .env.local as needed
cp -n env_template .env.local
```

3. Activate your `node` environment (`v20` is required):

```shell
nvm use
```

4. Install node packages

```
npm install
```

5. Start the development server

```shell
npm run dev
```

6. Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.

## This app vs the old VZE

- Create-React-App ➡️ NextJS
- Javascript ➡️ Typescript
- CoreUI + reactstrap ➡️ react-bootstrap
- Apollo Client ➡️ SWR + graphql-request

## Working features

- Crashes list
- filter by preset date range
- filter by custom date range
- filter using search input and selecting a field to search on
- reset filters
- filters are preserved (in local storage) when refreshing the page or navigating back to it
- advanced search filter menu toggle shows a badge with how many fitlers are applied
- expandable filter toggle menu with working filter switch groups
- paginate through search results
- loading spinner apperas in pagination controls when fetching data
- sortable table columns with icon indicating sort direction
- Crash details page
- Crash map: crash map displays crash location with nearmap aerials
- Crash map: ability to edit crash location
- Crash diagram: diagrams render
- Crash diagram: info alert shows when no diagram is available and is temp record
- Crash diagram: danger alert shows when no diagram is available and is not temp record
- Crash narrative: loads normally and is scrollable for long narratives
- Crash data card: click field to edit
- Crash data card: cannot save unless field is edited
- Crash data card: use cancel button to exit edit mode and restore initial value
- Crash data card: use `enter` key to save edits
- Crash data card: edit a field with lookup values
- Crash data card: edit a text input
- Crash data card: edit a number input
- Crash data card: nullify a value (e.g. street name) by clearing its input and saving it
- Related records - units: click field to edit it
- Related records - people: todo
- Related records - chargs: todo
- Change log: change log works normally with details modal. But it is not collapseable (yet).
- Sidebar
- is exapandable and open/closed state is preserved in localstorage


## Todo

- permissions-based features:
- side nav
- field editing
- etc. see <Can/> component from VZE
- crash details
- crash injury widgets
- swap addresses
- people table
- name edit component
- charges table
- notes
- recommendations
- misc column editing + placement
- Crash map: show coordinates and enable editing by tying into input
- crash diagram: zoom/tilt control
- Change log: collapseable
- table
- advanced filters: test them and add "Other" unit type filter
- export
- record counts
- Top nav component
- app logo
- navigration crash search
- profile menu with signout
- locations
- location details
- create crash record
- upload non-cr3
- dashboard

- users
- user list
- add/edit/delete uers
- copy user emails
- login page: make it look nice
- versioned localstorage
- error boundary (see Moped's for reference)
- map geocoder (technically an enhancement vis a vis current state)
143 changes: 143 additions & 0 deletions app/app/crashes/[record_locator]/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
"use client";
import { useCallback } from "react";
import Row from "react-bootstrap/Row";
import Col from "react-bootstrap/Col";
import Card from "react-bootstrap/Card";
import CrashMapCard from "@/components/CrashMapCard";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i love seeing these absolute imports in this code - so fresh ✨

import { GET_CRASH, UPDATE_CRASH } from "@/queries/crash";
import { UPDATE_UNIT } from "@/queries/unit";
import { useQuery } from "@/utils/graphql";
import AppBreadCrumb from "@/components/AppBreadCrumb";
import CrashHeader from "@/components/CrashHeader";
import CrashDiagramCard from "@/components/CrashDiagramCard";
import DataCard from "@/components/DataCard";
import RelatedRecordTable from "@/components/RelatedRecordTable";
import ChangeLog from "@/components/ChangeLog";
import { crashDataCards } from "@/configs/crashDataCard";
import { unitRelatedRecordCols } from "@/configs/unitRelatedRecordTable";
import { Crash } from "@/types/types";

export default function CrashDetailsPage({
params,
}: {
params: { record_locator: string };
}) {
const recordLocator = params.record_locator;

const { data, refetch, isValidating } = useQuery<{
crashes: Crash[];
}>({
query: recordLocator ? GET_CRASH : null,
variables: { recordLocator },
});

const onSaveCallback = useCallback(async () => {
await refetch();
}, [refetch]);

if (!data || !data?.crashes?.[0]) {
// todo: 404 page
// todo: loading spinner (would be nice to use a spinner inside cards)
return;
}

const crash = data.crashes[0];

return (
<>
<AppBreadCrumb />
<CrashHeader crash={crash} />
<Row>
<Col sm={12} md={6} lg={4} className="mb-3">
<CrashMapCard
savedLatitude={crash.latitude}
savedLongitude={crash.longitude}
crashId={crash.id}
onSaveCallback={onSaveCallback}
mutation={UPDATE_CRASH}
/>
</Col>
<Col sm={12} md={6} lg={4} className="mb-3">
<CrashDiagramCard crash={crash} />
</Col>
<Col sm={12} md={6} lg={4} className="mb-3">
<Card>
<Card.Header>Narrative</Card.Header>
<Card.Body className="crash-header-card-body">
<Card.Text>{crash.investigator_narrative || ""}</Card.Text>
</Card.Body>
</Card>
</Col>
</Row>
<Row>
<Col sm={12} md={6} lg={4} className="mb-3">
<DataCard<Crash>
record={crash}
isValidating={isValidating}
title="Summary"
columns={crashDataCards.summary}
mutation={UPDATE_CRASH}
onSaveCallback={onSaveCallback}
/>
</Col>
<Col sm={12} md={6} lg={4} className="mb-3">
<DataCard<Crash>
record={crash}
isValidating={isValidating}
title="Flags"
columns={crashDataCards.flags}
mutation={UPDATE_CRASH}
onSaveCallback={onSaveCallback}
/>
</Col>
<Col sm={12} md={6} lg={4} className="mb-3">
<DataCard<Crash>
record={crash}
isValidating={isValidating}
title="Other"
columns={crashDataCards.other}
mutation={UPDATE_CRASH}
onSaveCallback={onSaveCallback}
/>
</Col>
</Row>
<Row>
<Col sm={12} md={6} lg={4} className="mb-3">
<DataCard<Crash>
record={crash}
isValidating={isValidating}
title="Primary address"
columns={crashDataCards.address}
mutation={UPDATE_CRASH}
onSaveCallback={onSaveCallback}
/>
</Col>
<Col sm={12} md={6} lg={4} className="mb-3">
<DataCard<Crash>
record={crash}
isValidating={isValidating}
title="Secondary address"
columns={crashDataCards.address_secondary}
mutation={UPDATE_CRASH}
onSaveCallback={onSaveCallback}
/>
</Col>
</Row>
<Row>
<Col sm={12} className="mb-3">
<RelatedRecordTable
records={crash.units}
isValidating={isValidating}
title="Units"
columns={unitRelatedRecordCols}
mutation={UPDATE_UNIT}
onSaveCallback={onSaveCallback}
/>
</Col>
</Row>
<Row className="mb-5">
<Col>{crash && <ChangeLog logs={crash.change_logs} />}</Col>
</Row>
</>
);
}
25 changes: 25 additions & 0 deletions app/app/crashes/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
"use client";
import Card from "react-bootstrap/Card";
import AppBreadCrumb from "@/components/AppBreadCrumb";
import { crashesListViewColumns } from "@/configs/crashesListViewColumns";
import { crashesListViewQueryConfig } from "@/configs/crashesListViewTable";
import TableWrapper from "@/components/TableWrapper";
const localStorageKey = "crashesListViewQueryConfig";

export default function Crashes() {
return (
<>
<AppBreadCrumb />
<Card className="mx-3 mb-3">
<Card.Header className="fs-5 fw-bold">Crashes</Card.Header>
<Card.Body>
<TableWrapper
columns={crashesListViewColumns}
initialQueryConfig={crashesListViewQueryConfig}
localStorageKey={localStorageKey}
/>
</Card.Body>
</Card>
</>
);
}
4 changes: 4 additions & 0 deletions app/app/dashboard/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default function Dashboard() {
return <h1>This is the dashboard page</h1>;
}

25 changes: 25 additions & 0 deletions app/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import "../styles/global.scss";
import AuthProvider from "@/contexts/Auth";
import SidebarLayout from "@/components/SidebarLayout";

/**
* The root layout for the whole app
*
* todo: metadata
*/
export default function RootLayout({
children,
}: {
children: React.ReactNode;
}) {
return (
// <Html lang="en" style={{fontSize: "14px"}} data-bs-theme="dark">
Copy link
Member Author

@johnclary johnclary Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i left this here bc the dark theme is glorious to dev on. would be fun to spin off an issue to make a UI toggle for it 🌚

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

after switching back to light mode a while back, maybe it is time for me to find my way back to the dark side. 😈

<html lang="en" style={{ fontSize: "14px" }}>
Copy link
Member Author

@johnclary johnclary Nov 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

my chrome browser's font size is 16, and the ACC designs go down to 12, maybe even smaller. it's an accessibility issue that needs more consideration 👀

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fwiw this is what MUI does - https://mui.com/material-ui/customization/typography/#font-size which also seems to be the default of Bootstrap too - 1rem. Idk why the font looks so large with this override removed. But, i agree that it is something that needs more thought and can be adjusted globally later.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, thanks pointing to MUI's approach—interesting that they default to 14px.

My understanding of the way it works is that 1rem = whatever the browser default is, unless specified in the html tag, in which case 1rem becomes the specified value.

<AuthProvider>
<body>
<SidebarLayout>{children}</SidebarLayout>
</body>
</AuthProvider>
</html>
);
}
4 changes: 4 additions & 0 deletions app/app/locations/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export default function Locations() {
return <h1>This is the locations page</h1>;
}

5 changes: 5 additions & 0 deletions app/app/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
// this page redirects to /crashes
// todo: what should go here
export default function Page() {
return <p> hello</p>;
}
Loading