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

Edit basic info modal/kirustar14/personal info modal #43

Merged
merged 22 commits into from
Feb 28, 2025

Conversation

kirustar14
Copy link
Contributor

@kirustar14 kirustar14 commented Jan 22, 2025

Tracking Info

Resolves #19

Changes

Fixed the edit basic info modal following Figma style.

Testing

Opened the modal in page.tsx and removed it after.

Confirmation of Change

image

@kirustar14 kirustar14 requested a review from Miyuki-L as a code owner January 22, 2025 20:49
@Miyuki-L Miyuki-L requested review from azpi-arte and r800360 and removed request for azpi-arte January 23, 2025 00:06
@kirustar14 kirustar14 linked an issue Jan 23, 2025 that may be closed by this pull request
Copy link
Member

@r800360 r800360 left a comment

Choose a reason for hiding this comment

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

I went ahead and moved the code from frontend/src/app/Components to frontend/src/components as discussed in Issue #19 Edit Basic Info Modal

To manually test this code, I used the attached frontend/src/app/page.tsx:
"use client";

import Image from "next/image";
import { useState } from "react";
import EditBasicInfoModal from "@/components/EditBasicInfoModal/EditBasicInfoModal";

export default function Home() {
const [isOpen, setIsOpen] = useState(false);

const handleOnSubmit = (data: {
firstName: string;
lastName: string;
email: string;
phone: string;
}) => {
console.log("Submitted Data:", data); // Log to verify form submission
};
return (


<button onClick={() => setIsOpen(true)}>Open Modal
<EditBasicInfoModal
isOpen={isOpen}
onClose={() => setIsOpen(false)}
onSubmit={handleOnSubmit}
/>

);
}

This code generally seems to meet most requirements for Issue #19 on Edit Basic Info Modal except that the component is not sufficiently vertically responsive as demonstrated by the screenshot below.

image

A fix would be to try to scale the component vertical window size as per the browser vertical window size. This concludes my PR review; I am not requesting changes as this might not be an essential fix.

Copy link
Member

@Miyuki-L Miyuki-L left a comment

Choose a reason for hiding this comment

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

SINCE ROHAN MADE A COMMIT MAKE SURE TO PULL BEFORE PUSHING, IDEALLY PULL BEFORE MAKING PR REVIEW EDITS

Generally a good First Tasks.

CSS needs clean up and simplification and removal of repetition (Let me know if you need help)

Forgot to add in the task before hand (my bad) can you use the following resources below to handle the form input validation (also error messages) and react hook form optimizes things in terms of renderings

Tutorials/Resources
(Handles form field updates) https://react-hook-form.com/
(Input Validation) https://zod.dev/
Tutorial (on reacthook and zod working together)- https://www.freecodecamp.org/news/react-form-validation-zod-react-hook-form/

Also add in an index.ts file un the components folder to export the component (this will clean up the imports in the future)
See Onboarding example: https://github.com/TritonSE/onboarding/blob/main/frontend/src/components/index.ts

background: white;
padding: 40px;
border-radius: 15px;
width: 657px;
Copy link
Member

Choose a reason for hiding this comment

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

This is a big size to hard code in px. See if you can use rem, em, vw, vh relative units. This will also make the pop up scale to screen size more easily likely addressing the problem Rohan brought up in his review

.close-button {
position: absolute;
top: 31px;
left: 595px;
Copy link
Member

Choose a reason for hiding this comment

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

Same thing try relative units


/* Save Button Container */
.modal-footer button {
width: 520.76px;
Copy link
Member

Choose a reason for hiding this comment

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

try relative units

If you are pulling the units from figma 520 is fin don't need to go until 520.76

font-weight: 400;
font-size: 20px;
line-height: 26.04px;
color: #000000;
Copy link
Member

Choose a reason for hiding this comment

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

can we not just use black?

Comment on lines 147 to 153
.phone-group input::placeholder {
font-family: "DM Sans", sans-serif;
font-weight: 400;
font-size: 17px;
line-height: 22.13px;
color: #b4b4b4;
}
Copy link
Member

Choose a reason for hiding this comment

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

A lot of repetition in code

Just give the elements with the same stylines the same class name

If need to be slightly different then give it an id attribute (which is unique) to target that specific element

Comment on lines 39 to 42
<svg width="14" height="14" viewBox="0 0 14 14" xmlns="http://www.w3.org/2000/svg">
<line x1="0" y1="0" x2="14" y2="14" stroke="#000000" strokeWidth="1.5" />
<line x1="14" y1="0" x2="0" y2="14" stroke="#000000" strokeWidth="1.5" />
</svg>
Copy link
Member

Choose a reason for hiding this comment

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

Create a separate file for this svg under Public/icons

Then import it and use it -- > Max code more readable

Not sure where you code the code from but you can get it straight from the designers figma

<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none">
  <path d="M5 19L12 12M12 12L19 5M12 12L5 5M12 12L19 19" stroke="black" stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round"/>
</svg>

See How they import and use the icon https://github.com/TritonSE/PAP-Inventory-Processing/blob/ea2e7275d40f10fca354eb749f253a52cc75ef60/frontend/src/components/VSRIndividual/VSRIndividualPage/index.tsx#L561-L566

const EditBasicInfoModal = ({
isOpen,
onClose,
onSubmit,
Copy link
Member

Choose a reason for hiding this comment

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

onSubmit doesn't need to be passed it

Since what will happen when submitting is sending the data collected in the form over to the backend

nothing exterior is necessary

Copy link
Member

Choose a reason for hiding this comment

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

Overall The CSS for the model seems

Top and Left, Height, use for absolute shouldn't be needed so frequently

Usually adding padding and margin to the element and setting their gaps should be sufficient

const [phone, setPhone] = useState("");

// Modify handleSave to use onSubmit from parent
const handleSave = () => {
Copy link
Member

Choose a reason for hiding this comment

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

Put this in a useCallback

useCallback is for optimizing rendering since unless its dependencies change when screen is rerendered it will not recreate the function
Docs: https://react.dev/reference/react/useCallback

Copy link
Member

@Miyuki-L Miyuki-L left a comment

Choose a reason for hiding this comment

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

Looks Great! Just a few more css changes and it should be good.

phone: z
.string()
.min(1, "Phone Number is required")
.refine((val) => val.length >= 10, {
Copy link
Member

Choose a reason for hiding this comment

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

It seems phonenumbers in the world can be from 5 to 15. We need to take into account phone numbers from different contries.

Copy link
Member

Choose a reason for hiding this comment

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

There should be no package-lock.json at the root directory. Delete this file

Comment on lines 50 to 56
const response = await fetch("/your-api-endpoint", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify(data),
});
Copy link
Member

Choose a reason for hiding this comment

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

Create this as a function in src/api folder see the onboarding repo for reference. Let's keep all functions that call the backend defiend overthere. and then import and call it here

Copy link
Member

Choose a reason for hiding this comment

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

CSS looks a lot cleaner!.

the modal still seems to big interms of the general size of an element.
image

For the determining relative sizes to use you can write the css start up the frontend inspect that element to see what the resulting size interms of pixels is and compare it to the figma and adjust.

I think the modal should be almost done but we just need to size down everything in the modal

@Miyuki-L Miyuki-L requested a review from r800360 February 10, 2025 01:09
@Miyuki-L Miyuki-L force-pushed the EditBasicInfoModal/kirustar14/PersonalInfoModal branch from ecc859f to daaf5d9 Compare February 18, 2025 07:16
Copy link
Member

@Miyuki-L Miyuki-L left a comment

Choose a reason for hiding this comment

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

Almost there just a few things about the fetch request and resolve the merge conflicts

Copy link
Member

Choose a reason for hiding this comment

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

let's keep this page.tsx as is

//not sure how to send data to backend
const onSubmit: SubmitHandler<FormData> = async (data) => {
try {
const response = await fetchRequest("POST", "/your-api-endpoint", data, {});
Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

let's keep this page as is

@@ -0,0 +1,23 @@
type Method = "GET" | "POST" | "PUT";

export async function fetchRequest(
Copy link
Member

Choose a reason for hiding this comment

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

rename this function to be specific to this modal and with more information
i.e. editBasicInfoRequest

Copy link
Member

Choose a reason for hiding this comment

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

The backend route for this functionality should be in. (just a dummy one right now but you should be able to call it

Copy link
Member

@Miyuki-L Miyuki-L left a comment

Choose a reason for hiding this comment

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

1-2 little notes and adjust the spacing for the save button as discussed in the meeting on wednessday.

It so close but you are almost there

resolver: zodResolver(schema),
});

const onSubmit: SubmitHandler<FormData> = async (data) => {
Copy link
Member

Choose a reason for hiding this comment

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

put this in a usecallback

Copy link
Member

Choose a reason for hiding this comment

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

package--lock looks like it took out some dependencies which should still be there. Just npm install again on the frontend folder

Copy link
Member

@Miyuki-L Miyuki-L left a comment

Choose a reason for hiding this comment

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

Looks Good Great!

Copy link
Member

@r800360 r800360 left a comment

Choose a reason for hiding this comment

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

I have reviewed this code and tested the Modal and it looked mostly good to me. Nice work on this, Kiruthika!

I realized the phone number validation was particularly weak, so I used a really standard regular expression for this purpose in conjunction with the zod validation in frontend/src/components/EditBasicInfoModal.tsx. I also added the normalization of phone numbers so that the formatting is standard when we store it (removing dots, dashes, spaces, parentheses). I think the minimum phone number length is 7 rather than 5 (ITU-T E.164) so I updated that.

It looks good to me, so I will pass it back to Helen to review and merge.

@r800360 r800360 requested a review from Miyuki-L February 27, 2025 06:20
@Miyuki-L Miyuki-L force-pushed the EditBasicInfoModal/kirustar14/PersonalInfoModal branch from 7aaca08 to 273388a Compare February 28, 2025 08:51
@Miyuki-L Miyuki-L merged commit c5ef0cf into main Feb 28, 2025
1 of 2 checks passed
@Miyuki-L Miyuki-L deleted the EditBasicInfoModal/kirustar14/PersonalInfoModal branch February 28, 2025 08:52
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.

Edit Basic Info Modal
3 participants