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

Remove time from event startDate / endDate fields in the CMS #1091

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

CharlyMartin
Copy link
Collaborator

@CharlyMartin CharlyMartin commented Feb 12, 2025

📝 Description

This PR updates the event's startDate / endDate fields by removing the time portion. This will improve the CMS UX for the content team, standardize the data and make things clearer for us.

🛠️ Key Changes

  • Updates config.yml with new datetime format - 7a61172
  • Removes the time portion from all event Markdown entries - 06fd2ec
  • Refactors getMetaData to display a single date if the start and end dates are the same.
  • Fixes a bug in event sorting where an event can be both upcoming and past, as seen on fil.org today with the Digital Real Estate Summit event - 7920f0c

🧪 How to Test

Run the CMS locally, create an event and make sure the start and end times are only dates, not times.

📸 Screenshots

CleanShot 2025-02-12 at 14 31 57@2x

🔖 Resources

Copy link

vercel bot commented Feb 12, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
ffdweb-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 12, 2025 0:20am
filecoin-foundation-site ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 12, 2025 0:20am

Copy link

@CharlyMartin CharlyMartin changed the title UXIT-2094/improve-cms-event-dates Remove the time from the startDate / endDate fields for events in the CMS. Feb 12, 2025
@CharlyMartin CharlyMartin marked this pull request as ready for review February 12, 2025 12:34
@CharlyMartin CharlyMartin changed the title Remove the time from the startDate / endDate fields for events in the CMS. Remove time from event's startDate / endDate fields in the CMS Feb 12, 2025
@CharlyMartin CharlyMartin changed the title Remove time from event's startDate / endDate fields in the CMS Remove time from event startDate / endDate fields in the CMS Feb 12, 2025
@barbaraperic
Copy link
Collaborator

Just testing for now! I've added end date, and removed it - which caused a zod error:

Error [ZodError]: [
  {
    "code": "invalid_date",
    "path": [
      "end-date"
    ],
    "message": "Invalid date"
  }
]

Basically the field went from end-date: 2025-02-13 to end-date: ""

@barbaraperic
Copy link
Collaborator

Think it's unrelated to this PR, but I was able to create an event without SEO description, and zod started screaming.

 ⨯ Error [ZodError]: [
  {
    "code": "invalid_type",
    "expected": "string",
    "received": "undefined",
    "path": [
      "seo",
      "description"
    ],
    "message": "Required"
  },
  {
    "code": "invalid_date",
    "path": [
      "end-date"
    ],
    "message": "Invalid date"
  }
]
    at async getMarkdownData (src/app/_utils/getMarkdownData.ts:39:23)
    at async getEventsData (src/app/events/utils/getEventData.ts:17:20)
    at async Object.generateStaticParams (webpack-internal:/(rsc)/src/app/events/[slug]/src/app/events/[slug]/page.tsx:137:18)
  37 |     const dataToValidate = content ? { ...data, content } : data
  38 |
> 39 |     const parsedData = await zodSchema.parseAsync(dataToValidate)
     |                       ^

@barbaraperic
Copy link
Collaborator

Suuuper random edge case, but we allow start-date to be after end-date. Example: start-date: 2025-02-12
end-date: 2025-02-13.

Comment on lines +20 to +31
if (!endDate) {
return [formattedStartDate, location]
}

if (isSameDay(startDate, endDate)) {
return [formattedStartDate, location]
}

const formattedEndDate = formatDate(endDate)
const dateRange = `${formattedStartDate} - ${formattedEndDate}`

return [dateRange, location]
Copy link
Collaborator

Choose a reason for hiding this comment

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

this reads nicely 😊

Comment on lines +11 to +12
start-date: 2022-08-24
end-date: 2022-08-22
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 the other way around? 🧐

Copy link
Collaborator Author

@CharlyMartin CharlyMartin Feb 13, 2025

Choose a reason for hiding this comment

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

It should definitely be the other way around 😅 And that's a good catch! Nothing prevents the author from doing this, I'll add a Zod validation to catch these mistakes for us 🙏

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@mirhamasala
Copy link
Collaborator

Think it's unrelated to this PR, but I was able to create an event without SEO description, and zod started screaming.

@barbaraperic This has been fixed in #1098

@@ -7,8 +7,8 @@ category: supported-sponsored
location:
primary: San Francisco, CA
region: north-america
start-date: 2024-05-14T15:48:19.518Z
end-date: 2024-05-15T15:48:19.530Z
start-date: 2024-05-14
Copy link
Collaborator

Choose a reason for hiding this comment

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

Have we tested this using Chrome DevTools → Network tab → More tools → Sensors?

I’m concerned that some systems (browsers) might assume the date is in local time, especially if they automatically attach a time zone.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's a valid concern!

When logging the data here I see this, which is what we want!

startDate 2024-11-06T00:00:00.000Z
endDate 2024-11-12T00:00:00.000Z

But I'll play with the Sensors and see if we get different results in the US vs Asia.

@CharlyMartin
Copy link
Collaborator Author

CharlyMartin commented Feb 13, 2025

Just testing for now! I've added end date, and removed it - which caused a zod error:

Yes, this is not related to this PR, this is how Decap works. It doesn't delete fields sadly 🥲

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.

3 participants