Implement collaboration wallets, withdrawals, and app UI flows
This commit is contained in:
@@ -8,7 +8,7 @@ import { Badge } from "@/components/ui/badge";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { Skeleton } from "@/components/ui/skeleton";
|
||||
import { formatIDR } from "@/lib/format";
|
||||
import { Video, ArrowRight, Package, Receipt, ShoppingBag } from "lucide-react";
|
||||
import { Video, ArrowRight, Package, Receipt, ShoppingBag, Wallet } from "lucide-react";
|
||||
import { WhatsAppBanner } from "@/components/WhatsAppBanner";
|
||||
import { ConsultingHistory } from "@/components/reviews/ConsultingHistory";
|
||||
import { UnpaidOrderAlert } from "@/components/UnpaidOrderAlert";
|
||||
@@ -58,6 +58,7 @@ export default function MemberDashboard() {
|
||||
const [consultingSlots, setConsultingSlots] = useState<ConsultingSlot[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [hasWhatsApp, setHasWhatsApp] = useState(true);
|
||||
const [isCollaborator, setIsCollaborator] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
if (!authLoading && !user) navigate("/auth");
|
||||
@@ -122,7 +123,7 @@ export default function MemberDashboard() {
|
||||
}, []);
|
||||
|
||||
const fetchData = async () => {
|
||||
const [accessRes, ordersRes, paidOrdersRes, profileRes, slotsRes] = await Promise.all([
|
||||
const [accessRes, ordersRes, paidOrdersRes, profileRes, slotsRes, walletRes, collaboratorProductRes] = await Promise.all([
|
||||
supabase
|
||||
.from("user_access")
|
||||
.select(`id, product:products (id, title, slug, type, meeting_link, recording_url, event_start, duration_minutes)`)
|
||||
@@ -148,6 +149,8 @@ export default function MemberDashboard() {
|
||||
.eq("user_id", user!.id)
|
||||
.eq("status", "confirmed")
|
||||
.order("date", { ascending: false }),
|
||||
supabase.from("collaborator_wallets").select("user_id").eq("user_id", user!.id).maybeSingle(),
|
||||
supabase.from("products").select("id").eq("collaborator_user_id", user!.id).limit(1),
|
||||
]);
|
||||
|
||||
// Combine access from user_access and paid orders
|
||||
@@ -170,6 +173,7 @@ export default function MemberDashboard() {
|
||||
if (ordersRes.data) setRecentOrders(ordersRes.data);
|
||||
if (profileRes.data) setHasWhatsApp(!!profileRes.data.whatsapp_number);
|
||||
if (slotsRes.data) setConsultingSlots(slotsRes.data as unknown as ConsultingSlot[]);
|
||||
setIsCollaborator(!!walletRes?.data || !!(collaboratorProductRes?.data && collaboratorProductRes.data.length > 0));
|
||||
setLoading(false);
|
||||
};
|
||||
|
||||
@@ -282,6 +286,22 @@ export default function MemberDashboard() {
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
{isCollaborator && (
|
||||
<Card className="border-2 border-border col-span-full">
|
||||
<CardContent className="pt-6 flex items-center justify-between">
|
||||
<div className="flex items-center gap-4">
|
||||
<Wallet className="w-10 h-10 text-primary" />
|
||||
<div>
|
||||
<p className="text-sm text-muted-foreground">Kolaborator Dashboard</p>
|
||||
<p className="font-medium">Lihat profit & withdrawal</p>
|
||||
</div>
|
||||
</div>
|
||||
<Button variant="outline" onClick={() => navigate("/profit")} className="border-2">
|
||||
Buka Profit
|
||||
</Button>
|
||||
</CardContent>
|
||||
</Card>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{access.length > 0 && (
|
||||
|
||||
Reference in New Issue
Block a user