form-craft-package 1.7.6-dev.0 → 1.7.7-dev.0
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/.env.development
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
VITE_API_BASE_URL=https://formcraftmaster-backend-
|
|
1
|
+
VITE_API_BASE_URL=https://formcraftmaster-backend-dev-f8egf2fcfhhahuhr.centralus-01.azurewebsites.net
|
|
2
2
|
VITE_LOG_LEVEL=debug
|
|
3
3
|
VITE_COOKIE_DOMAIN=localhost
|
|
4
4
|
VITE_ENV=development
|
package/.env.staging
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
VITE_API_BASE_URL=https://formcraftmaster-backend-
|
|
1
|
+
VITE_API_BASE_URL=https://formcraftmaster-backend-dev-f8egf2fcfhhahuhr.centralus-01.azurewebsites.net
|
|
2
2
|
VITE_LOG_LEVEL=debug
|
|
3
3
|
VITE_COOKIE_DOMAIN=localhost
|
|
4
4
|
VITE_ENV=staging
|
package/package.json
CHANGED
package/src/enums/form.enum.ts
CHANGED
package/src/enums/index.ts
CHANGED
|
@@ -55,7 +55,8 @@ export enum AlignTypeEnum {
|
|
|
55
55
|
export * from './companies'
|
|
56
56
|
export enum LOCAL_STORAGE_KEYS_ENUM {
|
|
57
57
|
DynamicForms = '38be231fe41c169037ed04c267ebe070',
|
|
58
|
-
Domain = '6a6cb9bc5739ce27347f6311472e0276'
|
|
58
|
+
Domain = '6a6cb9bc5739ce27347f6311472e0276',
|
|
59
|
+
Config = '0db535f06ff882031118cc63ae7d5395'
|
|
59
60
|
}
|
|
60
61
|
export enum CountryEnum {
|
|
61
62
|
US = 'us',
|
|
@@ -17,12 +17,15 @@ export const useCompanyConfig = (): {
|
|
|
17
17
|
const [loading, setLoading] = useState<boolean>(true)
|
|
18
18
|
const [error, setError] = useState<string | null>(null)
|
|
19
19
|
|
|
20
|
-
// Get domain once, safely
|
|
21
20
|
useEffect(() => {
|
|
22
21
|
const storedDomain = localStorage.getItem(LOCAL_STORAGE_KEYS_ENUM.Domain)
|
|
23
22
|
const params = new URLSearchParams(window.location.search)
|
|
24
23
|
const paramDomain = params.get('domain')
|
|
25
|
-
const isLocalhost = [
|
|
24
|
+
const isLocalhost = [
|
|
25
|
+
'localhost',
|
|
26
|
+
'127.0.0.1',
|
|
27
|
+
'formcraft-frontend-dev-abegene0cmb5acfk.centralus-01.azurewebsites.net',
|
|
28
|
+
].some((domain) => window.location.hostname.includes(domain))
|
|
26
29
|
|
|
27
30
|
let resolvedDomain = storedDomain
|
|
28
31
|
|
|
@@ -30,6 +33,8 @@ export const useCompanyConfig = (): {
|
|
|
30
33
|
resolvedDomain = paramDomain
|
|
31
34
|
} else if (!storedDomain && paramDomain) {
|
|
32
35
|
resolvedDomain = paramDomain
|
|
36
|
+
} else if (!isLocalhost && !storedDomain && !paramDomain) {
|
|
37
|
+
resolvedDomain = window.location.hostname
|
|
33
38
|
}
|
|
34
39
|
|
|
35
40
|
if (!resolvedDomain) {
|
|
@@ -49,14 +54,18 @@ export const useCompanyConfig = (): {
|
|
|
49
54
|
try {
|
|
50
55
|
const response = await client.get<ICompanyConfig>(`/api/company/${currentDomain}/configpublic`)
|
|
51
56
|
if (response.status === 200 && Object.keys(response.data).length > 0) {
|
|
57
|
+
localStorage.setItem(LOCAL_STORAGE_KEYS_ENUM.Config, JSON.stringify(response.data))
|
|
52
58
|
setConfig(response.data)
|
|
59
|
+
setThemeConfig(response.data.siteLayout?.siteConfigs || DEFAULT_CONFIG.siteLayout.siteConfigs)
|
|
53
60
|
setError(null)
|
|
54
61
|
} else {
|
|
55
62
|
throw new Error('Empty or invalid config received')
|
|
56
63
|
}
|
|
57
64
|
} catch (err) {
|
|
58
|
-
console.error('Error fetching company config:', err)
|
|
59
|
-
|
|
65
|
+
console.error('Error fetching company config, using default:', err)
|
|
66
|
+
setConfig(DEFAULT_CONFIG)
|
|
67
|
+
setThemeConfig(DEFAULT_CONFIG.siteLayout.siteConfigs)
|
|
68
|
+
setError('Failed to load company configuration. Using default config.')
|
|
60
69
|
} finally {
|
|
61
70
|
setLoading(false)
|
|
62
71
|
}
|
|
@@ -77,7 +77,7 @@ export const layoutTemplates = [
|
|
|
77
77
|
<div key={form.id} className="">
|
|
78
78
|
<Link
|
|
79
79
|
to={href}
|
|
80
|
-
target={form.customLink
|
|
80
|
+
target={form.customLink || form.newTab ? '_blank' : '_self'}
|
|
81
81
|
onClick={isParentMenu ? () => toggleMenu(form.id) : undefined}
|
|
82
82
|
style={{
|
|
83
83
|
width: `${navigationWidth - 25}px`,
|
|
@@ -281,7 +281,7 @@ export const layoutTemplates = [
|
|
|
281
281
|
<div key={form.id} className="relative group">
|
|
282
282
|
<Link
|
|
283
283
|
to={href}
|
|
284
|
-
target={form.customLink
|
|
284
|
+
target={form.customLink || form.newTab ? '_blank' : '_self'}
|
|
285
285
|
onClick={isParentMenu ? (e) => e.preventDefault() : undefined}
|
|
286
286
|
style={{
|
|
287
287
|
borderRadius: `${siteConfigs?.Link.borderRadius}px`,
|
|
@@ -484,7 +484,7 @@ export const layoutTemplates = [
|
|
|
484
484
|
<div key={form.id} className="menu-item">
|
|
485
485
|
<Link
|
|
486
486
|
to={href}
|
|
487
|
-
target={form.customLink
|
|
487
|
+
target={form.customLink || form.newTab ? '_blank' : '_self'}
|
|
488
488
|
onClick={isParentMenu ? () => toggleMenu(form.id) : undefined}
|
|
489
489
|
style={{
|
|
490
490
|
width: `${navigationWidth - 25}px`,
|