Skip to content

Commit

Permalink
#109: Add field and submission for call-for-papers deadline
Browse files Browse the repository at this point in the history
  • Loading branch information
Espen Norderud committed Aug 3, 2023
1 parent ae38ed0 commit 71fe0f3
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 38 deletions.
3 changes: 2 additions & 1 deletion src/lib/server/sanityClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ export async function createConference(
slug: { _type: 'slug', current: slugCurrent },
title: conference.title,
startDate: conference.startDate,
endDate: conference.endDate,
endDate: conference.endDate,
callForPapersDate: conference.callForPapersDate,
url: conference.url,
categoryTag: conference.categoryTag ?? [],
internal: false
Expand Down
1 change: 1 addition & 0 deletions src/lib/types/conference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const Conference = z.object({
title: z.string().trim().min(1, {message: "Missing or invalid title"}),
startDate: z.string().trim().regex(yyyymmdd, {message: "Start date must be on the format YYYY-MM-DD"}).datetime( {message: "Missing or invalid start date"}),
endDate: z.string().trim().regex(yyyymmdd, {message: "End date must be on the format YYYY-MM-DD"}).datetime( {message: "Missing or invalid end date"}),
callForPapersDate: z.string().trim().regex(yyyymmdd, {message: "Call-for-papers date must be on the format YYYY-MM-DD"}).optional(),
url: z.string().trim().min(1, {message: "Missing or invalid url"}).url({ message: "Invalid url" }),
internal: z.boolean().optional(),
categoryTag: z.array(z.nativeEnum(ConferenceCategory)).optional(),
Expand Down
11 changes: 7 additions & 4 deletions src/routes/api/create-conference/+server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,16 @@ const verifyAndNormalizeConferenceData = (confData: ConferenceType) => {

Conference.safeParse(confData);

const now = formatDateYYYYMMDD(new Date());
const now = formatDateYYYYMMDD(new Date()) as string;
if (confData.startDate < now || confData.endDate < now) {
throw Error("Start or end date can't be in the past");
}
if (confData.endDate < confData.startDate) {
throw Error("End date can't be before start date");
}
if (confData.endDate < confData.startDate) {
throw Error("Start date can't be after End date");
}
if (!!confData.callForPapersDate && confData.endDate < confData.callForPapersDate) {
throw Error("Call-for-papers date can't be after End date");
}
};

const verifyConferenceIsNew = async (title: string, startDate: string) => {
Expand Down
42 changes: 9 additions & 33 deletions studio/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions studio/schemas/conference.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ export default {
of: [{ type: 'performance' }],
description: `Miles contribution to the event`
},
{
name: 'callForPapersDate',
type: 'date',
title: 'Call for papers',
description: 'Call-for-papers deadline'
},
{
title: 'Deadlines',
name: 'deadlines',
Expand Down

0 comments on commit 71fe0f3

Please sign in to comment.