diff --git a/apps/admin-ui/app/(drawer)/dashboard/index.tsx b/apps/admin-ui/app/(drawer)/dashboard/index.tsx index b1df2ea..582363b 100644 --- a/apps/admin-ui/app/(drawer)/dashboard/index.tsx +++ b/apps/admin-ui/app/(drawer)/dashboard/index.tsx @@ -75,7 +75,7 @@ export default function Dashboard() { const menuItems: MenuItem[] = [ { - title: 'Manage Orderss', + title: 'Manage Orders', icon: 'shopping-bag', description: 'View and manage customer orders', route: '/(drawer)/dashboard/manage-orders', diff --git a/apps/admin-ui/src/trpc-client.ts b/apps/admin-ui/src/trpc-client.ts index a3016f2..7322e40 100644 --- a/apps/admin-ui/src/trpc-client.ts +++ b/apps/admin-ui/src/trpc-client.ts @@ -1,7 +1,7 @@ import { createTRPCProxyClient, httpBatchLink, TRPCClientError } from '@trpc/client'; import { createTRPCReact } from '@trpc/react-query'; import { AppRouter } from '@backend/trpc/router' -import { BASE_API_URL } from 'common-ui'; +import { BASE_API_URL } from '@packages/shared'; import { getJWT } from '@/hooks/useJWT'; import { FORCE_LOGOUT_EVENT } from 'common-ui/src/lib/const-strs'; import { DeviceEventEmitter } from 'react-native'; diff --git a/apps/admin-web/src/lib/trpc-client.ts b/apps/admin-web/src/lib/trpc-client.ts index 96e47df..4747a63 100644 --- a/apps/admin-web/src/lib/trpc-client.ts +++ b/apps/admin-web/src/lib/trpc-client.ts @@ -3,11 +3,12 @@ import { createTRPCClient, httpBatchLink } from '@trpc/client' import type { AppRouter } from '@backend/trpc/router' import { getJWT } from '../hooks/useJWT' import { EventBus, FORCE_LOGOUT_EVENT } from './event-bus' +import { BASE_API_URL as DEFAULT_API_URL } from '@packages/shared' -// Same backend as admin-ui (BASE_API_URL from common-ui); overridable via env. +// Same backend as admin-ui; overridable via VITE_API_URL (set it to +// https://devapi.freshyo.in for dev builds — the shared default is production). export const BASE_API_URL = - // (import.meta.env?.VITE_API_URL as string | undefined) || 'https://worker.freshyo.in' - (import.meta.env?.VITE_API_URL as string | undefined) || 'https://devapi.freshyo.in' + (import.meta.env?.VITE_API_URL as string | undefined) || DEFAULT_API_URL export const trpc = createTRPCReact() diff --git a/apps/fallback-ui/src/constants.ts b/apps/fallback-ui/src/constants.ts index a7d4288..068155f 100644 --- a/apps/fallback-ui/src/constants.ts +++ b/apps/fallback-ui/src/constants.ts @@ -1,6 +1,7 @@ +import { BASE_API_URL } from '@packages/shared' + const webUiConstants = { - baseUrl: 'https://worker.freshyo.in/' - // baseUrl: '/' + baseUrl: `${BASE_API_URL}/` } diff --git a/apps/fallback-ui/vite.config.ts b/apps/fallback-ui/vite.config.ts index 78a2a00..3ca293f 100644 --- a/apps/fallback-ui/vite.config.ts +++ b/apps/fallback-ui/vite.config.ts @@ -9,6 +9,7 @@ export default defineConfig({ resolve: { alias: { '@': path.resolve(__dirname, 'src'), + '@packages/shared': path.resolve(__dirname, '../../packages/shared'), } }, server: { diff --git a/apps/superadmin-ui/src/lib/trpc-client.ts b/apps/superadmin-ui/src/lib/trpc-client.ts index 77990eb..68f011c 100644 --- a/apps/superadmin-ui/src/lib/trpc-client.ts +++ b/apps/superadmin-ui/src/lib/trpc-client.ts @@ -1,10 +1,11 @@ import { createTRPCReact } from '@trpc/react-query' import { createTRPCClient, httpBatchLink } from '@trpc/client' import type { AppRouter } from '@backend/trpc/router' +import { BASE_API_URL as DEFAULT_API_URL } from '@packages/shared' // const BASE_API_URL = 'http://192.168.100.126:8787' export const BASE_API_URL = - (import.meta.env?.VITE_API_URL as string | undefined) || 'https://worker.freshyo.in' + (import.meta.env?.VITE_API_URL as string | undefined) || DEFAULT_API_URL export const trpc = createTRPCReact() diff --git a/apps/user-ui/src/trpc-client.ts b/apps/user-ui/src/trpc-client.ts index 00d9493..a19d10e 100644 --- a/apps/user-ui/src/trpc-client.ts +++ b/apps/user-ui/src/trpc-client.ts @@ -1,7 +1,7 @@ import { createTRPCProxyClient, httpBatchLink } from "@trpc/client"; import { createTRPCReact } from "@trpc/react-query"; import { AppRouter } from "@backend/trpc/router"; -import { BASE_API_URL } from "common-ui"; +import { BASE_API_URL } from "@packages/shared"; import { getAuthToken } from "@/hooks/useJWT"; import { DeviceEventEmitter } from "react-native"; import { FORCE_LOGOUT_EVENT } from "common-ui/src/lib/const-strs"; diff --git a/apps/user-ui/tests/mocks/api.ts b/apps/user-ui/tests/mocks/api.ts index 35790f5..058a811 100644 --- a/apps/user-ui/tests/mocks/api.ts +++ b/apps/user-ui/tests/mocks/api.ts @@ -10,7 +10,7 @@ * silent empty render. * * The tRPC URL is matched on the procedure path rather than the host, because - * BASE_API_URL (packages/ui/index.ts) is a local address during development. + * BASE_API_URL (@packages/shared) is a local address during development. * `jest.mock('axios')` lives in tests/setup.ts so it is registered before any * app module imports axios. * diff --git a/apps/web-ui/src/lib/trpc-client.ts b/apps/web-ui/src/lib/trpc-client.ts index 1dd230e..5874f24 100644 --- a/apps/web-ui/src/lib/trpc-client.ts +++ b/apps/web-ui/src/lib/trpc-client.ts @@ -1,10 +1,11 @@ import { createTRPCReact } from '@trpc/react-query' import { createTRPCClient, httpBatchLink } from '@trpc/client' import type { AppRouter } from '@backend/trpc/router' +import { BASE_API_URL as DEFAULT_API_URL } from '@packages/shared' // const BASE_API_URL = 'http://192.168.100.111:8787' export const BASE_API_URL = - (import.meta.env?.VITE_API_URL as string | undefined) || 'https://worker.freshyo.in' + (import.meta.env?.VITE_API_URL as string | undefined) || DEFAULT_API_URL export const trpc = createTRPCReact() diff --git a/change-log.txt b/change-log.txt index f07e7a9..4cdd24a 100644 --- a/change-log.txt +++ b/change-log.txt @@ -3586,3 +3586,27 @@ set to false so these render only in superadmin-ui: apps/admin-ui/app/(drawer)/dashboard/customize-app/index.tsx — CONST_VISIBILITY: internalAppVersion: true -> false (superadmin-ui's src/routes/constants.tsx keeps it visible, unchanged.) + +[2026-10-02 00:16:36] refactor: move BASE_API_URL to @packages/shared so every UI uses one source. + +packages/ui (common-ui) is React Native specific; the API base URL does not belong +there. It now lives in the framework-agnostic shared package, and packages/ui no +longer exports it. + + - packages/shared/index.ts: export const BASE_API_URL = 'https://worker.freshyo.in'. + - packages/ui/index.ts: removed the local BASE_API_URL declaration + export. + - packages/ui/src/services/axios.ts: imports BASE_API_URL from '@packages/shared'. + - apps/user-ui/src/trpc-client.ts, apps/admin-ui/src/trpc-client.ts: import from + '@packages/shared' instead of 'common-ui'. + - apps/web-ui/src/lib/trpc-client.ts, apps/admin-web/..., apps/superadmin-ui/...: + default from '@packages/shared', still overridable via VITE_API_URL. + NOTE: admin-web's old devapi.freshyo.in default is gone; set + VITE_API_URL=https://devapi.freshyo.in for dev builds if still needed. + - apps/fallback-ui: vite alias for @packages/shared; baseUrl from the shared + constant. + - apps/user-ui/tests/mocks/api.ts: stale comment pointing at packages/ui. + +[2026-10-02 00:24:19] admin-ui: fix typo in dashboard menu title ('Manage Orderss' -> 'Manage Orders'). + +Pre-existing regression surfaced while running the suite after the BASE_API_URL +move; the dashboard-hub tests expect 'Manage Orders'. Unrelated to the URL change. diff --git a/packages/shared/index.ts b/packages/shared/index.ts index 27fd3b5..45cad8c 100644 --- a/packages/shared/index.ts +++ b/packages/shared/index.ts @@ -7,5 +7,11 @@ export const CACHE_FILENAMES = { banners: 'banners.json', } as const +/** + * Base origin of the backend API, shared by every UI (React Native and web). + * Framework-agnostic: apps may override it (e.g. VITE_API_URL) at build time. + */ +export const BASE_API_URL = 'https://worker.freshyo.in' + // Re-export all types from the types folder export * from './types' diff --git a/packages/ui/src/services/axios.ts b/packages/ui/src/services/axios.ts index 37a9fcc..82e7df1 100644 --- a/packages/ui/src/services/axios.ts +++ b/packages/ui/src/services/axios.ts @@ -4,7 +4,7 @@ import axiosParent from 'axios'; import { DeviceEventEmitter } from 'react-native' import { FORCE_LOGOUT_EVENT } from '../lib/const-strs'; import { getAuthToken } from '@/hooks/useJWT'; -import { BASE_API_URL } from '../../index'; +import { BASE_API_URL } from '@packages/shared'; // const API_BASE_URL = 'http://192.168.1.5:4000'; // Change to your API base URL // const API_BASE_URL = 'http://192.168.100.95:4000'; // Change to your API base URL