Skip to content

Commit e2197e0

Browse files
Protegiu souls contra monetização
X-Lovable-Edit-ID: edt-b15baa16-d585-4fbd-9a8d-5f11fa9bdf83 Co-authored-by: criptogus <128640021+criptogus@users.noreply.github.com>
2 parents dfc013d + 29736d0 commit e2197e0

4 files changed

Lines changed: 26 additions & 5 deletions

File tree

src/routes/marketplace.index.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ function Card({ p }: { p: MarketplaceItem }) {
406406
<div className="flex items-center justify-between gap-2">
407407
<TypeBadge type={p.type} />
408408
<div className="flex items-center gap-2">
409-
<PriceBadge priceCredits={p.price_credits} />
409+
{p.type !== "soul" && <PriceBadge priceCredits={p.price_credits} />}
410410
<span className="font-mono text-[10px] text-muted-foreground">v{p.latest_version}</span>
411411
<ShareOnXButton
412412
slug={p.slug}
@@ -454,9 +454,9 @@ function Card({ p }: { p: MarketplaceItem }) {
454454
)}
455455
<div className="mt-auto flex items-center gap-2 pt-5">
456456
<div className="inline-flex h-9 flex-1 items-center justify-center rounded-md bg-foreground text-sm font-medium text-background transition-opacity group-hover:opacity-90">
457-
{p.price_credits > 0 ? "View →" : "View package →"}
457+
{p.type === "soul" ? "View soul →" : p.price_credits > 0 ? "View →" : "View package →"}
458458
</div>
459-
{p.price_credits > 0 && (
459+
{p.type !== "soul" && p.price_credits > 0 && (
460460
<BuyButton packageId={p.id} priceCredits={p.price_credits} />
461461
)}
462462
</div>

src/routes/marketplace.leaderboard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ function RankCard({ p, rank }: { p: MarketplaceItem; rank: number }) {
125125
</span>
126126
<div className="flex items-center gap-2">
127127
<TypeBadge type={p.type} />
128-
<PriceBadge priceCredits={p.price_credits} />
128+
{p.type !== "soul" && <PriceBadge priceCredits={p.price_credits} />}
129129
</div>
130130
</div>
131131
<div className="mt-3 font-mono text-[15px] font-semibold leading-tight">{p.name}</div>

src/routes/u.$handle.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ function CreatorCard({ p }: { p: MarketplaceItem }) {
141141
>
142142
<div className="flex items-center justify-between gap-2">
143143
<TypeBadge type={p.type} />
144-
<PriceBadge priceCredits={p.price_credits} />
144+
{p.type !== "soul" && <PriceBadge priceCredits={p.price_credits} />}
145145
</div>
146146
<div className="mt-3 font-mono text-[15px] font-semibold leading-tight">{p.name}</div>
147147
<p className="mt-2 line-clamp-3 text-sm text-muted-foreground">{p.description}</p>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-- Force any existing soul to be free
2+
UPDATE public.packages SET price_credits = 0 WHERE type = 'soul' AND price_credits <> 0;
3+
4+
-- Trigger to enforce souls are always free
5+
CREATE OR REPLACE FUNCTION public.enforce_souls_free()
6+
RETURNS trigger
7+
LANGUAGE plpgsql
8+
SET search_path TO 'public'
9+
AS $$
10+
BEGIN
11+
IF NEW.type = 'soul' AND COALESCE(NEW.price_credits, 0) <> 0 THEN
12+
NEW.price_credits := 0;
13+
END IF;
14+
RETURN NEW;
15+
END
16+
$$;
17+
18+
DROP TRIGGER IF EXISTS trg_enforce_souls_free ON public.packages;
19+
CREATE TRIGGER trg_enforce_souls_free
20+
BEFORE INSERT OR UPDATE OF price_credits, type ON public.packages
21+
FOR EACH ROW EXECUTE FUNCTION public.enforce_souls_free();

0 commit comments

Comments
 (0)