Skip to content

Commit 7a63b56

Browse files
committed
feat: default configuration
1 parent 79de0ec commit 7a63b56

File tree

5 files changed

+11
-12
lines changed

5 files changed

+11
-12
lines changed

Dockerfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ FROM node:24-slim AS base
22

33
ENV PNPM_HOME="/pnpm"
44
ENV PATH="$PNPM_HOME:$PATH"
5+
ARG VITE_DEFAULT_CONFIGURATION="/maps"
56
RUN corepack enable
67

78
WORKDIR /app

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<body>
99
<div id="root"></div>
1010
<script>
11-
MAP_EDITOR_DISABLE_EDIT = true;
11+
DEFAULT_CONFIGURATION = '%VITE_DEFAULT_CONFIGURATION%';
1212
</script>
1313
<script type="module" src="/src/main.tsx"></script>
1414
</body>

src/App.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,12 @@ declare module '@tanstack/react-router' {
2929
}
3030
}
3131

32-
export interface AppProps {
33-
defaultConfig?: string;
34-
}
35-
36-
function App({ defaultConfig = window.DEFAULT_CONFIGURATION }: AppProps) {
32+
function App() {
3733
const actions = useUIActions();
3834

3935
useMemo(() => {
40-
if (defaultConfig) actions.setDefaultConfig(defaultConfig);
41-
}, [defaultConfig, actions]);
36+
if (window.DEFAULT_CONFIGURATION) actions.setDefaultConfig(window.DEFAULT_CONFIGURATION);
37+
}, [actions]);
4238

4339
return (
4440
<>

src/config.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export const fetchConfig = async (url: string) => {
6262

6363
export const mapConfigQueryOptions = (url: string) =>
6464
queryOptions({
65-
queryKey: ['map-config'],
65+
queryKey: ['map-config', url],
6666
queryFn: () => fetchConfig(url),
6767
});
6868

@@ -76,7 +76,7 @@ export const fetchStoreConfig = async (url: string) => {
7676

7777
export const storeConfigQueryOptions = (url: string) =>
7878
queryOptions({
79-
queryKey: ['map-store'],
79+
queryKey: ['map-store', url],
8080
queryFn: () => fetchStoreConfig(url),
8181
});
8282

@@ -132,6 +132,7 @@ export const LANGUAGES = [
132132

133133
export const DEFAULT_THEME = THEMES[0];
134134
export const DEFAULT_LANG = LANGUAGES[0].value;
135+
export const DEFAULT_STORE_CONFIG = '/maps';
135136

136137
export const defaultConfigBase = {
137138
id: '',

src/hooks/ui.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
import { create } from 'zustand';
22
import { devtools } from 'zustand/middleware';
33
import { immer } from 'zustand/middleware/immer';
4+
import { DEFAULT_STORE_CONFIG } from '../config';
45

56
interface UIState {
67
defaultConfig: string;
7-
ready?: boolean;
8+
ready: boolean;
89
}
910

1011
interface UIActions {
@@ -17,7 +18,7 @@ interface UIActions {
1718
export const useUIStore = create<UIState & UIActions>()(
1819
devtools(
1920
immer(set => ({
20-
defaultConfig: '/maps',
21+
defaultConfig: DEFAULT_STORE_CONFIG,
2122
ready: false,
2223
actions: {
2324
setDefaultConfig: path =>

0 commit comments

Comments
 (0)