Skip to content

Commit

Permalink
allow ProjectData to have null serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
psparacino committed Dec 1, 2023
1 parent 5ba26a2 commit 17418c7
Showing 1 changed file with 10 additions and 17 deletions.
27 changes: 10 additions & 17 deletions carbonmark/lib/createUrls.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,12 @@
import { DetailedProject, TokenPrice } from "lib/types/carbonmark.types";
import { Project, TokenPrice } from "lib/types/carbonmark.types";

// type ProjectData = {
// key: Project["key"];
// vintage: Project["vintage"];
// serialization?: Project["serialization"];
// };

// // @todo clean up this workaround
// export const toProjectData = (project: DetailedProject): ProjectData => ({
// key: project.key,
// vintage: project.vintage,
// serialization: project.serialization ?? undefined, // Convert null to undefined
// });
type ProjectData = {
key: Project["key"];
vintage: Project["vintage"];
serialization?: Project["serialization"] | null;
};

export const createProjectLink = (projectData: DetailedProject) => {
export const createProjectLink = (projectData: ProjectData) => {
if (projectData.key.startsWith("ICR") && projectData.serialization) {
return `/projects/${projectData.serialization}`;
} else {
Expand All @@ -22,18 +15,18 @@ export const createProjectLink = (projectData: DetailedProject) => {
};

export const createProjectPurchaseLink = (
project: DetailedProject,
project: ProjectData,
listingId: string
) => `${createProjectLink(project)}/purchase/${listingId}`;

export const createProjectPoolRetireLink = (
project: DetailedProject,
project: ProjectData,
pool: TokenPrice["poolName"]
) => `${createProjectLink(project)}/retire/pools/${pool.toLowerCase()}`;

export const createSellerLink = (handle: string) => `/users/${handle}`;

export const createProjectPoolPurchaseLink = (
project: DetailedProject,
project: ProjectData,
pool: TokenPrice["poolName"]
) => `${createProjectLink(project)}/purchase/pools/${pool}`;

0 comments on commit 17418c7

Please sign in to comment.