Fix badge colors and show paid webinars in access pages
- Change "Lunas" badge to use brand accent color instead of hardcoded green - Fix "Aktif" badge with white text and border for better contrast - Update MemberAccess page to fetch from paid orders (webinars now show) - Remove payment_provider filter completely since only Pakasir is used 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -36,11 +36,48 @@ export default function MemberAccess() {
|
|||||||
}, [user, authLoading]);
|
}, [user, authLoading]);
|
||||||
|
|
||||||
const fetchAccess = async () => {
|
const fetchAccess = async () => {
|
||||||
const { data } = await supabase
|
const [accessRes, paidOrdersRes] = await Promise.all([
|
||||||
.from('user_access')
|
// Get direct user_access
|
||||||
.select(`id, granted_at, expires_at, product:products (id, title, slug, type, meeting_link, recording_url, description)`)
|
supabase
|
||||||
.eq('user_id', user!.id);
|
.from('user_access')
|
||||||
if (data) setAccess(data as unknown as UserAccess[]);
|
.select(`id, granted_at, expires_at, product:products (id, title, slug, type, meeting_link, recording_url, description)`)
|
||||||
|
.eq('user_id', user!.id),
|
||||||
|
// Get products from paid orders (via order_items)
|
||||||
|
supabase
|
||||||
|
.from("orders")
|
||||||
|
.select(
|
||||||
|
`
|
||||||
|
order_items (
|
||||||
|
product:products (id, title, slug, type, meeting_link, recording_url, description)
|
||||||
|
)
|
||||||
|
`,
|
||||||
|
)
|
||||||
|
.eq("user_id", user!.id)
|
||||||
|
.eq("payment_status", "paid"),
|
||||||
|
]);
|
||||||
|
|
||||||
|
// Combine access from user_access and paid orders
|
||||||
|
const directAccess = (accessRes.data as unknown as UserAccess[]) || [];
|
||||||
|
const paidProductAccess: UserAccess[] = [];
|
||||||
|
|
||||||
|
if (paidOrdersRes.data) {
|
||||||
|
const existingIds = new Set(directAccess.map((a) => a.product.id));
|
||||||
|
paidOrdersRes.data.forEach((order: any) => {
|
||||||
|
order.order_items?.forEach((item: any) => {
|
||||||
|
if (item.product && !existingIds.has(item.product.id)) {
|
||||||
|
existingIds.add(item.product.id);
|
||||||
|
paidProductAccess.push({
|
||||||
|
id: `paid-${item.product.id}`,
|
||||||
|
granted_at: new Date().toISOString(),
|
||||||
|
expires_at: null,
|
||||||
|
product: item.product
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
setAccess([...directAccess, ...paidProductAccess]);
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -127,7 +164,7 @@ export default function MemberAccess() {
|
|||||||
<CardTitle>{item.product.title}</CardTitle>
|
<CardTitle>{item.product.title}</CardTitle>
|
||||||
<CardDescription className="capitalize">{item.product.type}</CardDescription>
|
<CardDescription className="capitalize">{item.product.type}</CardDescription>
|
||||||
</div>
|
</div>
|
||||||
<Badge className="bg-accent">Aktif</Badge>
|
<Badge className="bg-brand-accent text-white border-2">Aktif</Badge>
|
||||||
</div>
|
</div>
|
||||||
</CardHeader>
|
</CardHeader>
|
||||||
<CardContent>
|
<CardContent>
|
||||||
|
|||||||
@@ -298,7 +298,7 @@ export default function MemberDashboard() {
|
|||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
<div className="flex items-center gap-4">
|
<div className="flex items-center gap-4">
|
||||||
<Badge className={order.payment_status === "paid" ? "bg-green-600 text-white border-2 border-green-700" : "bg-amber-500 text-white border-2 border-amber-600"}>
|
<Badge className={order.payment_status === "paid" ? "bg-brand-accent text-white border-2" : "bg-amber-500 text-white border-2 border-amber-600"}>
|
||||||
{order.payment_status === "paid" ? "Lunas" : "Pending"}
|
{order.payment_status === "paid" ? "Lunas" : "Pending"}
|
||||||
</Badge>
|
</Badge>
|
||||||
<span className="font-bold">{formatIDR(order.total_amount)}</span>
|
<span className="font-bold">{formatIDR(order.total_amount)}</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user