date logic changed#358
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates week/date handling across the API and admin UI by replacing custom UTC/week-boundary logic with dayjs (UTC + ISO week), while also expanding the admin form builder experience (history filtering UI, publish success + empty-form draft flows, and form deletion).
Changes:
- Standardize week-bound computations (Mon–Sun, UTC) and date formatting using
dayjs+isoWeek+utcin server endpoints and admin pages. - Improve admin builder UX: history toolbar + advanced filter drawer, keyword search, empty-form draft prompt, publish success modal, and delete action.
- Regenerate/update
package-lock.jsonmetadata.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
| server/api/form/index.ts | Switch weekday formatting + weekly bounds to dayjs.utc().startOf/endOf('isoWeek'). |
| server/api/admin/class-progress.get.ts | Replace custom date/week parsing + YMD formatting with dayjs ISO-week logic for filtering and output. |
| app/composables/useAdmin.ts | Update date formatting, add builder state for new filters/modals, and refactor publish flow + deletion support. |
| app/pages/admin/builder.vue | Update builder UI to use new composable state, add modals and advanced filters drawer, and adjust week label logic. |
| app/pages/admin/raffle.vue | Replace getLastMonday usage with dayjs ISO-week week-start display. |
| app/pages/admin/styles/builder.css | Add styles for new modals, toolbar/drawer UI, and empty-form/publish-success presentation. |
| package-lock.json | Lockfile metadata churn (peer flags and related fields). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| const createdFormResponse = await callFormApi<any>('POST', {}, { | ||
| action: 'createForm', | ||
| startDate: weekStart || dayjs.utc().startOf('isoWeek').format('YYYY-MM-DD'), | ||
| published, | ||
| title: formTitle.value, | ||
| }) |
| if (selectedDate) { | ||
| const { mondayDate, sundayDate } = getWeekBoundsDates(selectedDate) | ||
| const mondayDate = dayjs.utc(selectedDate).startOf('isoWeek').toDate() | ||
| const sundayDate = dayjs.utc(selectedDate).endOf('isoWeek').toDate() |
| const mondayDate = dayjs.utc(selectedDate).startOf('isoWeek').toDate() | ||
| const sundayDate = dayjs.utc(selectedDate).endOf('isoWeek').toDate() |
| const mondayDate = dayjs.utc(selectedDate).startOf('isoWeek').toDate() | ||
| const sundayDate = dayjs.utc(selectedDate).endOf('isoWeek').toDate() |
| .empty-form-copy { margin: 0; color: #374151; font-weight: 500; line-height: 1.5; } | ||
|
|
||
| .empty-form-copy { margin: 0; color: #374151; font-weight: 500; line-height: 1.5; } | ||
|
|
| <div class="modal-box"> | ||
| <div class="modal-header"> | ||
| <div> | ||
| <h3 class="modal-title">You cannot publish because its empty.</h3> |
There was a problem hiding this comment.
"You cannot publish because form is empty" => better wording
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
All of this frontend date logic should be abstracted to its own composable. This will help clean up this composable as well as make it cleaner/clearer/easier to use the date functions on the reader side
| }) | ||
| } | ||
|
|
||
| const parseLocalDate = (value: string) => { |
There was a problem hiding this comment.
I this can be replaced with Dayjs functions
| @@ -35,10 +37,7 @@ | |||
| } | |||
|
|
|||
| const formatYmdLocal = (date: Date) => { | |||
There was a problem hiding this comment.
what purpose does this function now serve?
| form.status = form.status === 'Active' ? 'Unpublished' : 'Active' | ||
| } | ||
|
|
||
| const deleteStoredForm = async (form: any, skipConfirm = false) => { |
| } | ||
| } | ||
|
|
||
| const saveEmptyFormDraft = async () => { |
| <div class="modal-box"> | ||
| <div class="modal-header"> | ||
| <div> | ||
| <h3 class="modal-title">You cannot publish because its empty.</h3> |
There was a problem hiding this comment.
"You cannot publish because form is empty" => better wording
| <!-- FORM DETAILS MODAL --> | ||
| <!-- ══════════════════════════════════════════ --> | ||
| <Transition name="fade"> | ||
| <div v-if="emptyFormPromptOpen" class="modal-backdrop"> |
There was a problem hiding this comment.
when does emptyFormPromptOpen ever get set to true => when does this popup ever show?
| </div> | ||
|
|
||
| <div class="modal-footer success-footer"> | ||
| <button class="btn-indigo" @click="publishSuccessInfo = null; builderSubTab = 'history';">View in History</button> |
There was a problem hiding this comment.
No functional difference between these two buttons, both lead to the form history page
There was a problem hiding this comment.
only issue is the same one the copilot review stated: First validate that selectedDate value from query parameters is 1. not null, 2. a legitimate date value,
No description provided.