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

Create Log BE/FE Integration #129

Merged
merged 34 commits into from
Jul 15, 2023
Merged

Conversation

kevin-pierce
Copy link
Contributor

@kevin-pierce kevin-pierce commented Jun 29, 2023

GitHub Issue link

Create Log BE/FE Integration

Implementation description

Steps to test

What should reviewers focus on?

Checklist

  • My PR name is descriptive and in imperative tense
  • My commit messages are descriptive and in imperative tense. My commits are atomic and trivial commits are squashed or fixup'd into non-trivial commits
  • I have run the appropriate linter(s)
  • I have requested a review from the PL, as well as other devs who have background knowledge on this PR or who will be building on top of this PR
  • If I have made API changes, I have updated the REST API Docs
  • IF I have made changes to the db/models, I have updated the Data Models Page
  • I have updated other Docs as needed

@kevin-pierce kevin-pierce marked this pull request as draft June 29, 2023 02:46
@kevin-pierce kevin-pierce mentioned this pull request Jun 29, 2023
7 tasks
@kevin-pierce kevin-pierce requested a review from Safewaan June 29, 2023 03:59
frontend/src/APIClients/LogRecordAPIClient.ts Outdated Show resolved Hide resolved
frontend/src/APIClients/LogRecordAPIClient.ts Outdated Show resolved Hide resolved
frontend/src/APIClients/ResidentAPIClient.ts Outdated Show resolved Hide resolved
frontend/src/APIClients/ResidentAPIClient.ts Outdated Show resolved Hide resolved
frontend/src/APIClients/ResidentAPIClient.ts Outdated Show resolved Hide resolved
frontend/src/components/forms/CreateLog.tsx Show resolved Hide resolved
frontend/src/components/forms/CreateLog.tsx Outdated Show resolved Hide resolved
frontend/src/components/forms/CreateLog.tsx Outdated Show resolved Hide resolved
frontend/src/components/forms/CreateLog.tsx Outdated Show resolved Hide resolved
frontend/src/components/forms/CreateLog.tsx Outdated Show resolved Hide resolved
@Safewaan Safewaan mentioned this pull request Jul 6, 2023
7 tasks
@Safewaan Safewaan marked this pull request as ready for review July 11, 2023 01:57
@Safewaan Safewaan linked an issue Jul 11, 2023 that may be closed by this pull request
5 tasks
Copy link
Collaborator

@Safewaan Safewaan left a comment

Choose a reason for hiding this comment

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

LGTM 🚀 🌔 🎉 works as intended

Left a few comments- they can be ignored :D

// Ideally we should be storing this information in the database
const BUILDINGS = [
{ label: "144", value: "144 Erb St. West" },
{ label: "362", value: "362 Erb St. West" },
{ label: "402", value: "402 Erb St. West" },
];

const ALERT_DATA: AlertDataOptions = {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Helen merged in a PR that added a custom alert component. I'm okay with switching the alerts here after this pr is merged- this comment is more so a reminder to do that 🚗

frontend/src/components/forms/CreateLog.tsx Outdated Show resolved Hide resolved
@@ -68,12 +125,17 @@ const CreateLog = () => {
}),
);
const [building, setBuilding] = useState("");
const [resident, setResident] = useState("");
const [resident, setResident] = useState(-1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why use -1 instead of an empty state?

Copy link
Collaborator

Choose a reason for hiding this comment

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

would agree, I think because these are all strings anyways it's easier to make them empty strings

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 wanted to store the value of each field rather than their string representation (since the string representation isn't very useful in context of the API)

Copy link
Collaborator

@connor-bechthold connor-bechthold left a comment

Choose a reason for hiding this comment

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

All of my comments are general non-blocking but if you don't have time we can always address them later

Would recommend just briefly testing everything works after you fix the merge conflicts since they're generationally bad (can ping me or @Safewaan to help as well)

Also make sure to update any docs on API's changed when you get the chance

Thanks for getting this in 👨‍🍳 🧨

frontend/src/APIClients/LogRecordAPIClient.ts Outdated Show resolved Hide resolved
frontend/src/APIClients/LogRecordAPIClient.ts Outdated Show resolved Hide resolved
}

// Helper to get the currently logged in user
const getCurUserSelectOption = () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is HOT

Copy link
Contributor Author

@kevin-pierce kevin-pierce Jul 14, 2023

Choose a reason for hiding this comment

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

me copy pasta-ing the code below into a separate util function:

hot

frontend/src/components/forms/CreateLog.tsx Outdated Show resolved Hide resolved
@@ -68,12 +125,17 @@ const CreateLog = () => {
}),
);
const [building, setBuilding] = useState("");
const [resident, setResident] = useState("");
const [resident, setResident] = useState(-1);
Copy link
Collaborator

Choose a reason for hiding this comment

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

would agree, I think because these are all strings anyways it's easier to make them empty strings

@@ -161,9 +241,9 @@ const CreateLog = () => {
}),
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also a bunch of defaulted -1's here, if there's a reason for this than you can keep it but otherwise I would make them empty strings

const residentsData = await ResidentAPIClient.getResidents(true, 1, 1)

if (residentsData && residentsData.residents.length !== 0) {
// TODO: Remove the type assertions here
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could you clarify this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're leveraging non-null type assertions on those properties (below the comment IIRC) that we should probably refactor / remove at some point ; I included them for now to a) make my life easier with some of the merge conflicts and b) workaround to speed this up ; I've already made an issue to track this here - #148

frontend/src/components/forms/CreateLog.tsx Outdated Show resolved Hide resolved
frontend/src/components/forms/CreateLog.tsx Outdated Show resolved Hide resolved
frontend/src/types/LogRecordTypes.ts Outdated Show resolved Hide resolved
import { getLocalStorageObjProperty } from "../utils/LocalStorageUtils";
import baseAPIClient from "./BaseAPIClient";

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Rehomed these guys into the LogRecordAPIClient

@kevin-pierce kevin-pierce merged commit 3302547 into main Jul 15, 2023
@kevin-pierce kevin-pierce deleted the kevin/create-log-integration-v2 branch July 15, 2023 01:34
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.

Create Log BE/FE Integration
3 participants