feat(market): add Minha Intenções tab with panel, hook, and badge
- Introduced "Minhas Intenções" tab visible only to logged-in users. - Integrated MyPurchaseIntentionsPanel and useMyPurchaseIntentions hook. - Added tab badge showing count of pending intentions. - Extended session API to include user’s main character for downstream features.
This commit is contained in:
1 parent
f35fee944d
commit
7f42def478
55 files changed
+4906
-95
No files matched your search
@@ -19,8 +19,11 @@ import { useMarketTelemetry } from "@/lib/hooks/use-telemetry";
|
||||
import { AdCard } from "@/components/marketplace/AdCard";
|
||||
import { CreateAdModal } from "@/components/marketplace/CreateAdModal";
|
||||
import { MyAdsPanel } from "@/components/marketplace/MyAdsPanel";
|
||||
import { MyPurchaseIntentionsPanel } from "@/components/marketplace/MyPurchaseIntentionsPanel";
|
||||
import { useSession } from "@/lib/hooks/use-session";
|
||||
import { useListings, useInvalidateListings } from "@/lib/hooks/use-listings";
|
||||
import { useMyPurchaseIntentions } from "@/lib/hooks/use-purchase-intentions";
|
||||
import { useLocale } from "next-intl";
|
||||
|
||||
interface Listing {
|
||||
listing_id: number;
|
||||
@@ -53,6 +56,7 @@ export default function MarketClient({ initial }: { initial: InitialData }) {
|
||||
const { user } = useSession();
|
||||
const { trackSearch, trackFilter, trackPageView } = useMarketTelemetry();
|
||||
const invalidateListings = useInvalidateListings();
|
||||
const locale = useLocale();
|
||||
|
||||
const [page, setPage] = useState<number>(initial.page || 1);
|
||||
const [pageSize] = useState<number>(initial.pageSize || 20);
|
||||
@@ -152,11 +156,14 @@ export default function MarketClient({ initial }: { initial: InitialData }) {
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Tabs para Explorar e Meus Anúncios */}
|
||||
{/* Tabs para Explorar, Meus Anúncios e Minhas Intenções */}
|
||||
<Tabs value={activeTab} onValueChange={setActiveTab}>
|
||||
<TabsList>
|
||||
<TabsTrigger value="explore">Explorar</TabsTrigger>
|
||||
{user && <TabsTrigger value="my-ads">Meus Anúncios</TabsTrigger>}
|
||||
{user && (
|
||||
<MyPurchaseIntentionsTabTrigger />
|
||||
)}
|
||||
</TabsList>
|
||||
|
||||
{/* Aba: Explorar Anúncios */}
|
||||
@@ -399,8 +406,35 @@ export default function MarketClient({ initial }: { initial: InitialData }) {
|
||||
<MyAdsPanel />
|
||||
</TabsContent>
|
||||
)}
|
||||
|
||||
{/* Aba: Minhas Intenções */}
|
||||
{user && (
|
||||
<TabsContent value="my-intentions" className="mt-6">
|
||||
<MyPurchaseIntentionsPanel locale={locale} />
|
||||
</TabsContent>
|
||||
)}
|
||||
</Tabs>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Componente para o trigger da tab com badge de contador
|
||||
function MyPurchaseIntentionsTabTrigger() {
|
||||
const { intentions } = useMyPurchaseIntentions();
|
||||
const pendingCount = intentions.filter((i) => i.status === "pending").length;
|
||||
|
||||
return (
|
||||
<TabsTrigger value="my-intentions" className="relative">
|
||||
Minhas Intenções
|
||||
{pendingCount > 0 && (
|
||||
<Badge
|
||||
variant="destructive"
|
||||
className="ml-2 h-5 min-w-5 px-1.5 text-xs"
|
||||
>
|
||||
{pendingCount}
|
||||
</Badge>
|
||||
)}
|
||||
</TabsTrigger>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user