Skip to content

Commit

Permalink
feat(studio): add honoraryMember
Browse files Browse the repository at this point in the history
closes #96
  • Loading branch information
mheob committed Sep 19, 2024
1 parent 2dd4f22 commit a8888e0
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 1 deletion.
42 changes: 42 additions & 0 deletions apps/studio/schemas/documents/honorary-member.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { RiUserSmileLine } from 'react-icons/ri';
import { defineField, defineType } from 'sanity';

import { additionalInformation, contact, personal } from '@/shared/field-groups';
import { firstNameField, lastNameField, portraitPictureField } from '@/shared/fields/personal';
import { maxLengthRule } from '@/shared/validation-rules';

const honoraryMember = defineType({
title: 'Ehrenmitglieder',
name: 'honoraryMember',
type: 'document',
icon: RiUserSmileLine,
groups: [personal, contact, additionalInformation],
fields: [
// personal
firstNameField,
lastNameField,
portraitPictureField,

defineField({
title: 'Mitglied seit',
name: 'memberSince',
type: 'string',
group: 'personal',
validation: rule => [
// minLengthRule(rule, 2, 'Der Nachname'),
maxLengthRule(rule, 10, 'Mitglied seit'),
],
}),
],

preview: {
prepare: ({ media, firstName, lastName }) => ({ media, title: `${lastName}, ${firstName}` }),
select: {
media: 'image.asset',
firstName: 'firstName',
lastName: 'lastName',
},
},
});

export default honoraryMember;
2 changes: 2 additions & 0 deletions apps/studio/schemas/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import author from './documents/author';
import group from './documents/group';
import honoraryMember from './documents/honorary-member';
import newsArticle from './documents/news.article';
import newsCategory from './documents/news.category';
import person from './documents/person';
Expand Down Expand Up @@ -41,6 +42,7 @@ export const schemaTypes = [

author,
person,
honoraryMember,
role,

group,
Expand Down
7 changes: 6 additions & 1 deletion apps/studio/structure/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export function isExcludedDefaultListItem(id?: string) {
return ![
'assist.instruction.context',
'author',
'honoraryMember',
'media.tag',
'news.article',
'news.category',
Expand Down Expand Up @@ -66,7 +67,11 @@ function getGroupPersons(S: StructureBuilder): ListItemBuilder[] {
.child(
S.list()
.title('Personen')
.items([S.documentTypeListItem('author'), S.documentTypeListItem('person')]),
.items([
S.documentTypeListItem('author'),
S.documentTypeListItem('honoraryMember'),
S.documentTypeListItem('person'),
]),
),
];
}
Expand Down

0 comments on commit a8888e0

Please sign in to comment.