jcostadev23 / obras

1 stars 0 forks source link

[Bug] Rendering a calendar day without all info #11

Closed jaapaurelio closed 1 year ago

jaapaurelio commented 1 year ago

Currently, if we try to create a calendar day without one of the properties we get an error when we render the list of calendar days. Later we'll have a ticket to prevent submit a calendar day without all info, but nevertheless, we want this to be fixed. Page should not break if something is missing.

How to reproduce: Be ware that we're using a Job but this also happens with People and Equipment.

1 - Create a Calendar day without a Job:

Screenshot 2023-04-01 at 13 25 09

2 - Go to the calendar list page. A error will show up saying that it is impossible to read item.job.name.

Screenshot 2023-04-01 at 13 24 50

What is really happening

Since we created a calendar day without a job, it is impossible to access item.job.name because there is no job.

To prevent this error we can make a condition to make sure we have a job before accessing the job.name.

On the calendar list: Before:

<div>job: {item.job.name}</div>

After:

{item.job && <div>job: {item.job.name}</div>}

This means, if we have an item.job then create a div with a item.job.name.

After doing this, we should see the list of calendars. When there is no job associated with the calendar day, we will not show the job name.

After making sure this is fixed for the job object, add the same logic to the remaining objects: people and equipement. Make sure to test each one individually by creating a calendar day without them.

<div>people: {item.people.name}</div>
<div>job: {item.job.name}</div>
<div>equipement: {item.equipement.name}</div>
jcostadev23 commented 1 year ago

All done

jaapaurelio commented 1 year ago

Still not working for jobs!

jcostadev23 commented 1 year ago

All fixt