Skip to content

Commit

Permalink
fix: updated to v1 api
Browse files Browse the repository at this point in the history
  • Loading branch information
fluid-design-io committed Oct 30, 2023
1 parent 269bcb8 commit a853fde
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions apps/web/lib/code-gen/generate-figma-url-token.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import { BaseColors } from "@/types/app";
import { colorHelper } from "../colorHelper";

async function generateFigmaUrlToken(baseColors: Omit<BaseColors, "gray">) {
const url = await fetch("/api/figma-plugin", {
const { data, error } = await fetch("/api/v1/figma-plugin", {
body: JSON.stringify({
baseColors,
}),
method: "POST",
body: JSON.stringify({ baseColors }),
}).then((res) => res.text());
return url;
}).then((res) => res.json());
const hexColors = Object.values(baseColors).map((color) =>
colorHelper.toHex(color),
);
return `${process.env.NEXT_PUBLIC_URL}/?token=${
data.token
}&colors=${encodeURIComponent(hexColors.join(","))}`;
}

export default generateFigmaUrlToken;

0 comments on commit a853fde

Please sign in to comment.