Skip to content

Commit 2c0da31

Browse files
committed
fix remaining wrong links due to domain change
1 parent b277016 commit 2c0da31

File tree

5 files changed

+21
-13
lines changed

5 files changed

+21
-13
lines changed

.changeset/silent-seals-occur.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@fleek-platform/dashboard": patch
3+
---
4+
5+
fix remaining links

src/pages/_app.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import { AppProps } from '@/types/App';
1111
import { useRouter } from '@/hooks/useRouter';
1212
import { usePathname } from 'next/navigation';
1313
import { isServerSide } from '@/utils/isServerSide';
14-
import { getQueryParamsToObj } from '@/utils/url';
14+
import { getDashboardUrl, getQueryParamsToObj } from '@/utils/url';
1515
// TODO: Rename the util as `cookies` (plural)
1616
import { cookies } from '@/utils/cookie';
1717
import HomePage from '@/pages/LandingPage';
@@ -21,7 +21,8 @@ import { setDefined, getDefined, DEFINED_OVERRIDES_FILENAME } from '../defined';
2121
import { getWebsiteUrl } from '@/utils/url';
2222

2323
const loadConfig = async (): Promise<boolean> => {
24-
const overridesJson = `${getDefined('NEXT_PUBLIC_DASHBOARD_BASE_PATH')}/${DEFINED_OVERRIDES_FILENAME}`;
24+
const dashboardBasePath = getDashboardUrl();
25+
const overridesJson = `${dashboardBasePath}/${DEFINED_OVERRIDES_FILENAME}`;
2526

2627
try {
2728
const response = await fetch(overridesJson);

src/providers/AuthProvider.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import { usePathname } from 'next/navigation';
1414
import { useCookies } from './CookiesProvider';
1515
import { useRouter } from 'next/router';
1616

17-
import { getWebsiteUrl } from '@/utils/url';
17+
import { getDashboardUrl, getWebsiteUrl } from '@/utils/url';
1818

1919
import { getDefined } from '@/defined';
2020

@@ -107,6 +107,7 @@ export const AuthProvider: React.FC<React.PropsWithChildren<{}>> = ({
107107
);
108108

109109
useEffect(() => {
110+
const dashboardBasePath = getDashboardUrl();
110111
if (
111112
!cookies.values.accessToken ||
112113
!cookies.values.authToken ||
@@ -125,7 +126,7 @@ export const AuthProvider: React.FC<React.PropsWithChildren<{}>> = ({
125126
if (pathname === routes.home()) {
126127
// TODO: Create an utility, include related unit test
127128
// use utils to form URL correctly/conventions
128-
window.location.href = `${getDefined('NEXT_PUBLIC_DASHBOARD_BASE_PATH')}${routes.project.home({ projectId: cookies.values.projectId })}/${window.location.search}`;
129+
window.location.href = `${dashboardBasePath}${routes.project.home({ projectId: cookies.values.projectId })}/${window.location.search}`;
129130
}
130131
}, [cookies.values.accessToken, router, logout, pathname]);
131132

src/ui/ftw/EmptyState/EmptyState.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { CodeBlock } from '../CodeBlock/CodeBlock';
88
import { Text } from '../Text/Text';
99
import { emptyStateIllustrations, Section } from './emptyStateIllustrations';
1010

11-
import { getDefined } from '@/defined';
11+
import { getDashboardUrl } from '@/utils/url';
1212

1313
type ImageProps = ComponentProps<typeof ImageComponent> & {
1414
section: Section;
@@ -17,8 +17,9 @@ type ImageProps = ComponentProps<typeof ImageComponent> & {
1717
const Image: React.FC<ImageProps> = ({ section, ...props }) => {
1818
const { resolvedTheme } = useTheme();
1919
const theme = resolvedTheme === 'dark' ? 'dark' : 'light';
20-
const src = getDefined('NEXT_PUBLIC_DASHBOARD_BASE_PATH')
21-
? `${getDefined('NEXT_PUBLIC_DASHBOARD_BASE_PATH')}/${emptyStateIllustrations[theme][section]}`
20+
const dashboardBasePath = getDashboardUrl();
21+
const src = dashboardBasePath
22+
? `${dashboardBasePath}/${emptyStateIllustrations[theme][section]}`
2223
: emptyStateIllustrations[theme][section];
2324

2425
return (

src/utils/paths.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
import { getDefined } from '@/defined';
2+
import { getDashboardUrl } from './url';
23

34
const normalizePathname = (pathname: string) => {
45
const [path, query] = pathname.split('?');
56

67
const segments = path.split('/').filter(Boolean);
78

89
const normalizedPath = pathname.startsWith('/')
9-
? '/' + segments.join('/')
10+
? `/${segments.join('/')}`
1011
: segments.join('/');
1112

1213
return query ? `${normalizedPath}?${query}` : normalizedPath;
1314
};
1415

1516
export const joinBase = (pathname: string) => {
16-
if (!getDefined('NEXT_PUBLIC_DASHBOARD_BASE_PATH')) {
17+
const dashboardBasePath = getDashboardUrl();
18+
if (!dashboardBasePath) {
1719
return normalizePathname(pathname);
1820
}
1921

20-
const normalizedBase = normalizePathname(
21-
getDefined('NEXT_PUBLIC_DASHBOARD_BASE_PATH'),
22-
);
22+
const normalizedBase = normalizePathname(dashboardBasePath);
2323
const normalizedPath = normalizePathname(pathname);
2424

2525
const pathWithoutLeadingSlash = normalizedPath.startsWith('/')
@@ -28,6 +28,6 @@ export const joinBase = (pathname: string) => {
2828

2929
return (
3030
normalizedBase +
31-
(pathWithoutLeadingSlash ? '/' + pathWithoutLeadingSlash : '')
31+
(pathWithoutLeadingSlash ? `/${pathWithoutLeadingSlash}` : '')
3232
);
3333
};

0 commit comments

Comments
 (0)