@fayz-ai/plugin-courses 0.9.0 → 0.9.1
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/README.md +3 -3
- package/dist/components/CommerceUI.d.ts +19 -2
- package/dist/components/CommerceUI.d.ts.map +1 -1
- package/dist/components/dashboardWidgets.d.ts.map +1 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +342 -253
- package/dist/index.js.map +1 -1
- package/dist/lib/nav.d.ts.map +1 -0
- package/dist/locales/en.d.ts.map +1 -1
- package/dist/locales/pt-BR.d.ts.map +1 -1
- package/dist/public/createPublicCheckoutPlugin.d.ts +1 -1
- package/dist/public/createPublicCheckoutPlugin.d.ts.map +1 -1
- package/dist/public/{data.d.ts → data/index.d.ts} +1 -1
- package/dist/public/data/index.d.ts.map +1 -0
- package/dist/public/{data.supabase.d.ts → data/supabase.d.ts} +2 -2
- package/dist/public/data/supabase.d.ts.map +1 -0
- package/dist/public/index.d.ts +4 -4
- package/dist/public/index.d.ts.map +1 -1
- package/dist/public/index.js +353 -0
- package/dist/public/index.js.map +1 -0
- package/dist/public/{CheckoutScreen.d.ts → views/CheckoutScreen.d.ts} +1 -1
- package/dist/public/views/CheckoutScreen.d.ts.map +1 -0
- package/dist/views/CourseEditorPage.d.ts.map +1 -0
- package/dist/views/CourseOrderDetailView.d.ts +4 -3
- package/dist/views/CourseOrderDetailView.d.ts.map +1 -1
- package/dist/{pages → views}/CoursesListPage.d.ts.map +1 -1
- package/dist/{pages → views}/FinancialPage.d.ts.map +1 -1
- package/dist/{pages → views}/ReportsPage.d.ts.map +1 -1
- package/dist/views/SalesPage.d.ts +19 -0
- package/dist/views/SalesPage.d.ts.map +1 -0
- package/dist/views/SubscriptionsPage.d.ts +7 -0
- package/dist/views/SubscriptionsPage.d.ts.map +1 -0
- package/package.json +6 -9
- package/dist/dashboardWidgets.d.ts.map +0 -1
- package/dist/nav.d.ts.map +0 -1
- package/dist/pages/CourseEditorPage.d.ts.map +0 -1
- package/dist/pages/SalesPage.d.ts +0 -6
- package/dist/pages/SalesPage.d.ts.map +0 -1
- package/dist/pages/SubscriptionsPage.d.ts +0 -6
- package/dist/pages/SubscriptionsPage.d.ts.map +0 -1
- package/dist/public/CheckoutScreen.d.ts.map +0 -1
- package/dist/public/data.d.ts.map +0 -1
- package/dist/public/data.supabase.d.ts.map +0 -1
- package/src/components/CommerceUI.tsx +0 -153
- package/src/connectors/stripe.ts +0 -34
- package/src/dashboardWidgets.tsx +0 -64
- package/src/index.ts +0 -150
- package/src/lib/format.ts +0 -22
- package/src/locales/en.ts +0 -203
- package/src/locales/index.ts +0 -7
- package/src/locales/pt-BR.ts +0 -203
- package/src/nav.ts +0 -9
- package/src/pages/CourseEditorPage.tsx +0 -1122
- package/src/pages/CoursesListPage.tsx +0 -137
- package/src/pages/FinancialPage.tsx +0 -81
- package/src/pages/ReportsPage.tsx +0 -59
- package/src/pages/SalesPage.tsx +0 -86
- package/src/pages/SubscriptionsPage.tsx +0 -56
- package/src/public/CheckoutScreen.tsx +0 -279
- package/src/public/createPublicCheckoutPlugin.tsx +0 -88
- package/src/public/data.supabase.ts +0 -63
- package/src/public/data.ts +0 -89
- package/src/public/index.ts +0 -26
- package/src/settings/CoursesSettings.tsx +0 -55
- package/src/views/CourseOrderDetailView.tsx +0 -132
- /package/dist/{dashboardWidgets.d.ts → components/dashboardWidgets.d.ts} +0 -0
- /package/dist/{nav.d.ts → lib/nav.d.ts} +0 -0
- /package/dist/{pages → views}/CourseEditorPage.d.ts +0 -0
- /package/dist/{pages → views}/CoursesListPage.d.ts +0 -0
- /package/dist/{pages → views}/FinancialPage.d.ts +0 -0
- /package/dist/{pages → views}/ReportsPage.d.ts +0 -0
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import * as React from 'react'
|
|
2
|
-
import { useTranslation } from '@fayz-ai/core'
|
|
3
|
-
import {
|
|
4
|
-
OrderDetailView as SharedOrderDetailView, OrderDetailSkeleton, PersonLink,
|
|
5
|
-
type OrderDetailData, type OrderDetailInstallment, type OrderDetailTone,
|
|
6
|
-
} from '@fayz-ai/saas'
|
|
7
|
-
import { getCoursesProvider, type OrderDetail, type FinancialStatus } from '@fayz-ai/courses'
|
|
8
|
-
import { EmptyState } from '../components/CommerceUI'
|
|
9
|
-
import { formatMoney, formatDate } from '../lib/format'
|
|
10
|
-
import { navigateTo } from '../nav'
|
|
11
|
-
|
|
12
|
-
const Page = ({ children }: { children: React.ReactNode }) => (
|
|
13
|
-
<div className="mx-auto max-w-6xl p-6 md:p-8">{children}</div>
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
// Cache por id (fora do componente) — trocar de aba remonta a view; sem cache
|
|
17
|
-
// isso refaz o getOrder (skeleton + request) toda vez. Cache-first evita o refetch.
|
|
18
|
-
const orderCache = new Map<string, OrderDetail>()
|
|
19
|
-
|
|
20
|
-
function statusTone(s: FinancialStatus): OrderDetailTone {
|
|
21
|
-
if (s === 'paid') return 'success'
|
|
22
|
-
if (s === 'pending') return 'warning'
|
|
23
|
-
if (s === 'refunded' || s === 'chargeback') return 'destructive'
|
|
24
|
-
return 'muted'
|
|
25
|
-
}
|
|
26
|
-
function instTone(s: string): OrderDetailTone {
|
|
27
|
-
if (s === 'paid') return 'success'
|
|
28
|
-
if (s === 'overdue') return 'destructive'
|
|
29
|
-
return 'warning'
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
/** Order detail (`/courses/sales/:id`). Loads the canonical order and renders the
|
|
33
|
-
* SHARED archetype OrderDetailView (@fayz-ai/saas) — same component the shop uses. */
|
|
34
|
-
export function CourseOrderDetailView({ id }: { id?: string }) {
|
|
35
|
-
const t = useTranslation()
|
|
36
|
-
const [order, setOrder] = React.useState<OrderDetail | null>(() => (id ? orderCache.get(id) ?? null : null))
|
|
37
|
-
const [loading, setLoading] = React.useState(() => !(id && orderCache.has(id)))
|
|
38
|
-
|
|
39
|
-
React.useEffect(() => {
|
|
40
|
-
let alive = true
|
|
41
|
-
if (!id) { setLoading(false); return }
|
|
42
|
-
const cached = orderCache.get(id)
|
|
43
|
-
if (cached) { setOrder(cached); setLoading(false); return } // cache hit → sem request
|
|
44
|
-
setLoading(true)
|
|
45
|
-
void getCoursesProvider().getOrder(id).then((o) => {
|
|
46
|
-
if (!alive) return
|
|
47
|
-
if (o) orderCache.set(id, o)
|
|
48
|
-
setOrder(o); setLoading(false)
|
|
49
|
-
})
|
|
50
|
-
return () => { alive = false }
|
|
51
|
-
}, [id])
|
|
52
|
-
|
|
53
|
-
const back = () => navigateTo('/courses/sales')
|
|
54
|
-
|
|
55
|
-
if (loading) return <Page><OrderDetailSkeleton /></Page>
|
|
56
|
-
if (!order) {
|
|
57
|
-
return (
|
|
58
|
-
<Page>
|
|
59
|
-
<EmptyState
|
|
60
|
-
title={t('courses.order.notFound') || 'Pedido não encontrado'}
|
|
61
|
-
description=""
|
|
62
|
-
action={<button className="text-sm text-primary underline" onClick={back}>{t('common.back') || 'Voltar'}</button>}
|
|
63
|
-
/>
|
|
64
|
-
</Page>
|
|
65
|
-
)
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
const cur = order.currency
|
|
69
|
-
const installments: OrderDetailInstallment[] = order.installments.map((m) => ({
|
|
70
|
-
number: m.installmentNumber,
|
|
71
|
-
amount: formatMoney(m.amount, cur),
|
|
72
|
-
status: m.status,
|
|
73
|
-
statusTone: instTone(m.status),
|
|
74
|
-
dueDate: m.dueDate ? formatDate(m.dueDate) : null,
|
|
75
|
-
paymentDate: m.paymentDate ? formatDate(m.paymentDate) : null,
|
|
76
|
-
note: m.cardBrand ? `${m.cardBrand}${m.cardInstallments ? ` ${m.cardInstallments}x` : ''}` : null,
|
|
77
|
-
}))
|
|
78
|
-
|
|
79
|
-
const data: OrderDetailData = {
|
|
80
|
-
title: `${t('courses.order.title') || 'Pedido'} #${order.id.slice(0, 8)}`,
|
|
81
|
-
subtitle: formatDate(order.createdAt),
|
|
82
|
-
badges: [
|
|
83
|
-
{ label: t(`courses.financialStatus.${order.financialStatus}`) || order.financialStatus, tone: statusTone(order.financialStatus) },
|
|
84
|
-
...(order.installmentCount && order.installmentCount > 1 ? [{ label: `${order.installmentCount}x`, tone: 'muted' as OrderDetailTone }] : []),
|
|
85
|
-
],
|
|
86
|
-
customer: { name: order.customerName, email: order.customerEmail },
|
|
87
|
-
customerNode: (
|
|
88
|
-
<div className="space-y-1 text-sm">
|
|
89
|
-
{order.customerId ? (
|
|
90
|
-
<PersonLink
|
|
91
|
-
personId={order.customerId}
|
|
92
|
-
name={order.customerName ?? order.customerEmail ?? 'Cliente'}
|
|
93
|
-
className="font-medium"
|
|
94
|
-
/>
|
|
95
|
-
) : (
|
|
96
|
-
<p className="font-medium">{order.customerName ?? '—'}</p>
|
|
97
|
-
)}
|
|
98
|
-
{order.customerEmail && <p className="text-muted-foreground">{order.customerEmail}</p>}
|
|
99
|
-
</div>
|
|
100
|
-
),
|
|
101
|
-
items: [{
|
|
102
|
-
name: order.courseTitle ?? '—',
|
|
103
|
-
description: order.offerName,
|
|
104
|
-
quantity: 1,
|
|
105
|
-
unitPrice: formatMoney(order.total, cur),
|
|
106
|
-
total: formatMoney(order.total, cur),
|
|
107
|
-
}],
|
|
108
|
-
totals: [
|
|
109
|
-
{ label: 'Total', value: formatMoney(order.total, cur), strong: true },
|
|
110
|
-
...(order.platformFee > 0 ? [{ label: 'Taxa', value: `− ${formatMoney(order.platformFee, cur)}`, muted: true }] : []),
|
|
111
|
-
{ label: 'Líquido', value: formatMoney(order.netValue, cur) },
|
|
112
|
-
],
|
|
113
|
-
paymentMethod: order.paymentMethod ?? undefined,
|
|
114
|
-
receivable: {
|
|
115
|
-
rows: [
|
|
116
|
-
{ label: 'Recebido', value: formatMoney(order.paidAmount, cur) },
|
|
117
|
-
{ label: 'Saldo', value: formatMoney(order.balance, cur), strong: order.balance > 0 },
|
|
118
|
-
],
|
|
119
|
-
installments,
|
|
120
|
-
emptyLabel: t('courses.order.noInstallments') || 'Sem parcelas.',
|
|
121
|
-
},
|
|
122
|
-
onBack: back,
|
|
123
|
-
backLabel: t('courses.sales.title') || 'Vendas',
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return (
|
|
127
|
-
<Page>
|
|
128
|
-
<SharedOrderDetailView {...data} />
|
|
129
|
-
</Page>
|
|
130
|
-
)
|
|
131
|
-
}
|
|
132
|
-
CourseOrderDetailView.displayName = 'CourseOrderDetailView'
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|