Skip to content

Commit

Permalink
Updating available fields for updates
Browse files Browse the repository at this point in the history
Updates the moderation form to allow edits of createdOn and submitter

Adds some validations

Include HH:MM in time selection

UTC, Grid, and fix button height

refactor to reuse TimeAgo, tidy up date time checks

Date edit refactoring

rename fields for consistency, add hidden field to fix time not getting set correctly

Remove date replacement, still need to test against latest update

Remove FIXME, reorder of submitter check for consistency, reorder createdOn and submitter to minimize changes

Update app/routes/circulars._archive._index/route.tsx

Co-authored-by: Leo Singer <[email protected]>

Style updates for consistency, spacing, other PR feedback implementations

refine the cirteria for error or success class on date string
  • Loading branch information
dakota002 committed Jun 12, 2024
1 parent f23abf7 commit 56a7695
Show file tree
Hide file tree
Showing 9 changed files with 269 additions and 115 deletions.
2 changes: 1 addition & 1 deletion app/components/TimeAgo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import RelativeTime from 'dayjs/plugin/relativeTime'

dayjs.locale(locale)
dayjs.extend(RelativeTime)
const dateTimeFormat = new Intl.DateTimeFormat(locale.name, {
export const dateTimeFormat = new Intl.DateTimeFormat(locale.name, {
dateStyle: 'full',
timeStyle: 'long',
timeZone: 'utc',
Expand Down
18 changes: 16 additions & 2 deletions app/routes/circulars._archive._index/route.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import {
createChangeRequest,
get,
getChangeRequests,
moderatorGroup,
put,
putVersion,
search,
Expand Down Expand Up @@ -97,9 +98,22 @@ export async function action({ request }: ActionFunctionArgs) {
if (circularId === undefined)
throw new Response('circularId is required', { status: 400 })
if (!user?.name || !user.email) throw new Response(null, { status: 403 })

let submitter, createdOnDate, createdOnTime, createdOn
if (user.groups.includes(moderatorGroup)) {
submitter = getFormDataString(data, 'submitter')
createdOnDate = getFormDataString(data, 'createdOnDate')
createdOnTime = getFormDataString(data, 'createdOnTime')
createdOn = Date.parse(`${createdOnDate} ${createdOnTime} UTC`)
}
if (!submitter || !createdOnDate || !createdOnTime || !createdOn)
throw new Response(null, { status: 400 })
await createChangeRequest(
{ circularId: parseFloat(circularId), ...props },
{
circularId: parseFloat(circularId),
...props,
submitter,
createdOn,
},
user
)
await postZendeskRequest({
Expand Down
8 changes: 7 additions & 1 deletion app/routes/circulars.correction.$circularId.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,19 @@ export async function loader({
const user = await getUser(request)
if (!user?.groups.includes(group)) throw new Response(null, { status: 403 })
const circular = await get(parseFloat(circularId))
const defaultDateTime = new Date(circular.createdOn ?? 0)
.toISOString()
.split('T')

return {
formattedContributor: user ? formatAuthor(user) : '',
defaultBody: circular.body,
defaultSubject: circular.subject,
defaultFormat: circular.format,
circularId: circular.circularId,
submitter: circular.submitter,
defaultSubmitter: circular.submitter,
defaultCreatedOnDate: defaultDateTime[0],
defaultCreatedOnTime: defaultDateTime[1].substring(0, 5),
searchString: '',
}
}
Expand Down
Loading

0 comments on commit 56a7695

Please sign in to comment.