Skip to content

Commit 70f70d3

Browse files
feat(agenda): conditionally display Codante PRO promotion based on user status
- Integrated user context to check if the user is a Codante PRO subscriber. - The promotional card for Codante PRO is now displayed only for non-subscribers, enhancing user experience by targeting relevant offers.
1 parent d3a8618 commit 70f70d3

1 file changed

Lines changed: 32 additions & 28 deletions

File tree

  • app/routes/_layout-app/_agenda/agenda

app/routes/_layout-app/_agenda/agenda/index.tsx

Lines changed: 32 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import type React from "react";
22
import type { MetaFunction } from "react-router";
33

4-
import { Link, useLoaderData } from "react-router";
4+
import { Link, useLoaderData, useOutletContext } from "react-router";
55
import { parseISO, format } from "date-fns";
66
import { ptBR } from "date-fns/locale";
77

@@ -25,6 +25,7 @@ import { RiLiveLine } from "react-icons/ri";
2525
import { cn } from "~/lib/utils/cn";
2626
import { useState } from "react";
2727
import ProSpanWrapper from "~/components/ui/pro-span-wrapper";
28+
import type { User } from "~/lib/models/user.server";
2829

2930
export const meta: MetaFunction = () => {
3031
return [
@@ -67,6 +68,7 @@ function getBorderColor(type: string) {
6768

6869
export default function Calendar() {
6970
const events = useLoaderData<typeof loader>();
71+
const { user } = useOutletContext<{ user: User | null }>();
7072

7173
const [selectedFilter, setSelectedFilter] = useState<"upcoming" | "previous">(
7274
"upcoming",
@@ -254,33 +256,35 @@ export default function Calendar() {
254256
))}
255257
</div>
256258
</div>
257-
<div className="xl:w-1/3 w-full hidden xl:block">
258-
<Link to="/planos" className="sticky top-20">
259-
<Card
260-
border="default"
261-
className="w-full text-sm rounded-lg overflow-hidden bg-grainy mt-32"
262-
>
263-
<CardHeader>
264-
<CardTitle className="md:text-md lg:text-lg xl:text-lg text-xs">
265-
<span className="font-medium text-gray-700 dark:text-gray-50">
266-
Conheça o Codante <ProSpanWrapper>PRO</ProSpanWrapper>
267-
</span>
268-
</CardTitle>
269-
</CardHeader>
270-
<CardContent className="text-sm text-gray-700 dark:text-gray-300">
271-
<p>
272-
Tenha acesso completo a todos os nossos Mini Projetos e
273-
Workshops.
274-
</p>
275-
<img
276-
src="/img/agenda-promo.webp"
277-
alt="Codante Pro"
278-
className="w-full"
279-
/>
280-
</CardContent>
281-
</Card>
282-
</Link>
283-
</div>
259+
{(!user || !user.is_pro) && (
260+
<div className="xl:w-1/3 w-full hidden xl:block">
261+
<Link to="/planos" className="sticky top-20">
262+
<Card
263+
border="default"
264+
className="w-full text-sm rounded-lg overflow-hidden bg-grainy mt-32"
265+
>
266+
<CardHeader>
267+
<CardTitle className="md:text-md lg:text-lg xl:text-lg text-xs">
268+
<span className="font-medium text-gray-700 dark:text-gray-50">
269+
Conheça o Codante <ProSpanWrapper>PRO</ProSpanWrapper>
270+
</span>
271+
</CardTitle>
272+
</CardHeader>
273+
<CardContent className="text-sm text-gray-700 dark:text-gray-300">
274+
<p>
275+
Tenha acesso completo a todos os nossos Mini Projetos e
276+
Workshops.
277+
</p>
278+
<img
279+
src="/img/agenda-promo.webp"
280+
alt="Codante Pro"
281+
className="w-full"
282+
/>
283+
</CardContent>
284+
</Card>
285+
</Link>
286+
</div>
287+
)}
284288
</div>
285289
);
286290
}

0 commit comments

Comments
 (0)