Skip to content

Commit

Permalink
fix org selector
Browse files Browse the repository at this point in the history
  • Loading branch information
emilwidlund committed Nov 1, 2024
1 parent 1e4efe7 commit 388f042
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/cli.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,5 @@ const cli = meow(
);
}

successMessage(organization, createdProduct);
successMessage(organization, createdProduct, framework);
})();
6 changes: 3 additions & 3 deletions src/prompts/organization.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@ export const selectOrganizationPrompt = async (
organizations: Organization[],
matchingOrg?: Organization,
): Promise<Organization | undefined> => {
const { organization: organizationIndex } = await prompts({
const { organization: orgSlug } = await prompts({
type: "select",
name: "organization",
message: "Select an organization",
choices: [
...organizations.map((org) => ({
title: org.name,
value: org,
value: org.slug,
})),
{
title: "+ Create new organization",
Expand All @@ -35,5 +35,5 @@ export const selectOrganizationPrompt = async (
initial: matchingOrg ? organizations.indexOf(matchingOrg) : 0,
});

return organizations[organizationIndex];
return organizations.find((org) => org.slug === orgSlug);
};
5 changes: 2 additions & 3 deletions src/prompts/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export const productPrompt = async () => {
message: "Price Type",
choices: [
{ title: "Free", value: "free" },
{ title: "Fixed", value: "fixed" },
{ title: "Custom", value: "custom" },
{ title: "Fixed Price", value: "fixed" },
],
},
{
Expand Down Expand Up @@ -67,7 +66,7 @@ export const productPrompt = async () => {
message: "Price Type",
choices: [
{ title: "Free", value: "free" },
{ title: "Fixed", value: "fixed" },
{ title: "Fixed Price", value: "fixed" },
],
},
{
Expand Down
16 changes: 10 additions & 6 deletions src/ui/success.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import type { Product } from "@polar-sh/sdk/models/components/product.js";
import { Box, Text, render } from "ink";
import Link from "ink-link";
import React from "react";
import type { Framework } from "../template.js";

export const successMessage = (
organization: Organization,
product: Product,
framework: Framework,
) => {
render(
<Box flexDirection="column" columnGap={2}>
Expand Down Expand Up @@ -42,12 +44,14 @@ export const successMessage = (
Configure Webhooks
</Link>
</Text>
<Text color="cyanBright">
{">"}{" "}
<Link url="https://docs.polar.sh/guides/nextjs">
Continue to the Polar Next.js Guide
</Link>
</Text>
{framework === "next" && (
<Text color="cyanBright">
{">"}{" "}
<Link url="https://docs.polar.sh/guides/nextjs">
Continue to the Polar Next.js Guide
</Link>
</Text>
)}
</Box>
</Box>,
);
Expand Down

0 comments on commit 388f042

Please sign in to comment.