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

feat-317: Add profile menu for applicants #330

Merged
merged 6 commits into from
Jun 28, 2024

Conversation

ruth-avelar
Copy link
Contributor

What does this PR do?

Add the profile menu for the applicant
When click 'Profile' menu it goes to applicant/$id
Then there is an edit icon and it goes to applicationForm and the form can be editable

Where should the reviewer start?

How should this be manually tested?

Any background context you want to provide?

What are the relevant tickets?

Screenshots

Questions

Checklist

  • I added the necessary documentation, if appropriate.
  • I added tests to prove that my fix is effective or my feature works.
  • I reviewed existing Pull Requests before submitting mine.

Comment on lines 40 to 45
useEffect(() => {
if (value !== undefined) {
setSelectedValue(value);
}
},[value, setSelectedValue])

Copy link
Collaborator

Choose a reason for hiding this comment

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

is this needed?

I think this line further down does more or less the same:

          value={selectedValue || ""}

Oh! Wait. I see, you added a value prop that we receive now. But I don't see where you are using that new prop.

The thing is that before what we were doing was that forms using this component are usually ValidatedForms. Which can receive a defaultValues prop that has an object with properties and values. This line further up gets the value for this component from that defaultValues property by it's name:

  const [selectedValue, setSelectedValue] = useControlField<string>(name);

Comment on lines 33 to 45
export const loader: LoaderFunction = async ({ request }) => {
try {
const profile = await requireProfile(request);
const applicant = await getApplicantByEmail(profile.email);

return {
applicant,
};
} catch (error) {
console.error("Error loading data:", error);
}
};

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 not a route component, so I think we don't know if the loader will work or not. Or rather, we don't know what route is going to use this component, many routes will, so we are not guaranteed to have this function ok.

Regular components (outside a Route component) should not use loaders, and instead just require any values as props.

@ruth-avelar ruth-avelar force-pushed the feat-317-Allow-applicants-to-edit-profile branch from 4115455 to 98ed7ad Compare April 25, 2024 22:16
@jackbravo jackbravo force-pushed the feat-317-Allow-applicants-to-edit-profile branch from 79392ce to a007f8e Compare June 20, 2024 18:46
Comment on lines 11 to 12
existApplicant?: boolean;
applicantId?: string | number;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe we can just have applicantId, if we allow undefined we can check if its set or not, instead of using existApplicant

Comment on lines 50 to 57
const handleClickProfileApplicant = async () => {
submit(null, {
method: "get",
action: `/applicants/${applicantId}`,
});
};

const handleLogout = async () => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Oh! I haven't reviewed this code when it was first added (I mean for example the other handleClickProfile function). In general, I think it is better to use proper links instead of onClick actions and functions that depend on react. Links already provide good functionality, you can right-click on them to open in new tab, etc.

@@ -27,11 +28,13 @@ const StyledHeaderButton = styled(Button)(({ theme }) => ({
},
}));

const Header = ({ existApplicant }: IProps) => {

const Header = ({ existApplicant, applicantId }: IProps) => {
const currentUser = useOptionalUser();
Copy link
Collaborator

Choose a reason for hiding this comment

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

I wonder if we could add a useOptionalApplicant() function, to not have to pass the applicantId as a parameter... 🤔

Copy link
Collaborator

@jackbravo jackbravo left a comment

Choose a reason for hiding this comment

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

I was proposing a lot of changes to this PR, but I see that it was growing too big. So instead I'm going to approve this one and submit a follow up PR.

@jackbravo jackbravo merged commit bed6fb0 into main Jun 28, 2024
7 checks passed
@jackbravo jackbravo deleted the feat-317-Allow-applicants-to-edit-profile branch June 28, 2024 13:49
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.

2 participants