Skip to content

Commit 6123b27

Browse files
refactor: simplify parameter handling in EventPage and enhance Newsletter component animations
1 parent c3d7728 commit 6123b27

3 files changed

Lines changed: 65 additions & 8 deletions

File tree

src/app/events/[id]/page.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ type EventPageParams = {
1111
};
1212

1313
type EventPageProps = {
14-
params: Promise<EventPageParams> | EventPageParams;
14+
params: Promise<EventPageParams>;
1515
};
1616

1717
export function generateStaticParams() {
1818
return eventsData.map((event) => ({ id: event.id }));
1919
}
2020

2121
export async function generateMetadata({ params }: EventPageProps): Promise<Metadata> {
22-
const resolvedParams = params instanceof Promise ? await params : params;
22+
const resolvedParams = await params;
2323
const id = resolvedParams?.id;
2424
if (!id) {
2525
return {
@@ -50,7 +50,7 @@ export async function generateMetadata({ params }: EventPageProps): Promise<Meta
5050
}
5151

5252
export default async function EventPage({ params }: EventPageProps) {
53-
const resolvedParams = params instanceof Promise ? await params : params;
53+
const resolvedParams = await params;
5454
const id = resolvedParams?.id;
5555
if (!id) {
5656
notFound();

src/components/newsletter.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,13 @@ export const Newsletter = () => {
191191
toast.error("Por favor ingresa tu email");
192192
if (inputRef.current) {
193193
gsap.to(inputRef.current, {
194-
x: [-10, 10, -10, 10, 0],
194+
keyframes: [
195+
{ x: -10 },
196+
{ x: 10 },
197+
{ x: -10 },
198+
{ x: 10 },
199+
{ x: 0 },
200+
],
195201
duration: 0.5,
196202
ease: "power2.inOut",
197203
});

src/components/team.tsx

Lines changed: 55 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,57 @@ type HeadquartersStyle = {
5353
icon: (className?: string) => JSX.Element;
5454
};
5555

56+
const SOCIAL_PLATFORMS: readonly SocialPlatform[] = [
57+
"github",
58+
"linkedin",
59+
"instagram",
60+
"behance",
61+
"twitter",
62+
"website",
63+
] as const;
64+
65+
const isSocialPlatform = (platform: string): platform is SocialPlatform => {
66+
return SOCIAL_PLATFORMS.includes(platform as SocialPlatform);
67+
};
68+
69+
const normalizeSocials = (
70+
socials?: { platform: string; url: string }[]
71+
): SocialLink[] => {
72+
if (!socials) return [];
73+
return socials
74+
.map((social) => {
75+
if (!isSocialPlatform(social.platform)) return null;
76+
return {
77+
platform: social.platform,
78+
url: social.url,
79+
};
80+
})
81+
.filter((social): social is SocialLink => Boolean(social));
82+
};
83+
84+
const normalizeHeadquarters = (
85+
headquarters?: TeamJSON["headquarters"]
86+
): Headquarters[] => {
87+
if (!headquarters) return [];
88+
return headquarters
89+
.filter((hq) => (hq.members?.length ?? 0) > 0)
90+
.map((hq): Headquarters => ({
91+
id: hq.id,
92+
label: hq.label,
93+
location: hq.location,
94+
lead: hq.lead,
95+
members:
96+
hq.members?.map(
97+
(member): TeamMember => ({
98+
name: member.name,
99+
role: member.role,
100+
image: member.image,
101+
socials: normalizeSocials(member.socials),
102+
})
103+
) ?? [],
104+
}));
105+
};
106+
56107
const HEADQUARTERS_STYLES: Record<string, HeadquartersStyle> = {
57108
principal: {
58109
gradient: "from-primary via-primary to-secondary",
@@ -342,10 +393,10 @@ const HeadquartersCarousel = ({
342393
export const TeamSection = () => {
343394
const data = teamData as TeamJSON;
344395

345-
const headquartersList = useMemo<Headquarters[]>(() => {
346-
if (!data?.headquarters) return [];
347-
return data.headquarters.filter((hq) => hq.members?.length > 0);
348-
}, [data]);
396+
const headquartersList = useMemo<Headquarters[]>(
397+
() => normalizeHeadquarters(data?.headquarters),
398+
[data]
399+
);
349400

350401
if (headquartersList.length === 0) {
351402
return null;

0 commit comments

Comments
 (0)