Skip to content

Commit

Permalink
fix pricing
Browse files Browse the repository at this point in the history
  • Loading branch information
emilwidlund committed Nov 2, 2024
1 parent 2bca159 commit 24703c0
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 10 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "checkout-link",
"version": "0.1.2",
"version": "0.1.3",
"license": "Apache-2.0",
"bin": "bin/cli.js",
"type": "module",
Expand Down
1 change: 1 addition & 0 deletions src/cli.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ const [filePath] = cli.input;

(async () => {
const product = await productPrompt();
console.log(product);
const server = await serverPrompt();

await authenticationMessage();
Expand Down
34 changes: 25 additions & 9 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 @@ -56,13 +64,13 @@ export const productPrompt = async () => {
name: "recurringInterval",
message: "Recurring Interval",
choices: [
{ title: "Monthly", value: "monthly" },
{ title: "Yearly", value: "yearly" },
{ title: "Monthly", value: "month" },
{ title: "Yearly", value: "year" },
],
},
{
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 24703c0

Please sign in to comment.