@eintrek/erp-shell 0.1.61 → 0.1.62

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1732,7 +1732,7 @@ function platformApiBase(app) {
1732
1732
  * This package's version, attached to help messages so the back office can
1733
1733
  * tell which shell a report came from. Keep in step with package.json.
1734
1734
  */
1735
- const SHELL_VERSION = "0.1.61";
1735
+ const SHELL_VERSION = "0.1.62";
1736
1736
 
1737
1737
  const HELP_APP_LABEL = {
1738
1738
  platform: "แพลตฟอร์ม",
@@ -2075,8 +2075,15 @@ function NavUser({ organization, avatarSrc, profileHref, selectOrganizationHref
2075
2075
  };
2076
2076
  const handleProfile = () => {
2077
2077
  setIsOpen(false);
2078
- if (profileHref)
2079
- router.push(profileHref);
2078
+ if (!profileHref)
2079
+ return;
2080
+ // Account settings live on Platform, so from any other app this is a
2081
+ // full page load, the same as the apps menu.
2082
+ if (isExternalHref(profileHref)) {
2083
+ window.location.assign(profileHref);
2084
+ return;
2085
+ }
2086
+ router.push(profileHref);
2080
2087
  };
2081
2088
  const handleSystemLink = (href) => {
2082
2089
  setIsOpen(false);
@@ -2143,7 +2150,7 @@ function NavUser({ organization, avatarSrc, profileHref, selectOrganizationHref
2143
2150
  { code: "en", label: "English" },
2144
2151
  { code: "zh", label: "中文" },
2145
2152
  { code: "ja", label: "日本語" },
2146
- ].map(({ code, label }) => (jsxRuntime.jsxs("button", { onClick: () => handleLanguageChange(code), className: "flex w-full items-center gap-3 px-3 py-2 text-sm text-sidebar-foreground hover:bg-sidebar-accent rounded-md transition-colors", children: [jsxRuntime.jsx("span", { className: "flex-1 text-left", children: label }), organization?.language === code && (jsxRuntime.jsx("div", { className: "h-2 w-2 rounded-full bg-primary" }))] }, code))) }))] })), profileHref && (jsxRuntime.jsxs("button", { onClick: handleProfile, className: "flex w-full items-center gap-3 px-3 py-2.5 text-sm text-sidebar-foreground hover:bg-sidebar-accent rounded-md transition-colors", children: [jsxRuntime.jsx(lucideReact.User, { className: "h-4 w-4" }), jsxRuntime.jsx("span", { className: "flex-1 text-left", children: "\u0E02\u0E49\u0E2D\u0E21\u0E39\u0E25\u0E2A\u0E48\u0E27\u0E19\u0E15\u0E31\u0E27" })] })), showSelectOrganization && (jsxRuntime.jsxs("button", { onClick: handleSelectOrganization, className: "flex w-full items-center gap-3 px-3 py-2.5 text-sm text-sidebar-foreground hover:bg-sidebar-accent rounded-md transition-colors", children: [jsxRuntime.jsx(lucideReact.Building2, { className: "h-4 w-4" }), jsxRuntime.jsx("span", { className: "flex-1 text-left", children: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E18\u0E38\u0E23\u0E01\u0E34\u0E08" })] })), visibleSystemLinks.length > 0 && (jsxRuntime.jsxs("div", { className: "relative", children: [jsxRuntime.jsxs("button", { onClick: () => {
2153
+ ].map(({ code, label }) => (jsxRuntime.jsxs("button", { onClick: () => handleLanguageChange(code), className: "flex w-full items-center gap-3 px-3 py-2 text-sm text-sidebar-foreground hover:bg-sidebar-accent rounded-md transition-colors", children: [jsxRuntime.jsx("span", { className: "flex-1 text-left", children: label }), organization?.language === code && (jsxRuntime.jsx("div", { className: "h-2 w-2 rounded-full bg-primary" }))] }, code))) }))] })), profileHref && (jsxRuntime.jsxs("button", { onClick: handleProfile, className: "flex w-full items-center gap-3 px-3 py-2.5 text-sm text-sidebar-foreground hover:bg-sidebar-accent rounded-md transition-colors", children: [jsxRuntime.jsx(lucideReact.UserCog, { className: "h-4 w-4" }), jsxRuntime.jsx("span", { className: "flex-1 text-left", children: "\u0E15\u0E31\u0E49\u0E07\u0E04\u0E48\u0E32\u0E1A\u0E31\u0E0D\u0E0A\u0E35" })] })), showSelectOrganization && (jsxRuntime.jsxs("button", { onClick: handleSelectOrganization, className: "flex w-full items-center gap-3 px-3 py-2.5 text-sm text-sidebar-foreground hover:bg-sidebar-accent rounded-md transition-colors", children: [jsxRuntime.jsx(lucideReact.Building2, { className: "h-4 w-4" }), jsxRuntime.jsx("span", { className: "flex-1 text-left", children: "\u0E40\u0E25\u0E37\u0E2D\u0E01\u0E18\u0E38\u0E23\u0E01\u0E34\u0E08" })] })), visibleSystemLinks.length > 0 && (jsxRuntime.jsxs("div", { className: "relative", children: [jsxRuntime.jsxs("button", { onClick: () => {
2147
2154
  setShowAppsMenu(!showAppsMenu);
2148
2155
  setShowThemeMenu(false);
2149
2156
  setShowLanguageMenu(false);
@@ -2223,6 +2230,32 @@ function hasPlanFeature(features, feature) {
2223
2230
  return false;
2224
2231
  }
2225
2232
 
2233
+ /**
2234
+ * Where Platform lives, and the pages every app sends people to on it.
2235
+ *
2236
+ * Personal settings — profile, password, signature, LINE — exist once, on
2237
+ * Platform. Every other app links there instead of keeping its own copy.
2238
+ *
2239
+ * Plain .ts (no JSX) so node --test can import it; app-registry.tsx reads the
2240
+ * base from here too, so the app switcher and the account link never disagree.
2241
+ */
2242
+ const DEFAULT_PLATFORM_URL = "https://platform.antniti.com";
2243
+ /** Read per call: Next inlines NEXT_PUBLIC_* at the consuming app's build. */
2244
+ function platformBaseUrl() {
2245
+ return (process.env.NEXT_PUBLIC_PLATFORM_URL || DEFAULT_PLATFORM_URL).replace(/\/+$/, "");
2246
+ }
2247
+ /**
2248
+ * ตั้งค่าบัญชี for an organisation: `/{code}/account/settings` on Platform.
2249
+ * Undefined without an organisation code — there is no page to open then.
2250
+ */
2251
+ function accountSettingsHref(orgCode, { activeApp } = {}) {
2252
+ const code = orgCode?.trim();
2253
+ if (!code)
2254
+ return undefined;
2255
+ const path = `/${encodeURIComponent(code)}/account/settings`;
2256
+ return activeApp === "platform" ? path : `${platformBaseUrl()}${path}`;
2257
+ }
2258
+
2226
2259
  function normaliseBase(value, fallback) {
2227
2260
  return (value ?? fallback).replace(/\/$/, "");
2228
2261
  }
@@ -2239,7 +2272,7 @@ const APPS = [
2239
2272
  label: "แพลตฟอร์ม",
2240
2273
  icon: jsxRuntime.jsx(lucideReact.Building2, { className: "h-4 w-4 shrink-0" }),
2241
2274
  features: null,
2242
- baseUrl: () => normaliseBase(process.env.NEXT_PUBLIC_PLATFORM_URL, "https://platform.antniti.com"),
2275
+ baseUrl: platformBaseUrl,
2243
2276
  },
2244
2277
  {
2245
2278
  id: "accounx",
@@ -4329,6 +4362,7 @@ exports.WITHOUT_ORGANIZATION_FLAG = WITHOUT_ORGANIZATION_FLAG;
4329
4362
  exports.WORKSPACE_HEADER_VARS = WORKSPACE_HEADER_VARS;
4330
4363
  exports.WORKSPACE_LIGHT_HEADER_VARS = WORKSPACE_LIGHT_HEADER_VARS;
4331
4364
  exports.WorkspaceBrand = WorkspaceBrand;
4365
+ exports.accountSettingsHref = accountSettingsHref;
4332
4366
  exports.axiosInstance = instance;
4333
4367
  exports.buildSystemLinks = buildSystemLinks;
4334
4368
  exports.buildUrlWithCode = buildUrlWithCode;
@@ -4363,6 +4397,7 @@ exports.normalizePathnameForPermissionRules = normalizePathnameForPermissionRule
4363
4397
  exports.openHelp = openHelp;
4364
4398
  exports.organizationScopedQueryHash = organizationScopedQueryHash;
4365
4399
  exports.parseMyRoles = parseMyRoles;
4400
+ exports.platformBaseUrl = platformBaseUrl;
4366
4401
  exports.resolveActiveNav = resolveActiveNav;
4367
4402
  exports.resolveSidebarNav = resolveSidebarNav;
4368
4403
  exports.resolveStaleOrganization = resolveStaleOrganization;