Skip to content

Commit

Permalink
feat: Update schema
Browse files Browse the repository at this point in the history
  • Loading branch information
acasazza committed Feb 15, 2021
1 parent 1eac239 commit 7c7210e
Show file tree
Hide file tree
Showing 8 changed files with 49 additions and 71 deletions.
2 changes: 0 additions & 2 deletions studio/schemas/catalog.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,12 @@ export default {
icon: GoFileSubmodule,
fields: [
{
id: 'name',
name: 'name',
title: 'Name',
type: 'string',
validation: (rule) => rule.required(),
},
{
id: 'taxonomies',
name: 'taxonomies',
title: 'Taxonomies',
type: 'array',
Expand Down
13 changes: 3 additions & 10 deletions studio/schemas/country.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,21 +8,18 @@ export default {
icon: MdFlag,
fields: [
{
id: 'name',
name: 'name',
title: 'Name',
type: 'string',
validation: (rule) => rule.required(),
},
{
id: 'code',
name: 'code',
title: 'Code',
type: 'string',
validation: (rule) => rule.required().min(2).max(4),
},
{
id: 'catalog',
name: 'catalog',
title: 'Catalog',
type: 'array',
Expand All @@ -37,26 +34,22 @@ export default {
validation: (rule) => rule.required(),
},
{
id: 'marketId',
name: 'marketId',
title: 'MarketId',
title: 'Market Id',
type: 'string',
},
{
id: 'image',
name: 'image',
title: 'Image',
type: 'image',
validation: (rule) => rule.required(),
},
{
id: 'defaultLocale',
name: 'defaultLocale',
title: 'DefaultLocale',
type: 'string',
},
{
id: 'domain',
name: 'domain',
title: 'Domain',
type: 'string',
Expand All @@ -65,8 +58,8 @@ export default {

preview: {
select: {
title: 'Name',
media: 'Image',
title: 'name',
media: 'image',
},
},
}
6 changes: 3 additions & 3 deletions studio/schemas/product.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ export default {

preview: {
select: {
title: 'Name',
subtitle: 'Slug.current',
media: 'Images.0.Images',
title: 'name',
subtitle: 'slug.current',
media: 'images.0.images',
},
prepare({ title, subtitle, media }) {
return {
Expand Down
3 changes: 0 additions & 3 deletions studio/schemas/productImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@ export default {
icon: BsFillImageFill,
fields: [
{
id: 'name',
name: 'name',
title: 'Name',
type: 'string',
validation: (rule) => rule.required(),
},
{
id: 'description',
name: 'description',
title: 'Description',
type: 'text',
},
{
id: 'images',
name: 'images',
title: 'Images',
type: 'image',
Expand Down
32 changes: 16 additions & 16 deletions studio/schemas/schema.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
import createSchema from "part:@sanity/base/schema-creator";
import schemaTypes from "all:part:@sanity/base/schema-type";
import createSchema from 'part:@sanity/base/schema-creator'
import schemaTypes from 'all:part:@sanity/base/schema-type'

// We import object and document schemas
import product from "./product";
import country from "./country";
import variant from "./variant";
import size from "./size";
import taxon from "./taxon";
import taxonomy from "./taxonomy";
import catalog from "./catalog";
import blockContent from "./blockContent";
import product from './product'
import country from './country'
import variant from './variant'
import size from './size'
import taxon from './taxon'
import taxonomy from './taxonomy'
import catalog from './catalog'
import blockContent from './blockContent'

import productImage from "./productImage";
import localeString from "./locale/String";
import localeText from "./locale/Text";
import localeBlockContent from "./locale/BlockContent";
import productImage from './productImage'
import localeString from './locale/String'
import localeText from './locale/Text'
import localeBlockContent from './locale/BlockContent'

// Then we give our schema to the builder and provide the result to Sanity
export default createSchema({
// We name our schema
name: "default",
name: 'default',
// Then proceed to concatenate our document type
// to the ones provided by any plugins that are installed
types: schemaTypes.concat([
Expand All @@ -40,4 +40,4 @@ export default createSchema({
localeBlockContent,
localeString,
]),
});
})
7 changes: 0 additions & 7 deletions studio/schemas/taxon.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@ export default {
icon: BsSquareHalf,
fields: [
{
id: 'name',
name: 'name',
title: 'Name',
type: 'string',
validation: (rule) => rule.required(),
},
{
id: 'label',
name: 'label',
title: 'Label',
type: 'string',
},
{
id: 'slug',
name: 'slug',
title: 'Slug',
type: 'slug',
Expand All @@ -31,13 +28,11 @@ export default {
validation: (rule) => rule.required(),
},
{
id: 'description',
name: 'description',
title: 'Description',
type: 'text',
},
{
id: 'images',
name: 'images',
title: 'Images',
type: 'array',
Expand All @@ -51,7 +46,6 @@ export default {
],
},
{
id: 'products',
name: 'products',
title: 'Products',
type: 'array',
Expand All @@ -65,7 +59,6 @@ export default {
],
},
{
id: 'taxons',
name: 'taxons',
title: 'Taxons',
type: 'array',
Expand Down
3 changes: 0 additions & 3 deletions studio/schemas/taxonomy.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,17 @@ export default {
icon: SiElasticstack,
fields: [
{
id: 'name',
name: 'name',
title: 'Name',
type: 'string',
validation: (rule) => rule.required(),
},
{
id: 'label',
name: 'label',
title: 'Label',
type: 'string',
},
{
id: 'taxons',
name: 'taxons',
title: 'Taxons',
type: 'array',
Expand Down
54 changes: 27 additions & 27 deletions studio/schemas/variant.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,52 @@
import { GrMultiple } from "react-icons/gr";
import { GrMultiple } from 'react-icons/gr'

export default {
name: "variant",
title: "Variant",
description: "",
type: "document",
name: 'variant',
title: 'Variant',
description: '',
type: 'document',
icon: GrMultiple,
fields: [
{
id: "name",
name: "Name",
type: "string",
name: 'name',
title: 'Name',
type: 'string',
validation: (rule) => rule.required(),
},
{
id: "code",
name: "Code",
type: "string",
name: 'code',
title: 'Code',
type: 'string',
validation: (rule) => rule.required(),
},
{
id: "description",
name: "Description",
type: "text",
name: 'description',
title: 'Description',
type: 'text',
},
{
id: "images",
name: "Images",
type: "array",
name: 'images',
title: 'Images',
type: 'array',
of: [
{
type: "reference",
type: 'reference',
to: {
type: "productImage",
type: 'productImage',
},
},
],
validation: (rule) => rule.required(),
},
{
id: "size",
name: "Size",
type: "array",
name: 'size',
title: 'Size',
type: 'array',
of: [
{
type: "reference",
type: 'reference',
to: {
type: "size",
type: 'size',
},
},
],
Expand All @@ -56,8 +56,8 @@ export default {

preview: {
select: {
title: "Name",
media: "Images.0.Images",
title: 'name',
media: 'images.0.images',
},
},
};
}

0 comments on commit 7c7210e

Please sign in to comment.