From ce1971a64bd02e46990ac728065749e9de477271 Mon Sep 17 00:00:00 2001 From: Florent Lagrede Date: Tue, 28 Feb 2023 10:47:03 +0100 Subject: [PATCH] feat: add BuyModal and BuyModalOptions documents (#27) * feat: add BuyModal and BuyModalOptions documents * fix: comment create action --- deskStructure.js | 8 +++++ schemas/documents/registry/buyModal.js | 15 ++++++++ schemas/documents/registry/buyModalOptions.js | 27 ++++++++++++++ schemas/objects/cards/actionCard.js | 36 +++++++++++++++++++ schemas/objects/{ => cards}/card.js | 0 schemas/objects/cards/infoCard.js | 25 +++++++++++++ schemas/schema.js | 10 +++++- 7 files changed, 120 insertions(+), 1 deletion(-) create mode 100644 schemas/documents/registry/buyModal.js create mode 100644 schemas/documents/registry/buyModalOptions.js create mode 100644 schemas/objects/cards/actionCard.js rename schemas/objects/{ => cards}/card.js (100%) create mode 100644 schemas/objects/cards/infoCard.js diff --git a/deskStructure.js b/deskStructure.js index 85a952c..23809d5 100644 --- a/deskStructure.js +++ b/deskStructure.js @@ -72,6 +72,14 @@ export default () => { .title('Basket Details Page') .schemaType('basketDetailsPage') .child(S.document().schemaType('basketDetailsPage')), + S.listItem() + .title('Buy Modal Options') + .schemaType('buyModalOptions') + .child(S.document().schemaType('buyModalOptions')), + S.listItem() + .title('Buy Modal') + .schemaType('buyModal') + .child(S.document().schemaType('buyModal')), ]), ), diff --git a/schemas/documents/registry/buyModal.js b/schemas/documents/registry/buyModal.js new file mode 100644 index 0000000..4353590 --- /dev/null +++ b/schemas/documents/registry/buyModal.js @@ -0,0 +1,15 @@ +export default { + type: 'document', + name: 'buyModal', + title: 'Buy Modal', + __experimental_actions: ['update', /* 'create', 'delete', */ 'publish'], + fields: [ + { + title: 'Info card', + name: 'infoCard', + type: 'infoCard', + description: 'Create the card to be displayed at the top of the buy modal', + validation: Rule => Rule.required(), + }, + ], +}; diff --git a/schemas/documents/registry/buyModalOptions.js b/schemas/documents/registry/buyModalOptions.js new file mode 100644 index 0000000..d589a90 --- /dev/null +++ b/schemas/documents/registry/buyModalOptions.js @@ -0,0 +1,27 @@ +export default { + type: 'document', + name: 'buyModalOptions', + title: 'Buy Modal Options', + __experimental_actions: ['update', /* 'create', 'delete', */ 'publish'], + fields: [ + { + title: 'Title', + name: 'title', + type: 'string', + validation: Rule => Rule.required(), + }, + { + title: 'Buy Options Cards', + name: 'cards', + type: 'array', + description: + 'Create one or several cards (min 1), to be displayed when clicking a buy button for a non-connected user', + of: [ + { + type: 'actionCard', + }, + ], + validation: Rule => Rule.required().min(1), + }, + ], +}; diff --git a/schemas/objects/cards/actionCard.js b/schemas/objects/cards/actionCard.js new file mode 100644 index 0000000..5416629 --- /dev/null +++ b/schemas/objects/cards/actionCard.js @@ -0,0 +1,36 @@ +export default { + name: 'actionCard', + type: 'object', + title: 'ActionCard', + fields: [ + { + title: 'Title', + name: 'title', + type: 'string', + validation: Rule => Rule.required(), + }, + { + title: 'Description', + name: 'description', + type: 'customPortableText', + validation: Rule => Rule.required(), + }, + { + title: 'Button', + name: 'button', + type: 'button', + validation: Rule => Rule.required(), + }, + { + title: 'Note', + name: 'note', + type: 'customPortableText', + }, + { + title: 'Image', + name: 'image', + type: 'customImage', + validation: Rule => Rule.required(), + }, + ], +}; diff --git a/schemas/objects/card.js b/schemas/objects/cards/card.js similarity index 100% rename from schemas/objects/card.js rename to schemas/objects/cards/card.js diff --git a/schemas/objects/cards/infoCard.js b/schemas/objects/cards/infoCard.js new file mode 100644 index 0000000..e744a60 --- /dev/null +++ b/schemas/objects/cards/infoCard.js @@ -0,0 +1,25 @@ +export default { + name: 'infoCard', + type: 'object', + title: 'InfoCard', + fields: [ + { + title: 'Title', + name: 'title', + type: 'string', + validation: Rule => Rule.required(), + }, + { + title: 'Description', + name: 'description', + type: 'customPortableText', + validation: Rule => Rule.required(), + }, + { + title: 'Image', + name: 'image', + type: 'customImage', + validation: Rule => Rule.required(), + }, + ], +}; diff --git a/schemas/schema.js b/schemas/schema.js index 9b79e4e..8c6dcc0 100644 --- a/schemas/schema.js +++ b/schemas/schema.js @@ -20,6 +20,8 @@ import projectsPage from './documents/registry/projectsPage'; import projectPage from './documents/registry/projectPage'; import bridgePage from './documents/registry/bridgePage'; import basketDetailsPage from './documents/registry/basketDetailsPage'; +import buyModal from './documents/registry/buyModal'; +import buyModalOptions from './documents/registry/buyModalOptions'; import resource from './documents/shared/resource'; import faq from './documents/shared/faq'; @@ -59,7 +61,7 @@ import imageGridSection from './objects/sections/imageGridSection'; import stepCard from './objects/stepCard'; import bottomBanner from './objects/bottomBanner'; -import card from './objects/card'; +import card from './objects/cards/card'; import pageMetadata from './objects/pageMetadata'; import customPortableText from './objects/customPortableText'; import button from './objects/button'; @@ -176,6 +178,8 @@ import creditInfos from './objects/creditInfos'; import buyersEcologicalCreditCardsSection from './objects/sections/buyersPage/ecologicalCreditCardsSection'; import buyersFeaturedProjectCardsSection from './objects/sections/buyersPage/featuredProjectCardsSection'; import buyersPartnersSection from './objects/sections/buyersPage/partnersSection'; +import actionCard from './objects/cards/actionCard'; +import infoCard from './objects/cards/infoCard'; // Then we give our schema to the builder and provide the result to Sanity export default createSchema({ @@ -184,6 +188,7 @@ export default createSchema({ // Then proceed to concatenate our document type // to the ones provided by any plugins that are installed types: schemaTypes.concat([ + actionCard, basicStepCardSection, basketDetailsPage, blogPost, @@ -192,6 +197,8 @@ export default createSchema({ bottomBanner, bridgePage, button, + buyModal, + buyModalOptions, buyer, buyersPage, buyersEcologicalCreditCardsSection, @@ -269,6 +276,7 @@ export default createSchema({ imageItemsSection, imageLink, imageWithTitle, + infoCard, labeledTextLinkable, landManagementPractice, landSteward,