Skip to content

Ability to upload and delete crash diagrams for temporary records#1971

Open
roseeichelmann wants to merge 10 commits intomainfrom
rose/26662_upload_crash_diagrams
Open

Ability to upload and delete crash diagrams for temporary records#1971
roseeichelmann wants to merge 10 commits intomainfrom
rose/26662_upload_crash_diagrams

Conversation

@roseeichelmann
Copy link
Contributor

@roseeichelmann roseeichelmann commented Feb 20, 2026

Associated issues

Closes cityofaustin/atd-data-tech#26662

Testing

URL to test:
Local

Steps to test:

  1. Start up your local VZ including the image API using
    ./vision-zero local-stack-up
  2. Go to a temp record
  3. You should see a button to upload a crash diagram, click on it and first try to upload something thats not a jpg or png, make sure you get an error. Also test throttling your network off to see the error
  4. Make sure that when you close and reopen the values have been reset
  5. Now actually upload an image for the crash diagram, see that there is a preview image, now click save and the diagram should immediately refetch on modal close
  6. The Edit diagram button should appear when a temp record has a diagram saved, use it to save a different image
  7. Test all the rotate/save controls to make sure they still work
  8. Test the delete button (Edit diagram -> Delete)
  9. Test that read only users cant see any of these buttons
  10. Test that the fatality image upload still works as expected

Ship list

  • Check migrations for any conflicts with latest migrations in main branch
  • Confirm Hasura role permissions for necessary access
  • Code reviewed
  • Product manager approved

@netlify
Copy link

netlify bot commented Feb 20, 2026

Deploy Preview for atd-vze-staging ready!

Name Link
🔨 Latest commit 9bc23fb
🔍 Latest deploy log https://app.netlify.com/projects/atd-vze-staging/deploys/69a9cc2f5e3bc300071224fe
😎 Deploy Preview https://deploy-preview-1971--atd-vze-staging.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@roseeichelmann roseeichelmann added the WIP Work in progress label Feb 20, 2026
@roseeichelmann roseeichelmann moved this from New to In Progress in DTS Dev Team Feb 20, 2026
@johnclary johnclary added WIP Work in progress and removed WIP Work in progress labels Mar 4, 2026
@roseeichelmann roseeichelmann removed the WIP Work in progress label Mar 5, 2026
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I ended up DRYing it up and making this into a reuseable/interchangeable component for both image upload modals (fatalities and crash diagrams)

</Form.Control.Feedback>
</Form.Group>
</Col>
{needsImageSource && (
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this whole change is just checking if this modal needs the image source field (such as in the fatality upload modal)


fetchImage();
}, [personId, getToken, imageVersion]);
const { imageUrl, refetch, isLoading } = useImage({
Copy link
Contributor Author

Choose a reason for hiding this comment

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

wow i did not know about this useImage hook @johnclary made 🤦 got to really DRY up all this code by deleting my useEffect above that is basically an exact replica of this useImage hook thats already being used for the crash diagrams

Copy link
Member

Choose a reason for hiding this comment

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

oh nice! i forgot about it even though it was just a few weeks ago: #1959 (comment)

setShowModal={setShowModal}
storedUrl={imageUrl}
title={`Upload crash diagram`}
url={`${process.env.NEXT_PUBLIC_CR3_API_DOMAIN}/images/crash_diagram/${crash.record_locator}`}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

if you fudge up this URL in your code editor you can test the error message in the modal

Copy link
Member

Choose a reason for hiding this comment

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

Looks good!

const token = await getToken();
const response = await fetch(url, {
headers: {
Authorization: `Bearer ${token}`,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

remove this line in your code editor to test error displayed when token is missing

@roseeichelmann roseeichelmann changed the title Ability to upload crash diagrams for temporary records Ability to upload and delete crash diagrams for temporary records Mar 5, 2026
Copy link
Member

@johnclary johnclary left a comment

Choose a reason for hiding this comment

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

Wow—works great and looks great. And coming at at just +13 lines of code 🙌

I left really minor feedback. I tested this quite a lot and everything is super smooth 🚀

import Image from "react-bootstrap/Image";
import Button from "react-bootstrap/Button";
import { FaRotate } from "react-icons/fa6";
import { FaRegPenToSquare } from "react-icons/fa6";
Copy link
Member

Choose a reason for hiding this comment

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

Would you switch this to

import { LuSquarePen } from "react-icons/lu";

😇

setShowModal={setShowModal}
storedUrl={imageUrl}
title={`Upload crash diagram`}
url={`${process.env.NEXT_PUBLIC_CR3_API_DOMAIN}/images/crash_diagram/${crash.record_locator}`}
Copy link
Member

Choose a reason for hiding this comment

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

Looks good!


fetchImage();
}, [personId, getToken, imageVersion]);
const { imageUrl, refetch, isLoading } = useImage({
Copy link
Member

Choose a reason for hiding this comment

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

oh nice! i forgot about it even though it was just a few weeks ago: #1959 (comment)

const file = watch("file");

const url = `${process.env.NEXT_PUBLIC_CR3_API_DOMAIN}/images/person/${personId}`;
const needsImageSource = defaultValues.hasOwnProperty("image_source");
Copy link
Member

@johnclary johnclary Mar 6, 2026

Choose a reason for hiding this comment

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

Love that you are making this component reusable!

This is working fine, but I think it could be more obvious from the component API that there is a switch that toggles the image source requirement.

Even thought it makes the component less abstract, it might be be better to remove the url and defaultValues props and instead use an explicit prop like imageType that indicates if the image is a crash diagram or person image. And then inside the component you can supply the correct url and defaultValues based on this prop value.

That way the dev doesn't have to know the right combination of URL and default values because the component handles it for you.

Copy link
Member

@chiaberry chiaberry left a comment

Choose a reason for hiding this comment

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

Tested uploading and deleting!

I kind of want a "Is temp crash" filter, but I just searched by T in the search bar and they came up.

What do you think about rewording the message "Crash diagrams are not available for temporary crash records". Seems a little contradictory saying that when theres a button immediately below it to add one.

I see John's comment that you are going to rework some of the component, so I'll do a quick retest after that and approve then.

@johnclary
Copy link
Member

What do you think about rewording the message "Crash diagrams are not available for temporary crash records".

Yes. Maybe "This temporary crash record does not have a diagram" - ?

I kind of want a "Is temp crash" filter

So did Xavier!

Screenshot 2026-03-06 at 3 35 29 PM

@chiaberry
Copy link
Member

@johnclary ill learn to scroll someday

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants