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

Mod submitter date update #2264

Merged
merged 5 commits into from
Jun 13, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading