From ba9942b1d3d8835e11211c00b7bc1c1af96d7381 Mon Sep 17 00:00:00 2001 From: Lautaro Petaccio Date: Wed, 29 Nov 2023 19:47:26 -0300 Subject: [PATCH 1/4] fix: Links --- src/api/Events.ts | 4 ++-- src/components/Button/AddToCalendarButton.tsx | 4 +++- src/components/Button/AttendingButtons.tsx | 6 +++-- src/components/Button/JumpInButton.tsx | 4 +++- .../Event/CarouselEvents/CarouselEvents.tsx | 10 ++++---- src/components/Event/EventCard/EventCard.tsx | 6 ++--- .../Event/EventCardBig/EventCardBig.tsx | 4 +++- .../Event/EventCardMini/EventCardMini.tsx | 4 +++- .../EventModal/EventDetail/EventDetail.tsx | 6 +++-- .../Event/ListEvents/ListEvents.tsx | 24 +++++++++++++++---- src/components/Layout/Navigation.tsx | 5 ++++ src/config/dev.json | 2 +- src/config/prod.json | 2 +- src/entities/Event/utils.ts | 11 ++++++--- src/modules/locations.ts | 5 +--- 15 files changed, 66 insertions(+), 31 deletions(-) diff --git a/src/api/Events.ts b/src/api/Events.ts index a083f551..6a8beb15 100644 --- a/src/api/Events.ts +++ b/src/api/Events.ts @@ -58,7 +58,7 @@ export type EditSchedule = Pick< > export default class Events extends API { - static Url = env("EVENTS_URL", `https://events.decentraland.org/api`) + static Url = env("EVENTS_API_URL", `https://events.decentraland.org/api`) static Cache = new Map() @@ -71,7 +71,7 @@ export default class Events extends API { } static get() { - return this.from(env("EVENTS_URL", this.Url)) + return this.from(env("EVENTS_API_URL", this.Url)) } static parseEvent(event: SessionEventAttributes): SessionEventAttributes { diff --git a/src/components/Button/AddToCalendarButton.tsx b/src/components/Button/AddToCalendarButton.tsx index 979c8b50..2cd81706 100644 --- a/src/components/Button/AddToCalendarButton.tsx +++ b/src/components/Button/AddToCalendarButton.tsx @@ -1,5 +1,7 @@ import React, { useCallback } from "react" +import { withPrefix } from "gatsby" + import useTrackContext from "decentraland-gatsby/dist/context/Track/useTrackContext" import useFormatMessage from "decentraland-gatsby/dist/hooks/useFormatMessage" import Time from "decentraland-gatsby/dist/utils/date/Time" @@ -53,7 +55,7 @@ export default function AddToCalendarButton({ target="_blank" {...props} onClick={handleClick} - href={to} + href={withPrefix(to)} basic className={TokenList.join(["AddToCalendarButton", props.className])} > diff --git a/src/components/Button/AttendingButtons.tsx b/src/components/Button/AttendingButtons.tsx index f25141a3..3194b24c 100644 --- a/src/components/Button/AttendingButtons.tsx +++ b/src/components/Button/AttendingButtons.tsx @@ -1,5 +1,7 @@ import React, { useCallback, useMemo, useState } from "react" +import { withPrefix } from "gatsby" + import { useLocation } from "@gatsbyjs/reach-router" import useTrackContext from "decentraland-gatsby/dist/context/Track/useTrackContext" import useAsyncTask from "decentraland-gatsby/dist/hooks/useAsyncTask" @@ -58,7 +60,7 @@ export default function AttendingButtons(props: AttendingButtonsProps) { await (navigator as any).share({ title: event.name, text: event.description, - url: location.origin + locations.event(event.id), + url: location.origin + withPrefix(locations.event(event.id)), }) } catch (err) { console.error(err) @@ -183,7 +185,7 @@ export default function AttendingButtons(props: AttendingButtonsProps) { disabled={loading || sharing || !approved} onClick={handleStopPropagation} className="fluid" - href={href} + href={href ? withPrefix(href) : href} target="_blank" style={{ display: "flex", diff --git a/src/components/Button/JumpInButton.tsx b/src/components/Button/JumpInButton.tsx index 18680802..e14f9f7d 100644 --- a/src/components/Button/JumpInButton.tsx +++ b/src/components/Button/JumpInButton.tsx @@ -1,5 +1,7 @@ import React, { useMemo } from "react" +import { withPrefix } from "gatsby" + import useFormatMessage from "decentraland-gatsby/dist/hooks/useFormatMessage" import { Button, @@ -28,7 +30,7 @@ export default function JumpInButton(props: ButtonProps) {