Skip to content

Commit

Permalink
Additional fields for DCI
Browse files Browse the repository at this point in the history
  • Loading branch information
0xAurelius committed Jan 13, 2025
1 parent 351e3f5 commit 0015a19
Show file tree
Hide file tree
Showing 8 changed files with 227 additions and 14 deletions.
1 change: 1 addition & 0 deletions carbon-projects/lib/sectors.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
[{ title: "Waste handling and disposal", value: "waste-h-d" }];
47 changes: 47 additions & 0 deletions carbon-projects/schemas/assessor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import { defineType } from "sanity";

export default defineType({
name: "assessor",
title: "Assessor",
description: "Information about an organization that assesses projects",
description:
"A profile containing information about an entity including name, avatar, and link",
type: "document",
preview: {
select: {
name: "name",
},
prepare(selection) {
return {
title: selection.name || "",
};
},
},
fields: [
{
type: "string",
title: "Name",
name: "name",
validation: (r) => r.required(),
},
{
type: "string",
title: "Link",
name: "link",
},
{
type: "image",
title: "Avatar",
name: "avatar",
},
{
type: "array",
title: "Accreditations",
name: "accreditations",
of: [
{ type: "string", name: "name" },
{ type: "string", name: "link" },
],
},
],
});
44 changes: 44 additions & 0 deletions carbon-projects/schemas/developer.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { defineType } from "sanity";

export default defineType({
name: "developer",
title: "Developer",
description: "Information about an organization that develops projects",
description:
"A profile containing information about an entity including name, avatar, and link",
type: "document",
preview: {
select: {
name: "name",
},
prepare(selection) {
return {
title: selection.name || "",
};
},
},
fields: [
{
type: "string",
title: "Name",
name: "name",
validation: (r) => r.required(),
},
{
type: "string",
title: "Link",
name: "link",
},
{
type: "image",
title: "Avatar",
name: "avatar",
},
{
type: "array",
title: "Carbonmark Handles",
name: "handles",
of: [{ type: "string" }],
},
],
});
6 changes: 6 additions & 0 deletions carbon-projects/schemas/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
import assessor from "./assessor";
import country from "./country";
import developer from "./developer";
import indexContent from "./indexContent";
import methodology from "./methodology";
import captionImage from "./objects/captionImage";
import externalFile from "./objects/externalFile";
import hostedFile from "./objects/hostedFile";
import project from "./project";
import projectContent from "./projectContent";
import standard from "./standard";
export const schemaTypes = [
project,
methodology,
Expand All @@ -15,4 +18,7 @@ export const schemaTypes = [
captionImage,
country,
indexContent,
assessor,
developer,
standard,
];
9 changes: 8 additions & 1 deletion carbon-projects/schemas/methodology.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { defineField, defineType } from "sanity";
import { categories } from "../lib/categories";
import { sectors } from "../lib/sectors";

export default defineType({
name: "methodology",
title: "Methodology",
description: "Methodology definition",
type: "document",
groups: [{ name: "location" }],
preview: {
select: {
slug: "id",
Expand Down Expand Up @@ -43,6 +43,13 @@ export default defineType({
},
validation: (r) => r.required(),
}),
defineField({
name: "sector",
type: "string",
options: {
list: sectors,
},
}),
defineField({
name: "link",
type: "string",
Expand Down
9 changes: 5 additions & 4 deletions carbon-projects/schemas/objects/hostedFile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ export default defineType({
name: "hostedFile",
type: "file",
title: "Hosted file",
description: "A file whose content is hosted directly in the Sanity CMS, with associated metadata",
description:
"A file whose content is hosted directly in the Sanity CMS, with associated metadata",
fields: [
{
type: "string",
Expand All @@ -24,12 +25,12 @@ export default defineType({
{
type: "string",
title: "File category",
name: "category"
name: "category",
},
{
type: "number",
title: "File size",
name: "size"
}
name: "size",
},
],
});
89 changes: 80 additions & 9 deletions carbon-projects/schemas/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ const ccbs = [
{ title: "CCB Community Gold", value: "CCB-Community Gold" },
];

const registries = [
{ title: "Verra", value: "VCS" },
{ title: "Gold Standard", value: "GS" },
{ title: "EcoRegistry", value: "ECO" },
{ title: "International Carbon Registry", value: "ICR" },
{ title: "Puro", value: "PUR" },
{ title: "J-Credit", value: "JCS" },
{ title: "Carbonmark Direct Issuance", value: "CMARK" },
];

const subcategories = [
{ title: "Solar Energy", value: "solar" },
{ title: "Wind Energy", value: "wind" },
Expand All @@ -21,6 +31,20 @@ const subcategories = [
{ title: "Mangrove Restoration", value: "mangroves" },
];

const statuses = [
{ title: "Registered", value: "registered" },
{ title: "Validated", value: "validated" },
{ title: "Verified", value: "verified" },
{ title: "Withdrawn", value: "withdrawn" }
];

const types = [
{ title: "Avoidance", value: "avoidance" },
{ title: "Reduction", value: "reduction" },
{ title: "Removal", value: "removal" },
{ title: "Hybrid", value: "hybrid" },
];

export default defineType({
name: "project",
title: "Project",
Expand Down Expand Up @@ -71,14 +95,7 @@ export default defineType({
placeholder: "VCS",
type: "string",
options: {
list: [
{ title: "Verra", value: "VCS" },
{ title: "Gold Standard", value: "GS" },
{ title: "EcoRegistry", value: "ECO" },
{ title: "International Carbon Registry", value: "ICR" },
{ title: "Puro", value: "PUR" },
{ title: "J-Credit", value: "JCS" },
],
list: registries,
},
validation: (r) => r.required(),
},
Expand Down Expand Up @@ -117,6 +134,52 @@ export default defineType({
return true;
}),
}),
defineField({
type: "reference",
name: "developer",
to: [{ type: "developer" }],
description: "The developer of this project",
group: "info",
}),
defineField({
type: "reference",
name: "assessor",
to: [{ type: "assessor" }],
description: "The assessor of this project",
group: "info",
}),
defineField({
type: "array",
name: "standards",
of: [
{
type: "reference",
to: [{ type: "standard" }],
},
],
description: "Standards with which the project conforms",
group: "info",
}),
{
name: "status",
description:
"Project status. Indicates where a project is in its lifecycle from registration to verification and issuance",
group: "info",
type: "string",
options: {
list: statuses,
},
},
{
name: "type",
description:
"Project type. Indicates whether a project avoids or removes emissions, or both.",
group: "info",
type: "string",
options: {
list: types,
},
},
defineField({
type: "array",
name: "methodologies",
Expand Down Expand Up @@ -146,11 +209,18 @@ export default defineType({
defineField({
name: "subcategory",
description: "From our predefined ontology of subcategories",
group: "info",
type: "string",
options: {
list: subcategories,
},
}),
defineField({
name: "estAnnualMitigations",
description: "Estimated tonnes of carbon emissions mitigated per annum",
group: "info",
type: "number",
}),
{
name: "region",
description: "Region where the project was implemented",
Expand Down Expand Up @@ -252,7 +322,8 @@ export default defineType({
}),
defineField({
name: "hostedDocuments",
description: "PDF documents hosted in this CMS associated with this project",
description:
"PDF documents hosted in this CMS associated with this project",
group: "media",
type: "array",
of: [{ type: "hostedFile" }],
Expand Down
36 changes: 36 additions & 0 deletions carbon-projects/schemas/standard.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { defineType } from "sanity";

export default defineType({
name: "standard",
title: "Standard",
description: "Information about a standard that applies to projects",
type: "document",
preview: {
select: {
name: "name",
},
prepare(selection) {
return {
title: selection.name || "",
};
},
},
fields: [
{
type: "string",
title: "Name",
name: "name",
validation: (r) => r.required(),
},
{
type: "string",
title: "Link",
name: "link",
},
{
type: "image",
title: "Logo",
name: "logo",
},
],
});

0 comments on commit 0015a19

Please sign in to comment.