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

Add a Courses schema #46

Merged
merged 16 commits into from
May 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
131 changes: 131 additions & 0 deletions schemas/course.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
import {defineType, defineField} from 'sanity'

export const course = defineType({
title: "Courses",
name: "course",
type: "document",
fields: [
defineField({
title: "Title",
name: "title",
type: "string",
validation: Rule => Rule.required()
}),
defineField({
title: "Provider",
name: "provider",
type: "array",
of: [{ type: "reference", to: [{ type: "provider" }] }],
validation: Rule => Rule.required()
}),
defineField({
title: "Description",
name: "description",
type: "text",
validation: Rule => Rule.required()
}),
defineField({
title: 'Cost',
name: 'cost',
type: 'string',
validation: Rule => Rule.required(),
initialValue: 'paid',
options: {
list: [
{ title: 'Paid', value: 'paid' },
{ title: 'Free', value: 'free' }
]
}
}),
defineField({
title: 'Format',
name: 'format',
type: 'string',
options: {
list: [
{ title: 'Talk', value: 'talk' },
{ title: 'Workshop', value: 'workshop' },
{ title: 'Tutorial', value: 'tutorial' },
{ title: 'Roundtable', value: 'roundtable' },
{ title: 'Competition', value: 'competition' },
{ title: 'Panel', value: 'panel' },
{ title: 'Interview', value: 'interview' },
{ title: 'Demo', value: 'demo' },
{ title: 'Keynote', value: 'keynote' },
{ title: 'Announcement', value: 'announcement' },
{ title: 'Other', value: 'other' }
]
}
}),
defineField({
title: 'Level',
name: 'level',
type: 'string',
validation: Rule => Rule.required(),
initialValue: 'beginner',
options: {
list: [
{ title: 'Beginner', value: 'beginner' },
{ title: 'Intermediate', value: 'intermediate' },
{ title: 'Advanced', value: 'advanced' }
]
}
}),
// Time required hours
defineField({
title: 'Time required',
name: 'timeRequired',
type: 'number',
validation: Rule => Rule.required(),
description: 'The approximate number of hours required to complete this course.'
}),
defineField({
title: "Attendance Mode",
name: "attendanceMode",
type: "string",
validation: Rule => Rule.required(),
initialValue: "online",
options: {
list: [
{ title: 'Online', value: 'online' },
{ title: 'Offline', value: 'offline' },
{ title: 'Mixed', value: 'mixed'},
{ title: 'None', value: 'none'}
],
layout: 'radio'
}
}),
defineField({
title: "Exam",
name: "exam",
type: "boolean",
initialValue: false
}),
defineField({
title: "Credential awarded",
name: "credential",
type: "boolean",
initialValue: false
}),
defineField({
title: "IAAP pre-approved",
description: "Whether or not this course is pre-approved for IAAP CAEC credits.",
name: "iaap",
type: "boolean",
initialValue: false
}),
defineField({
title: "Location",
name: "location",
type: "string",
hidden: ({document}) => document?.attendanceMode === 'online'
}),
defineField({
title: "Website",
name: "website",
type: "url"
})
]
})

export default course;
2 changes: 1 addition & 1 deletion schemas/event.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {defineType, defineField, defineArrayMember} from 'sanity'
import {defineType, defineField} from 'sanity'

export const event = defineType({
title: "Events",
Expand Down
4 changes: 3 additions & 1 deletion schemas/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
// schemas/index.js
import event from './event'
import course from './course'
import provider from './provider'

export const schemaTypes = [event]
export const schemaTypes = [event, course, provider]
22 changes: 22 additions & 0 deletions schemas/provider.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import {defineType, defineField} from 'sanity'

export const provider = defineType({
title: "Provider",
name: "provider",
type: "document",
fields: [
defineField({
title: "Name",
name: "name",
type: "string",
validation: Rule => Rule.required()
}),
defineField({
title: "Website",
name: "website",
type: "url"
})
]
})

export default provider;
Loading