Skip to content

Commit

Permalink
fix price
Browse files Browse the repository at this point in the history
  • Loading branch information
emilwidlund committed Nov 1, 2024
1 parent 3118804 commit fb22cb0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "polar-init",
"version": "0.2.0",
"version": "0.2.1",
"license": "Apache-2.0",
"bin": "bin/cli.js",
"type": "module",
Expand Down
30 changes: 23 additions & 7 deletions src/prompts/product.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@ export const productPrompt = async () => {

const priceTypeResponse = await prompts({
type: "select",
name: "priceType",
name: "type",
message: "Product Type",
choices: [
{ title: "One-Time Purchase", value: "one-time" },
{ title: "One-Time Purchase", value: "one_time" },
{ title: "Subscription", value: "recurring" },
],
});

if (priceTypeResponse.priceType === "one-time") {
if (priceTypeResponse.type === "one_time") {
const priceResponse = await prompts([
{
type: "select",
name: "priceAmountType",
name: "amountType",
message: "Price Type",
choices: [
{ title: "Free", value: "free" },
Expand All @@ -46,7 +46,15 @@ export const productPrompt = async () => {

return {
...productResponse,
prices: [priceResponse],
prices: [
{
...priceResponse,
...priceTypeResponse,
...(typeof priceResponse.priceAmount === "number"
? { priceAmount: priceResponse.priceAmount * 100 }
: {}),
},
],
};
}

Expand All @@ -62,7 +70,7 @@ export const productPrompt = async () => {
},
{
type: "select",
name: "priceAmountType",
name: "amountType",
message: "Price Type",
choices: [
{ title: "Free", value: "free" },
Expand All @@ -79,6 +87,14 @@ export const productPrompt = async () => {

return {
...productResponse,
prices: [priceResponse],
prices: [
{
...priceResponse,
...priceTypeResponse,
...(typeof priceResponse.priceAmount === "number"
? { priceAmount: priceResponse.priceAmount * 100 }
: {}),
},
],
};
};

0 comments on commit fb22cb0

Please sign in to comment.