jcostadev23 / obras

1 stars 0 forks source link

Person page #19

Closed jaapaurelio closed 1 year ago

jaapaurelio commented 1 year ago

We should have a page to list all the person information plus all the days where he worked.

The URL will be /people/[id]

This has to show the user card, like in the edit page. After, a list of all the days where this user worked.

Something like the calendar page but only for days where this user worked.

The query should be similar to the calendar one, but with some condition to filter only this user id.

Useful example for documentation

https://docs.amplify.aws/lib/datastore/data-access/q/platform/js/#predicates

Screenshot 2023-04-04 at 09 00 21

Here they are getting all Posts (Articles) where the rating is greater (gt) than 4.

We want something similar but we want all Calendar where people id is the id of this person.

Without testing, it will be something similar to

const calendarDays = await DataStore.query(Calendar, (c) => c.calendarPeopleId.eq(personId));

I didn't test this code but it should work or be very close to work. You might need to adapt something.

calendarPeopleId is the property we want to filter by. Open devtools and check the Calendar data. We can see that we want all calendar where the calendarPeopleId is from the person we want.

personId is the variable where we saved this person id. From router.query.

Screenshot 2023-04-04 at 09 04 38

The end result

We should show all calendar days from this user. User page Jose:

Screenshot_20230404-233250

jcostadev23 commented 1 year ago

Done