Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Links #593

Merged
merged 5 commits into from
Nov 30, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
658 changes: 600 additions & 58 deletions package-lock.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"core-js": "^3.22.2",
"cssnano": "^5.0.10",
"dcl-catalyst-client": "^21.5.0",
"decentraland-gatsby": "^5.92.0",
"decentraland-gatsby": "^5.96.1",
"es6-shim": "^0.35.6",
"express-fileupload": "^1.2.1",
"gatsby": "^4.23.0",
Expand Down
4 changes: 2 additions & 2 deletions src/api/Events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, Events>()

Expand All @@ -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 {
Expand Down
4 changes: 3 additions & 1 deletion src/components/Button/AddToCalendarButton.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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])}
>
Expand Down
6 changes: 4 additions & 2 deletions src/components/Button/AttendingButtons.tsx
Original file line number Diff line number Diff line change
@@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion src/components/Button/JumpInButton.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useMemo } from "react"

import { withPrefix } from "gatsby"

import useFormatMessage from "decentraland-gatsby/dist/hooks/useFormatMessage"
import {
Button,
Expand Down Expand Up @@ -28,7 +30,7 @@ export default function JumpInButton(props: ButtonProps) {
<Button
primary
className="fluid"
href={href}
href={withPrefix(href)}
target="_blank"
style={{
display: "flex",
Expand Down
10 changes: 5 additions & 5 deletions src/components/Event/CarouselEvents/CarouselEvents.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, { useCallback, useMemo } from "react"

import Carousel2, {
IndicatorType,
} from "decentraland-gatsby/dist/components/Carousel2/Carousel2"
import { withPrefix } from "gatsby"

import Carousel2 from "decentraland-gatsby/dist/components/Carousel2/Carousel2"
import SubTitle from "decentraland-gatsby/dist/components/Text/SubTitle"
import { navigate } from "decentraland-gatsby/dist/plugins/intl"
import TokenList from "decentraland-gatsby/dist/utils/dom/TokenList"
Expand Down Expand Up @@ -108,7 +108,7 @@ export const CarouselEvents = React.memo((props: CarouselEventsProps) => {
<Button
primary
as="a"
href={locations.schedule(schedule.id)}
href={withPrefix(locations.schedule(schedule.id))}
onClick={handleClickFullSchedule}
>
Full Schedule
Expand Down Expand Up @@ -176,7 +176,7 @@ const CarouselThemeHeader = React.memo(function CarouselThemeHeader({
<Button
as="a"
primary
href={locations.schedule(schedule.id)}
href={withPrefix(locations.schedule(schedule.id))}
onClick={handleClickFullSchedule}
>
{CarouselThemeHeaderCTA[schedule.theme]}
Expand Down
6 changes: 3 additions & 3 deletions src/components/Event/EventCard/EventCard.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import React, { useCallback, useMemo } from "react"

import { withPrefix } from "gatsby"

import ImgFixed from "decentraland-gatsby/dist/components/Image/ImgFixed"
import Avatar from "decentraland-gatsby/dist/components/Profile/Avatar"
import { navigate } from "decentraland-gatsby/dist/plugins/intl"
import TokenList from "decentraland-gatsby/dist/utils/dom/TokenList"
import { Card } from "decentraland-ui/dist/components/Card/Card"

import { SessionEventAttributes } from "../../../entities/Event/types"
import WorldIcon from "../../../images/worlds-icon.svg"
import locations from "../../../modules/locations"
import StartIn from "../../Badge/StartIn"
import AttendingButtons from "../../Button/AttendingButtons"
import JumpInPosition from "../../Button/JumpInPosition"
import EventDate from "../EventDate/EventDate"
import EventSection from "../EventSection"

import "./EventCard.css"

Expand Down Expand Up @@ -64,7 +64,7 @@ export default React.memo(function EventCard(props: EventCardProps) {
props.loading && "loading",
event && !event.approved && "pending",
])}
href={href}
href={href ? withPrefix(href) : href}
onClick={handleClick}
>
{event && <StartIn date={nextStartAt} />}
Expand Down
4 changes: 3 additions & 1 deletion src/components/Event/EventCardBig/EventCardBig.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useCallback, useMemo } from "react"

import { withPrefix } from "gatsby"

import ImgFixed from "decentraland-gatsby/dist/components/Image/ImgFixed"
import { navigate } from "decentraland-gatsby/dist/plugins/intl"
import TokenList from "decentraland-gatsby/dist/utils/dom/TokenList"
Expand Down Expand Up @@ -48,7 +50,7 @@ export default React.memo(function EventCardBig(props: EventCardBigProps) {
props.loading && "loading",
event && !event.approved && "pending",
])}
href={href}
href={href ? withPrefix(href) : href}
onClick={handleClick}
>
<div className="event-card-big__container">
Expand Down
4 changes: 3 additions & 1 deletion src/components/Event/EventCardMini/EventCardMini.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useCallback, useMemo } from "react"

import { withPrefix } from "gatsby"

import ImgFixed from "decentraland-gatsby/dist/components/Image/ImgFixed"
import { navigate } from "decentraland-gatsby/dist/plugins/intl"
import TokenList from "decentraland-gatsby/dist/utils/dom/TokenList"
Expand Down Expand Up @@ -52,7 +54,7 @@ export default React.memo(function EventCardMini(props: EventCardMiniProps) {
props.loading && "loading",
event && !event.approved && "pending",
])}
href={href}
href={href ? withPrefix(href) : href}
onClick={handleClick}
>
{event && !props.loading && (
Expand Down
6 changes: 4 additions & 2 deletions src/components/Event/EventModal/EventDetail/EventDetail.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useCallback, useMemo } from "react"

import { withPrefix } from "gatsby"

import DateBox from "decentraland-gatsby/dist/components/Date/DateBox"
import Avatar from "decentraland-gatsby/dist/components/Profile/Avatar"
import Italic from "decentraland-gatsby/dist/components/Text/Italic"
Expand Down Expand Up @@ -154,7 +156,7 @@ export default function EventDetail({ event, ...props }: EventDetailProps) {
basic
className="edit-detail__menu-icon-button"
as="a"
href={locations.editEvent(event.id)}
href={withPrefix(locations.editEvent(event.id))}
onClick={prevent(() =>
navigate(locations.editEvent(event.id))
)}
Expand All @@ -167,7 +169,7 @@ export default function EventDetail({ event, ...props }: EventDetailProps) {
basic
className="edit-detail__menu-icon-button"
as="a"
href={locations.cloneEvent(event.id)}
href={withPrefix(locations.cloneEvent(event.id))}
onClick={prevent(() =>
navigate(locations.cloneEvent(event.id))
)}
Expand Down
24 changes: 20 additions & 4 deletions src/components/Event/ListEvents/ListEvents.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useCallback, useMemo } from "react"

import { withPrefix } from "gatsby"

import { useLocation } from "@gatsbyjs/reach-router"
import useTrackContext from "decentraland-gatsby/dist/context/Track/useTrackContext"
import useFormatMessage from "decentraland-gatsby/dist/hooks/useFormatMessage"
Expand Down Expand Up @@ -138,7 +140,12 @@ export const ListEvents = React.memo((props: ListEventsProps) => {
new URLSearchParams(location.search)
)
track(SegmentEvent.Filter, newFilters)
navigate(url(location.pathname, newParams))
console.log("Change type change", url(location.pathname, newParams))
console.log("With prefix", withPrefix("/"), withPrefix(""))
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we remove this logs?

const pathname = location.pathname.startsWith(withPrefix("/"))
? location.pathname.slice(withPrefix("/").length)
: location.pathname
navigate(url(pathname, newParams))
},
[location.pathname, location.search, props.filters]
)
Expand All @@ -152,7 +159,10 @@ export const ListEvents = React.memo((props: ListEventsProps) => {
new URLSearchParams(location.search)
)
track(SegmentEvent.Filter, newFilters)
navigate(url(location.pathname, newParams))
const pathname = location.pathname.startsWith(withPrefix(""))
? location.pathname.slice(withPrefix("/").length)
: location.pathname
navigate(url(pathname, newParams))
},
[location.pathname, location.search, props.filters]
)
Expand All @@ -172,7 +182,10 @@ export const ListEvents = React.memo((props: ListEventsProps) => {
new URLSearchParams(location.search)
)
track(SegmentEvent.Filter, newFilters)
navigate(url(location.pathname, newParams))
const pathname = location.pathname.startsWith(withPrefix("/"))
? location.pathname.slice(withPrefix("/").length)
: location.pathname
navigate(url(pathname, newParams))
},
[]
)
Expand All @@ -192,7 +205,10 @@ export const ListEvents = React.memo((props: ListEventsProps) => {
new URLSearchParams(location.search)
)
track(SegmentEvent.Filter, newFilters)
navigate(url(location.pathname, newParams))
const pathname = location.pathname.startsWith(withPrefix("/"))
? location.pathname.slice(withPrefix("/").length)
: location.pathname
navigate(url(pathname, newParams))
},
[]
)
Expand Down
5 changes: 5 additions & 0 deletions src/components/Layout/Navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React, { useCallback, useMemo } from "react"

import { withPrefix } from "gatsby"

import { useLocation } from "@gatsbyjs/reach-router"
import useAuthContext from "decentraland-gatsby/dist/context/Auth/useAuthContext"
import useTrackContext from "decentraland-gatsby/dist/context/Track/useTrackContext"
Expand Down Expand Up @@ -102,6 +104,9 @@ export default function Navigation(props: NavigationProps) {

debounceTrack(e.target.value)
let target = location.pathname
if (target.startsWith(withPrefix("/"))) {
target = target.slice(withPrefix("/").length)
}
const search = newParams.toString()
if (search) {
target += "?" + search
Expand Down
2 changes: 1 addition & 1 deletion src/config/dev.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"GATSBY_CHAIN_ID": "1,137",
"GATSBY_DECENTRALAND_URL": "https://play.decentraland.org",
"GATSBY_EVENTS_URL": "https://events.decentraland.zone/api",
"GATSBY_EVENTS_API_URL": "https://events.decentraland.zone/api",
"GATSBY_EVENTS_BASE_URL": "https://decentraland.zone/events",
"GATSBY_LAND_URL": "https://api.decentraland.org",
"GATSBY_PROFILE_URL": "https://peer.decentraland.org",
Expand Down
2 changes: 1 addition & 1 deletion src/config/prod.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"GATSBY_CHAIN_ID": "1,137",
"GATSBY_DECENTRALAND_URL": "https://play.decentraland.org",
"GATSBY_EVENTS_URL": "https://events.decentraland.org/api",
"GATSBY_EVENTS_API_URL": "https://events.decentraland.org/api",
"GATSBY_EVENTS_BASE_URL": "https://events.decentraland.org",
"GATSBY_LAND_URL": "https://api.decentraland.org",
"GATSBY_PROFILE_URL": "https://peer.decentraland.org",
Expand Down
11 changes: 8 additions & 3 deletions src/entities/Event/utils.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { withPrefix } from "gatsby"

import Time from "decentraland-gatsby/dist/utils/date/Time"
import env from "decentraland-gatsby/dist/utils/env"
import padStart from "lodash/padStart"
Expand All @@ -20,7 +22,10 @@ const DECENTRALAND_URL = env(
"DECENTRALAND_URL",
"https://play.decentraland.org"
)
const EVENTS_URL = env("EVENTS_URL", "https://events.decentraland.org/api")
const EVENTS_BASE_URL = env(
"EVENTS_BASE_URL",
"https://events.decentraland.org"
)
const PROFILE_SITE_URL = env(
"PROFILE_SITE_URL",
"https://profile.decentraland.org"
Expand All @@ -33,8 +38,8 @@ export function profileSiteUrl(address: string) {
}

export function siteUrl(pathname = "") {
const target = new URL(EVENTS_URL)
target.pathname = pathname
const target = new URL(EVENTS_BASE_URL)
target.pathname = withPrefix(pathname)
return target
}

Expand Down
5 changes: 1 addition & 4 deletions src/modules/locations.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import API from "decentraland-gatsby/dist/utils/api/API"
import env from "decentraland-gatsby/dist/utils/env"

import { EventType } from "../entities/Event/types"
import {
Expand All @@ -9,8 +8,6 @@ import {
} from "../entities/Event/utils"
import { ALL_EVENT_CATEGORY } from "../entities/EventCategory/types"

const BASE_URL = env("BASE_URL", "/")

export enum EventView {
Attendees = "attendees",
}
Expand Down Expand Up @@ -90,7 +87,7 @@ export function url(
path: string,
query?: Record<string, string> | URLSearchParams
) {
return API.url(BASE_URL, path, query)
return API.url("", path, query)
}

export default {
Expand Down
Loading