create-nextblock 0.12.11 → 0.12.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/templates/nextblock-template/app/checkout/success/actions.ts +3 -0
- package/templates/nextblock-template/app/checkout/success/page.tsx +5 -0
- package/templates/nextblock-template/app/cms/media/components/MediaPickerDialog.tsx +0 -9
- package/templates/nextblock-template/app/cms/products/[id]/edit/page.tsx +12 -0
- package/templates/nextblock-template/app/profile/orders/[id]/CustomerOrderDetailPageClient.tsx +5 -0
- package/templates/nextblock-template/app/profile/orders/[id]/page.tsx +1 -0
- package/templates/nextblock-template/package.json +1 -1
- package/templates/nextblock-template/tsconfig.tsbuildinfo +1 -0
package/package.json
CHANGED
|
@@ -4,6 +4,7 @@ import { createClient as createSupabaseClient } from '@supabase/supabase-js';
|
|
|
4
4
|
import {
|
|
5
5
|
applyOrderInventoryDeduction,
|
|
6
6
|
assignInvoiceMetadata,
|
|
7
|
+
getFreemiusOrderLicense,
|
|
7
8
|
getInvoicePresentationData,
|
|
8
9
|
getStripeClient,
|
|
9
10
|
syncStripeOrderFromSession,
|
|
@@ -107,6 +108,7 @@ export async function fulfillOrderAction(sessionId: string) {
|
|
|
107
108
|
alreadyPaid: true,
|
|
108
109
|
status: 'paid',
|
|
109
110
|
invoice: await getInvoicePresentationData(order.id, supabase as any),
|
|
111
|
+
license: await getFreemiusOrderLicense({ orderId: order.id, client: supabase as any }),
|
|
110
112
|
};
|
|
111
113
|
}
|
|
112
114
|
|
|
@@ -116,6 +118,7 @@ export async function fulfillOrderAction(sessionId: string) {
|
|
|
116
118
|
alreadyPaid: false,
|
|
117
119
|
status: 'trial',
|
|
118
120
|
invoice: await getInvoicePresentationData(order.id, supabase as any),
|
|
121
|
+
license: await getFreemiusOrderLicense({ orderId: order.id, client: supabase as any }),
|
|
119
122
|
};
|
|
120
123
|
}
|
|
121
124
|
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
FreemiusLicensePanel,
|
|
5
|
+
type FreemiusOrderLicense,
|
|
4
6
|
InvoiceViewerShell,
|
|
5
7
|
type InvoicePresentationData,
|
|
6
8
|
buildInvoiceDocumentLabels,
|
|
@@ -29,6 +31,7 @@ export default function CheckoutSuccessPage() {
|
|
|
29
31
|
const searchParams = useSearchParams();
|
|
30
32
|
const sessionId = searchParams.get('session_id');
|
|
31
33
|
const [invoice, setInvoice] = useState<InvoicePresentationData | null>(null);
|
|
34
|
+
const [license, setLicense] = useState<FreemiusOrderLicense | null>(null);
|
|
32
35
|
const [syncError, setSyncError] = useState<string | null>(null);
|
|
33
36
|
const [isSyncing, setIsSyncing] = useState(false);
|
|
34
37
|
const [hasRemainingCheckoutItems, setHasRemainingCheckoutItems] = useState(false);
|
|
@@ -92,6 +95,7 @@ export default function CheckoutSuccessPage() {
|
|
|
92
95
|
if (result.invoice) {
|
|
93
96
|
const resolvedInvoice = result.invoice as InvoicePresentationData;
|
|
94
97
|
setOrderStatus((result as any).status || resolvedInvoice.order.status || null);
|
|
98
|
+
setLicense(((result as any).license as FreemiusOrderLicense | null) ?? null);
|
|
95
99
|
const purchasedKeys = new Set(
|
|
96
100
|
resolvedInvoice.order.items.map((item) =>
|
|
97
101
|
buildPurchasedItemKey(item.product_id, item.variant_id)
|
|
@@ -169,6 +173,7 @@ export default function CheckoutSuccessPage() {
|
|
|
169
173
|
</div>
|
|
170
174
|
}
|
|
171
175
|
action={action}
|
|
176
|
+
beforeInvoice={<FreemiusLicensePanel license={license} />}
|
|
172
177
|
loading={isSyncing}
|
|
173
178
|
loadingMessage={translateOrFallback(
|
|
174
179
|
t,
|
|
@@ -8,8 +8,6 @@ import {
|
|
|
8
8
|
DialogHeader,
|
|
9
9
|
DialogTitle,
|
|
10
10
|
DialogTrigger,
|
|
11
|
-
DialogFooter,
|
|
12
|
-
DialogClose,
|
|
13
11
|
Button,
|
|
14
12
|
Input,
|
|
15
13
|
Separator,
|
|
@@ -246,13 +244,6 @@ export default function MediaPickerDialog({
|
|
|
246
244
|
</div>
|
|
247
245
|
)}
|
|
248
246
|
</div>
|
|
249
|
-
<DialogFooter className="mt-auto pt-4">
|
|
250
|
-
<DialogClose asChild>
|
|
251
|
-
<Button type="button" variant="outline">
|
|
252
|
-
Close
|
|
253
|
-
</Button>
|
|
254
|
-
</DialogClose>
|
|
255
|
-
</DialogFooter>
|
|
256
247
|
</DialogContent>
|
|
257
248
|
</Dialog>
|
|
258
249
|
);
|
|
@@ -157,9 +157,21 @@ export default async function EditProductPage({
|
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
159
|
|
|
160
|
+
// Product drafts persist prices in major units (dollars, the ProductForm
|
|
161
|
+
// value shape), but ProductForm re-divides the top-level price/sale_price by
|
|
162
|
+
// 100 because it expects a raw product row (minor units/cents). Convert the
|
|
163
|
+
// draft's dollars back to cents so the form shows the saved amount instead of
|
|
164
|
+
// 1/100th of it (e.g. an imported $29.50 draft otherwise renders as $0.30).
|
|
165
|
+
// The prices maps and variant prices are already in the dollar shape the form
|
|
166
|
+
// consumes directly, so only these two scalars need converting.
|
|
167
|
+
const draftDollarsToStoredCents = (value: unknown) =>
|
|
168
|
+
typeof value === 'number' && Number.isFinite(value) ? Math.round(value * 100) : value;
|
|
169
|
+
|
|
160
170
|
normalizedInitialData = {
|
|
161
171
|
...meta,
|
|
162
172
|
id: product.id,
|
|
173
|
+
price: draftDollarsToStoredCents(meta.price),
|
|
174
|
+
sale_price: draftDollarsToStoredCents(meta.sale_price),
|
|
163
175
|
product_media: hydratedProductMedia,
|
|
164
176
|
category_ids: meta.category_ids ?? assignedCategories.map((c: any) => c.id),
|
|
165
177
|
};
|
package/templates/nextblock-template/app/profile/orders/[id]/CustomerOrderDetailPageClient.tsx
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
|
+
FreemiusLicensePanel,
|
|
5
|
+
type FreemiusOrderLicense,
|
|
4
6
|
InvoiceViewerShell,
|
|
5
7
|
type InvoicePresentationData,
|
|
6
8
|
buildInvoiceDocumentLabels,
|
|
@@ -19,6 +21,7 @@ interface CustomerOrderDetailPageClientProps {
|
|
|
19
21
|
invoice_number: string | null;
|
|
20
22
|
};
|
|
21
23
|
invoice: InvoicePresentationData | null;
|
|
24
|
+
license: FreemiusOrderLicense | null;
|
|
22
25
|
profile: ProfileAccountSummary;
|
|
23
26
|
user: ProfileAccountUser;
|
|
24
27
|
}
|
|
@@ -26,6 +29,7 @@ interface CustomerOrderDetailPageClientProps {
|
|
|
26
29
|
export function CustomerOrderDetailPageClient({
|
|
27
30
|
order,
|
|
28
31
|
invoice,
|
|
32
|
+
license,
|
|
29
33
|
profile,
|
|
30
34
|
user,
|
|
31
35
|
}: CustomerOrderDetailPageClientProps) {
|
|
@@ -57,6 +61,7 @@ export function CustomerOrderDetailPageClient({
|
|
|
57
61
|
'print_invoice',
|
|
58
62
|
'Print / Save as PDF'
|
|
59
63
|
)}
|
|
64
|
+
beforeInvoice={<FreemiusLicensePanel license={license} />}
|
|
60
65
|
action={{
|
|
61
66
|
href: '/profile/orders',
|
|
62
67
|
label: translateOrFallback(
|