Skip to content

Conversation

@MehekB
Copy link
Contributor

@MehekB MehekB commented Apr 12, 2025

Description

Added ability for admin to create a new client and add to the client list.

Key Features:

  • Add Client Form: Collects essential client information (first_name, last_name, etc.).
  • Cancel Confirmation Dialog: When users click Cancel, a modal AlertDialog prompts for confirmation before discarding data.
  • Form Submission: validates input and sends a POST request via backend.post('/clients', clientData), displaying a success or error toast.

Screenshots/Media

When "Add New Client" is clicked

Screenshot 2025-04-12 at 12 40 48 PM

Confirmation for cancelling

Screenshot 2025-04-12 at 12 27 56 PM

Issues

Closes #130

Copy link
Collaborator

@benson-fm benson-fm left a comment

Choose a reason for hiding this comment

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

Hey guys,

great start on the task, there's some things that need to be fixed like overall flow and some features missing but the base level stuff is there great work! If you need any clarification lmk!

destination_city: formData.destination_city,
comments: formData.comments
};
console.log(clientData)
Copy link
Collaborator

Choose a reason for hiding this comment

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

you can remove this

Comment on lines 100 to 101
// site: formData.site,
// case_managers: formData.case_managers,
Copy link
Collaborator

Choose a reason for hiding this comment

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

im not entirely sure if this used, since its commented and you aren't using it you can go ahead and delete it

homelessness_length: parseInt(formData.homelessness_length || "0", 10),
chronically_homeless: formData.chronically_homeless === "Yes" ? true : false ,
attending_school_upon_entry: formData.attending_school_upon_entry === "Yes" ? true : false ,
employement_gained: formData.employment_gained,
Copy link
Collaborator

Choose a reason for hiding this comment

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

mispelling right here could lead to unexpected behavior

const {backend} = useBackendContext()
const toast = useToast()

const handleSubmit = async (event: React.FormEvent) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

For this instance when I press submit, it doesn't directly get loaded, you may want to do a useEffect hook where once submit is ran the a fetch would be made again to the db for the changes to be reflected on the table

const {backend} = useBackendContext()
const toast = useToast()

const handleSubmit = async (event: React.FormEvent) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

image

In this instance it needs to say missing fields refer to this figma

Copy link
Collaborator

Choose a reason for hiding this comment

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

Also instead of error occurred print the specific words that are listed in the figma for the red pop up

https://www.figma.com/design/sHKYRo824s5Te8qKZeiaAP/-CCH--2.-Lo-Fi--%3E-Hi-Fi?node-id=8590-89264&t=pNYLbb0GaO1btOOR-4

>
<DrawerOverlay />
<DrawerContent>
<DrawerCloseButton />
Copy link
Collaborator

Choose a reason for hiding this comment

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

Also note that when the drawer is closed that the following flow happens as seen in the figma where a component pops out saying that there is a new client and they could edit it meaning that you would need to save the data there even if it means you exit out of the pop up the data is still there

https://www.figma.com/design/sHKYRo824s5Te8qKZeiaAP/-CCH--2.-Lo-Fi--%3E-Hi-Fi?node-id=8593-204040&t=pNYLbb0GaO1btOOR-4

Copy link
Collaborator

Choose a reason for hiding this comment

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

So there is an issue with this feature is when that I submit a client to be added and I finish, this notification is still there, this needs to be gone when I successfully submit a client so you may want to use a useState here

Furthermore there isn't a option where I can click on the return to editing client, make sure you add this button, you may want to add onClick function for this

@dlacuata dlacuata requested a review from benson-fm April 26, 2025 23:04
Copy link
Collaborator

@benson-fm benson-fm left a comment

Choose a reason for hiding this comment

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

Great work on the fixes guys, theres some extra stuff that needs to be fixed just look through my comments but other than that great job!

homelessness_length: "",
chronically_homeless: "",
attending_school_upon_entry: "",
employment_gained: "",
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 technically correct, however, there is an issue where currently right now the table in the db is misspelled for right now just change it to employement and the other instances that are considered of this specific column.

homelessness_length: parseInt(formData.homelessness_length || "0", 10),
chronically_homeless: formData.chronically_homeless === "Yes" ? true : false ,
attending_school_upon_entry: formData.attending_school_upon_entry === "Yes" ? true : false ,
employment_gained: formData.employment_gained,
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here with the employement thing I was talking about above

>
<DrawerOverlay />
<DrawerContent>
<DrawerCloseButton />
Copy link
Collaborator

Choose a reason for hiding this comment

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

So there is an issue with this feature is when that I submit a client to be added and I finish, this notification is still there, this needs to be gone when I successfully submit a client so you may want to use a useState here

Furthermore there isn't a option where I can click on the return to editing client, make sure you add this button, you may want to add onClick function for this

Comment on lines +223 to +247
<Text fontWeight="medium">First Name</Text>
<Input placeholder="Short Answer" value={formData.first_name}
onChange={(e) => {setFormData({ ...formData, first_name: e.target.value }); setFormInProgress(true); setShowUnfinishedAlert(true)}}
/>

<Text fontWeight="medium">Last Name</Text>
<Input placeholder="Short Answer" value={formData.last_name}
onChange={(e) => {setFormData({ ...formData, last_name: e.target.value }); setFormInProgress(true)}}
/>

<Text fontWeight="medium">Status</Text>
<Select placeholder="Select option" value={formData.status}
onChange={(e) => {setFormData({ ...formData, status: e.target.value }); setFormInProgress(true)}}>
<option value="Active">Active</option>
<option value="Exited">Exited</option>
</Select>

<Text fontWeight="medium">Site</Text>
<Input placeholder="Short Answer"
onChange={(e) => {setFormData({ ...formData, site: e.target.value }); setFormInProgress(true)}}
/>

<Text fontWeight="medium">Unit ID</Text>
<Input placeholder="Short Answer" value={formData.unit_id}
onChange={(e) => {setFormData({ ...formData, unit_id: e.target.value }); setFormInProgress(true)}}
Copy link
Collaborator

Choose a reason for hiding this comment

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

This and the following stuff below as we want to get more readable code we see some similar patterns here. What I would want you guys to do here is to make a separate component and you can insert some parameters to decrease the amount of lines maybe something like

SomeComponentYesAndNo (title, placeholder, formDataTitle) {
    <Text>{title}</Text>
    <Input placeholder={placehodler} onCHange{ setFormData({...formData, {formDataTitle}: e.target.value})}>
}


SomeComponentSelect () {
 ...
}

</Select>

<Text fontWeight="medium">Employment Gained</Text>
<Select placeholder="Select option" value={formData.employment_gained}
Copy link
Collaborator

Choose a reason for hiding this comment

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

what i was talking about employement you might want to change here


<Text fontWeight="medium">Employment Gained</Text>
<Select placeholder="Select option" value={formData.employment_gained}
onChange={(e) => {setFormData({ ...formData, employment_gained: e.target.value }); setFormInProgress(true)}}>
Copy link
Collaborator

Choose a reason for hiding this comment

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

this too

@srukelman srukelman merged commit 09fa8e0 into main May 4, 2025
1 check failed
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.

Admin Manually Add Client to Client List

5 participants