sitepaige-mcp-server 0.7.14 → 1.0.2
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/README.md +94 -42
- package/components/form.tsx +133 -6
- package/components/login.tsx +173 -21
- package/components/menu.tsx +128 -3
- package/components/testimonial.tsx +1 -1
- package/defaultapp/api/Auth/route.ts +105 -3
- package/defaultapp/api/Auth/signup/route.ts +143 -0
- package/defaultapp/api/Auth/verify-email/route.ts +98 -0
- package/defaultapp/db-password-auth.ts +325 -0
- package/defaultapp/storage/email.ts +162 -0
- package/dist/blueprintWriter.js +15 -1
- package/dist/blueprintWriter.js.map +1 -1
- package/dist/components/form.tsx +133 -6
- package/dist/components/login.tsx +173 -21
- package/dist/components/menu.tsx +128 -3
- package/dist/components/testimonial.tsx +1 -1
- package/dist/defaultapp/api/Auth/route.ts +105 -3
- package/dist/defaultapp/api/Auth/signup/route.ts +143 -0
- package/dist/defaultapp/api/Auth/verify-email/route.ts +98 -0
- package/dist/defaultapp/db-password-auth.ts +325 -0
- package/dist/defaultapp/storage/email.ts +162 -0
- package/dist/generators/apis.js +1 -0
- package/dist/generators/apis.js.map +1 -1
- package/dist/generators/defaultapp.js +2 -2
- package/dist/generators/defaultapp.js.map +1 -1
- package/dist/generators/env-example-template.txt +27 -0
- package/dist/generators/images.js +38 -13
- package/dist/generators/images.js.map +1 -1
- package/dist/generators/pages.js +1 -1
- package/dist/generators/pages.js.map +1 -1
- package/dist/generators/sql.js +19 -0
- package/dist/generators/sql.js.map +1 -1
- package/dist/generators/views.js +17 -2
- package/dist/generators/views.js.map +1 -1
- package/dist/index.js +15 -116
- package/dist/index.js.map +1 -1
- package/dist/sitepaige.js +20 -127
- package/dist/sitepaige.js.map +1 -1
- package/manifest.json +5 -24
- package/package.json +3 -2
package/dist/components/form.tsx
CHANGED
|
@@ -9,6 +9,133 @@ interface RFormProps {
|
|
|
9
9
|
design: Design;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
// Translation function for form submit text
|
|
13
|
+
const getFormTranslation = (key: string, websiteLanguage: string) => {
|
|
14
|
+
const translations: Record<string, Record<string, string>> = {
|
|
15
|
+
'Submit': {
|
|
16
|
+
'English': 'Submit',
|
|
17
|
+
'Spanish': 'Enviar',
|
|
18
|
+
'French': 'Soumettre',
|
|
19
|
+
'German': 'Absenden',
|
|
20
|
+
'Portuguese': 'Enviar',
|
|
21
|
+
'Italian': 'Invia',
|
|
22
|
+
'Dutch': 'Versturen',
|
|
23
|
+
'Chinese': '提交',
|
|
24
|
+
'Japanese': '送信',
|
|
25
|
+
'Korean': '제출',
|
|
26
|
+
'Russian': 'Отправить',
|
|
27
|
+
'Arabic': 'إرسال',
|
|
28
|
+
'Hindi': 'सबमिट करें'
|
|
29
|
+
},
|
|
30
|
+
'Submitting...': {
|
|
31
|
+
'English': 'Submitting...',
|
|
32
|
+
'Spanish': 'Enviando...',
|
|
33
|
+
'French': 'Envoi en cours...',
|
|
34
|
+
'German': 'Wird gesendet...',
|
|
35
|
+
'Portuguese': 'Enviando...',
|
|
36
|
+
'Italian': 'Invio in corso...',
|
|
37
|
+
'Dutch': 'Bezig met versturen...',
|
|
38
|
+
'Chinese': '提交中...',
|
|
39
|
+
'Japanese': '送信中...',
|
|
40
|
+
'Korean': '제출 중...',
|
|
41
|
+
'Russian': 'Отправка...',
|
|
42
|
+
'Arabic': 'جاري الإرسال...',
|
|
43
|
+
'Hindi': 'सबमिट हो रहा है...'
|
|
44
|
+
},
|
|
45
|
+
'Submit Another Response': {
|
|
46
|
+
'English': 'Submit Another Response',
|
|
47
|
+
'Spanish': 'Enviar otra respuesta',
|
|
48
|
+
'French': 'Soumettre une autre réponse',
|
|
49
|
+
'German': 'Weitere Antwort senden',
|
|
50
|
+
'Portuguese': 'Enviar outra resposta',
|
|
51
|
+
'Italian': 'Invia un\'altra risposta',
|
|
52
|
+
'Dutch': 'Nog een reactie versturen',
|
|
53
|
+
'Chinese': '提交另一个回复',
|
|
54
|
+
'Japanese': '別の回答を送信',
|
|
55
|
+
'Korean': '다른 응답 제출',
|
|
56
|
+
'Russian': 'Отправить еще один ответ',
|
|
57
|
+
'Arabic': 'إرسال رد آخر',
|
|
58
|
+
'Hindi': 'एक और प्रतिक्रिया सबमिट करें'
|
|
59
|
+
},
|
|
60
|
+
'Thank You!': {
|
|
61
|
+
'English': 'Thank You!',
|
|
62
|
+
'Spanish': '¡Gracias!',
|
|
63
|
+
'French': 'Merci!',
|
|
64
|
+
'German': 'Vielen Dank!',
|
|
65
|
+
'Portuguese': 'Obrigado!',
|
|
66
|
+
'Italian': 'Grazie!',
|
|
67
|
+
'Dutch': 'Bedankt!',
|
|
68
|
+
'Chinese': '谢谢!',
|
|
69
|
+
'Japanese': 'ありがとうございます!',
|
|
70
|
+
'Korean': '감사합니다!',
|
|
71
|
+
'Russian': 'Спасибо!',
|
|
72
|
+
'Arabic': 'شكراً لك!',
|
|
73
|
+
'Hindi': 'धन्यवाद!'
|
|
74
|
+
},
|
|
75
|
+
'Your form has been submitted successfully. We\'ll get back to you soon.': {
|
|
76
|
+
'English': 'Your form has been submitted successfully. We\'ll get back to you soon.',
|
|
77
|
+
'Spanish': 'Tu formulario ha sido enviado exitosamente. Nos pondremos en contacto contigo pronto.',
|
|
78
|
+
'French': 'Votre formulaire a été soumis avec succès. Nous vous contacterons bientôt.',
|
|
79
|
+
'German': 'Ihr Formular wurde erfolgreich gesendet. Wir werden uns bald bei Ihnen melden.',
|
|
80
|
+
'Portuguese': 'Seu formulário foi enviado com sucesso. Entraremos em contato em breve.',
|
|
81
|
+
'Italian': 'Il tuo modulo è stato inviato con successo. Ti contatteremo presto.',
|
|
82
|
+
'Dutch': 'Uw formulier is succesvol verzonden. We nemen binnenkort contact met u op.',
|
|
83
|
+
'Chinese': '您的表单已成功提交。我们会尽快与您联系。',
|
|
84
|
+
'Japanese': 'フォームが正常に送信されました。近日中にご連絡いたします。',
|
|
85
|
+
'Korean': '양식이 성공적으로 제출되었습니다. 곧 연락드리겠습니다.',
|
|
86
|
+
'Russian': 'Ваша форма успешно отправлена. Мы свяжемся с вами в ближайшее время.',
|
|
87
|
+
'Arabic': 'تم إرسال النموذج بنجاح. سنتواصل معك قريباً.',
|
|
88
|
+
'Hindi': 'आपका फॉर्म सफलतापूर्वक सबमिट किया गया है। हम जल्द ही आपसे संपर्क करेंगे।'
|
|
89
|
+
},
|
|
90
|
+
'Form secured by FormSubmit': {
|
|
91
|
+
'English': 'Form secured by FormSubmit',
|
|
92
|
+
'Spanish': 'Formulario protegido por FormSubmit',
|
|
93
|
+
'French': 'Formulaire sécurisé par FormSubmit',
|
|
94
|
+
'German': 'Formular gesichert durch FormSubmit',
|
|
95
|
+
'Portuguese': 'Formulário protegido por FormSubmit',
|
|
96
|
+
'Italian': 'Modulo protetto da FormSubmit',
|
|
97
|
+
'Dutch': 'Formulier beveiligd door FormSubmit',
|
|
98
|
+
'Chinese': '表单由FormSubmit保护',
|
|
99
|
+
'Japanese': 'FormSubmitによって保護されたフォーム',
|
|
100
|
+
'Korean': 'FormSubmit로 보호된 양식',
|
|
101
|
+
'Russian': 'Форма защищена FormSubmit',
|
|
102
|
+
'Arabic': 'النموذج محمي بواسطة FormSubmit',
|
|
103
|
+
'Hindi': 'फॉर्म FormSubmit द्वारा सुरक्षित'
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
// Determine which language to use
|
|
108
|
+
let language = 'English'; // Default
|
|
109
|
+
if (websiteLanguage) {
|
|
110
|
+
// Extract the main language from the input
|
|
111
|
+
const langMap: Record<string, string> = {
|
|
112
|
+
'English': 'English',
|
|
113
|
+
'Spanish': 'Spanish',
|
|
114
|
+
'French': 'French',
|
|
115
|
+
'German': 'German',
|
|
116
|
+
'Portuguese': 'Portuguese',
|
|
117
|
+
'Italian': 'Italian',
|
|
118
|
+
'Dutch': 'Dutch',
|
|
119
|
+
'Chinese': 'Chinese',
|
|
120
|
+
'Japanese': 'Japanese',
|
|
121
|
+
'Korean': 'Korean',
|
|
122
|
+
'Russian': 'Russian',
|
|
123
|
+
'Arabic': 'Arabic',
|
|
124
|
+
'Hindi': 'Hindi'
|
|
125
|
+
};
|
|
126
|
+
|
|
127
|
+
// Find the matching language
|
|
128
|
+
for (const [langKey, langValue] of Object.entries(langMap)) {
|
|
129
|
+
if (websiteLanguage.includes(langKey)) {
|
|
130
|
+
language = langValue;
|
|
131
|
+
break;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
return translations[key]?.[language] || key;
|
|
137
|
+
};
|
|
138
|
+
|
|
12
139
|
interface FormField {
|
|
13
140
|
id: string;
|
|
14
141
|
name: string;
|
|
@@ -85,9 +212,9 @@ export default function RForm({ name, custom_view_description, design }: RFormPr
|
|
|
85
212
|
d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"
|
|
86
213
|
/>
|
|
87
214
|
</svg>
|
|
88
|
-
<h3 className="text-2xl font-bold text-green-800 mb-2">Thank You
|
|
215
|
+
<h3 className="text-2xl font-bold text-green-800 mb-2">{getFormTranslation('Thank You!', design.websiteLanguage)}</h3>
|
|
89
216
|
<p className="text-green-700">
|
|
90
|
-
Your form has been submitted successfully. We'll get back to you soon.
|
|
217
|
+
{getFormTranslation('Your form has been submitted successfully. We\'ll get back to you soon.', design.websiteLanguage)}
|
|
91
218
|
</p>
|
|
92
219
|
<button
|
|
93
220
|
onClick={() => {
|
|
@@ -97,7 +224,7 @@ export default function RForm({ name, custom_view_description, design }: RFormPr
|
|
|
97
224
|
}}
|
|
98
225
|
className="mt-6 px-6 py-2 bg-green-600 text-white rounded-lg hover:bg-green-700 transition-colors"
|
|
99
226
|
>
|
|
100
|
-
Submit Another Response
|
|
227
|
+
{getFormTranslation('Submit Another Response', design.websiteLanguage)}
|
|
101
228
|
</button>
|
|
102
229
|
</div>
|
|
103
230
|
</div>
|
|
@@ -249,10 +376,10 @@ export default function RForm({ name, custom_view_description, design }: RFormPr
|
|
|
249
376
|
d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"
|
|
250
377
|
/>
|
|
251
378
|
</svg>
|
|
252
|
-
Submitting...
|
|
379
|
+
{getFormTranslation('Submitting...', design.websiteLanguage)}
|
|
253
380
|
</span>
|
|
254
381
|
) : (
|
|
255
|
-
'Submit'
|
|
382
|
+
getFormTranslation('Submit', design.websiteLanguage)
|
|
256
383
|
)}
|
|
257
384
|
</button>
|
|
258
385
|
</div>
|
|
@@ -260,7 +387,7 @@ export default function RForm({ name, custom_view_description, design }: RFormPr
|
|
|
260
387
|
|
|
261
388
|
{/* FormSubmit.co attribution (optional but nice to have) */}
|
|
262
389
|
<div className="mt-6 text-center text-xs text-gray-400">
|
|
263
|
-
<p>Form secured by FormSubmit</p>
|
|
390
|
+
<p>{getFormTranslation('Form secured by FormSubmit', design.websiteLanguage)}</p>
|
|
264
391
|
</div>
|
|
265
392
|
</div>
|
|
266
393
|
);
|
|
@@ -9,11 +9,17 @@ checked in the system build settings. It is safe to modify this file without it
|
|
|
9
9
|
import React, { useState } from 'react';
|
|
10
10
|
|
|
11
11
|
interface LoginProps {
|
|
12
|
-
providers: ('apple' | 'facebook' | 'github' | 'google')[];
|
|
12
|
+
providers: ('apple' | 'facebook' | 'github' | 'google' | 'username')[];
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
export default function Login({ providers }: LoginProps) {
|
|
16
16
|
const [error, setError] = useState<string | null>(null);
|
|
17
|
+
const [isSignup, setIsSignup] = useState(false);
|
|
18
|
+
const [email, setEmail] = useState('');
|
|
19
|
+
const [password, setPassword] = useState('');
|
|
20
|
+
const [confirmPassword, setConfirmPassword] = useState('');
|
|
21
|
+
const [isLoading, setIsLoading] = useState(false);
|
|
22
|
+
const [message, setMessage] = useState<{ type: 'success' | 'error'; text: string } | null>(null);
|
|
17
23
|
|
|
18
24
|
|
|
19
25
|
const handleProviderLogin = async (provider: string) => {
|
|
@@ -43,37 +49,183 @@ export default function Login({ providers }: LoginProps) {
|
|
|
43
49
|
|
|
44
50
|
};
|
|
45
51
|
|
|
52
|
+
const handleUsernamePasswordAuth = async (e: React.FormEvent) => {
|
|
53
|
+
e.preventDefault();
|
|
54
|
+
setError(null);
|
|
55
|
+
setMessage(null);
|
|
56
|
+
setIsLoading(true);
|
|
57
|
+
|
|
58
|
+
try {
|
|
59
|
+
if (isSignup) {
|
|
60
|
+
// Handle signup
|
|
61
|
+
if (password !== confirmPassword) {
|
|
62
|
+
setError('Passwords do not match');
|
|
63
|
+
setIsLoading(false);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const response = await fetch('/api/Auth/signup', {
|
|
68
|
+
method: 'POST',
|
|
69
|
+
headers: { 'Content-Type': 'application/json' },
|
|
70
|
+
body: JSON.stringify({ email, password })
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
const data = await response.json();
|
|
74
|
+
|
|
75
|
+
if (response.ok) {
|
|
76
|
+
setMessage({ type: 'success', text: 'Verification email sent! Please check your inbox.' });
|
|
77
|
+
setIsSignup(false);
|
|
78
|
+
setPassword('');
|
|
79
|
+
setConfirmPassword('');
|
|
80
|
+
} else {
|
|
81
|
+
setError(data.error || 'Signup failed');
|
|
82
|
+
}
|
|
83
|
+
} else {
|
|
84
|
+
// Handle login
|
|
85
|
+
const response = await fetch('/api/Auth', {
|
|
86
|
+
method: 'POST',
|
|
87
|
+
headers: { 'Content-Type': 'application/json' },
|
|
88
|
+
body: JSON.stringify({ email, password, provider: 'username' })
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
const data = await response.json();
|
|
92
|
+
|
|
93
|
+
if (response.ok) {
|
|
94
|
+
// Redirect to home or dashboard
|
|
95
|
+
window.location.href = '/';
|
|
96
|
+
} else {
|
|
97
|
+
setError(data.error || 'Login failed');
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
} catch (err) {
|
|
101
|
+
setError('An unexpected error occurred');
|
|
102
|
+
} finally {
|
|
103
|
+
setIsLoading(false);
|
|
104
|
+
}
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
const showUsernamePasswordForm = providers?.includes('username');
|
|
108
|
+
const oauthProviders = providers?.filter(p => p !== 'username') || [];
|
|
109
|
+
|
|
46
110
|
return (
|
|
47
111
|
<div className="flex flex-col items-center justify-center min-h-[500px] p-4">
|
|
48
112
|
<div className="w-full max-w-md space-y-8">
|
|
49
113
|
<div className="text-center">
|
|
50
|
-
<h2 className="text-3xl font-bold">Sign in to your account</h2>
|
|
114
|
+
<h2 className="text-3xl font-bold">{isSignup ? 'Create an account' : 'Sign in to your account'}</h2>
|
|
51
115
|
</div>
|
|
52
116
|
|
|
53
|
-
{(
|
|
54
|
-
<
|
|
55
|
-
<div className="
|
|
56
|
-
<div
|
|
57
|
-
<
|
|
117
|
+
{showUsernamePasswordForm && (
|
|
118
|
+
<form onSubmit={handleUsernamePasswordAuth} className="mt-8 space-y-6">
|
|
119
|
+
<div className="space-y-4">
|
|
120
|
+
<div>
|
|
121
|
+
<label htmlFor="email" className="block text-sm font-medium text-gray-700">
|
|
122
|
+
Email address
|
|
123
|
+
</label>
|
|
124
|
+
<input
|
|
125
|
+
id="email"
|
|
126
|
+
name="email"
|
|
127
|
+
type="email"
|
|
128
|
+
autoComplete="email"
|
|
129
|
+
required
|
|
130
|
+
value={email}
|
|
131
|
+
onChange={(e) => setEmail(e.target.value)}
|
|
132
|
+
className="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
|
|
133
|
+
/>
|
|
58
134
|
</div>
|
|
59
|
-
|
|
60
|
-
|
|
135
|
+
|
|
136
|
+
<div>
|
|
137
|
+
<label htmlFor="password" className="block text-sm font-medium text-gray-700">
|
|
138
|
+
Password
|
|
139
|
+
</label>
|
|
140
|
+
<input
|
|
141
|
+
id="password"
|
|
142
|
+
name="password"
|
|
143
|
+
type="password"
|
|
144
|
+
autoComplete={isSignup ? 'new-password' : 'current-password'}
|
|
145
|
+
required
|
|
146
|
+
value={password}
|
|
147
|
+
onChange={(e) => setPassword(e.target.value)}
|
|
148
|
+
className="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
|
|
149
|
+
/>
|
|
61
150
|
</div>
|
|
62
|
-
</div>
|
|
63
151
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
152
|
+
{isSignup && (
|
|
153
|
+
<div>
|
|
154
|
+
<label htmlFor="confirmPassword" className="block text-sm font-medium text-gray-700">
|
|
155
|
+
Confirm Password
|
|
156
|
+
</label>
|
|
157
|
+
<input
|
|
158
|
+
id="confirmPassword"
|
|
159
|
+
name="confirmPassword"
|
|
160
|
+
type="password"
|
|
161
|
+
autoComplete="new-password"
|
|
162
|
+
required
|
|
163
|
+
value={confirmPassword}
|
|
164
|
+
onChange={(e) => setConfirmPassword(e.target.value)}
|
|
165
|
+
className="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-indigo-500 focus:border-indigo-500"
|
|
166
|
+
/>
|
|
167
|
+
</div>
|
|
75
168
|
)}
|
|
76
169
|
</div>
|
|
170
|
+
|
|
171
|
+
<div>
|
|
172
|
+
<button
|
|
173
|
+
type="submit"
|
|
174
|
+
disabled={isLoading}
|
|
175
|
+
className="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-indigo-600 hover:bg-indigo-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-indigo-500 disabled:opacity-50"
|
|
176
|
+
>
|
|
177
|
+
{isLoading ? 'Processing...' : (isSignup ? 'Sign up' : 'Sign in')}
|
|
178
|
+
</button>
|
|
179
|
+
</div>
|
|
180
|
+
|
|
181
|
+
<div className="text-center">
|
|
182
|
+
<button
|
|
183
|
+
type="button"
|
|
184
|
+
onClick={() => {
|
|
185
|
+
setIsSignup(!isSignup);
|
|
186
|
+
setError(null);
|
|
187
|
+
setMessage(null);
|
|
188
|
+
}}
|
|
189
|
+
className="text-sm text-indigo-600 hover:text-indigo-500"
|
|
190
|
+
>
|
|
191
|
+
{isSignup ? 'Already have an account? Sign in' : "Don't have an account? Sign up"}
|
|
192
|
+
</button>
|
|
193
|
+
</div>
|
|
194
|
+
</form>
|
|
195
|
+
)}
|
|
196
|
+
|
|
197
|
+
{oauthProviders.length > 0 && (
|
|
198
|
+
<div className="mt-6">
|
|
199
|
+
{showUsernamePasswordForm && (
|
|
200
|
+
<>
|
|
201
|
+
<div className="relative">
|
|
202
|
+
<div className="absolute inset-0 flex items-center">
|
|
203
|
+
<div className="w-full border-t"></div>
|
|
204
|
+
</div>
|
|
205
|
+
<div className="relative flex justify-center text-sm">
|
|
206
|
+
<span className="px-2 bg-white text-gray-500">Or continue with</span>
|
|
207
|
+
</div>
|
|
208
|
+
</div>
|
|
209
|
+
</>
|
|
210
|
+
)}
|
|
211
|
+
|
|
212
|
+
<div className={`mt-6 grid grid-cols-${Math.min(oauthProviders.length, 2)} gap-3`}>
|
|
213
|
+
{oauthProviders.map(provider => (
|
|
214
|
+
<button
|
|
215
|
+
key={provider}
|
|
216
|
+
onClick={() => handleProviderLogin(provider)}
|
|
217
|
+
className="w-full flex justify-center py-3 px-4 border border-transparent rounded-md shadow-sm focus:outline-none focus:ring-2 focus:ring-offset-2 transition duration-150 classButtonRounding classButtonBackground classButtonFontType classButtonFontSize"
|
|
218
|
+
>
|
|
219
|
+
{provider}
|
|
220
|
+
</button>
|
|
221
|
+
))}
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
)}
|
|
225
|
+
|
|
226
|
+
{message && (
|
|
227
|
+
<div className={`mt-4 text-center ${message.type === 'success' ? 'text-green-600' : 'text-red-600'}`}>
|
|
228
|
+
{message.text}
|
|
77
229
|
</div>
|
|
78
230
|
)}
|
|
79
231
|
|
package/dist/components/menu.tsx
CHANGED
|
@@ -26,8 +26,10 @@ interface MenuItem {
|
|
|
26
26
|
page: string | null;
|
|
27
27
|
menu: string | null;
|
|
28
28
|
untouchable: boolean;
|
|
29
|
-
link_type?: 'page' | 'external';
|
|
29
|
+
link_type?: 'page' | 'external' | 'file';
|
|
30
30
|
external_url?: string | null;
|
|
31
|
+
file_id?: string | null;
|
|
32
|
+
file_name?: string | null;
|
|
31
33
|
hiddenOnDesktop?: boolean; // New field to hide item on desktop (shows in icon bar instead)
|
|
32
34
|
}
|
|
33
35
|
|
|
@@ -57,6 +59,8 @@ export default function Menu({ menu, onClick, pages = [] }: MenuProps) {
|
|
|
57
59
|
const [hoveredIndex, setHoveredIndex] = useState<number | null>(null);
|
|
58
60
|
const [mobileMenuOpen, setMobileMenuOpen] = useState(false);
|
|
59
61
|
const [isMobile, setIsMobile] = useState(false);
|
|
62
|
+
const [selectedPage, setSelectedPage] = useState<string | null>(null);
|
|
63
|
+
const [isPaigeLoading, setIsPaigeLoading] = useState(false);
|
|
60
64
|
|
|
61
65
|
// Handle case where menu is undefined/null
|
|
62
66
|
if (!menu) {
|
|
@@ -88,7 +92,8 @@ export default function Menu({ menu, onClick, pages = [] }: MenuProps) {
|
|
|
88
92
|
return () => window.removeEventListener('resize', checkMobile);
|
|
89
93
|
}, []);
|
|
90
94
|
|
|
91
|
-
const direction = menu.direction === 'vertical' ? 'vertical' :
|
|
95
|
+
const direction = menu.direction === 'vertical' ? 'vertical' :
|
|
96
|
+
menu.direction === 'tiled' ? 'tiled' : 'horizontal';
|
|
92
97
|
|
|
93
98
|
const renderMenuItem = (item: MenuItem, index: number) => {
|
|
94
99
|
const handleClick = () => {
|
|
@@ -187,8 +192,128 @@ export default function Menu({ menu, onClick, pages = [] }: MenuProps) {
|
|
|
187
192
|
);
|
|
188
193
|
};
|
|
189
194
|
|
|
195
|
+
// Render a tiled menu item
|
|
196
|
+
const renderTiledMenuItem = (item: MenuItem, index: number) => {
|
|
197
|
+
const isSelected = item.page === selectedPage;
|
|
198
|
+
|
|
199
|
+
// Helper function to get font size value
|
|
200
|
+
const getFontSizeValue = (sizeClass: string) => {
|
|
201
|
+
const sizeMap: Record<string, string> = {
|
|
202
|
+
'text-xs': '0.75rem',
|
|
203
|
+
'text-sm': '0.875rem',
|
|
204
|
+
'text-base': '1rem',
|
|
205
|
+
'text-lg': '1.125rem',
|
|
206
|
+
'text-xl': '1.25rem',
|
|
207
|
+
'text-2xl': '1.5rem',
|
|
208
|
+
'text-3xl': '1.875rem',
|
|
209
|
+
};
|
|
210
|
+
return sizeMap[sizeClass] || '1.25rem';
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const tileContent = (
|
|
214
|
+
<div className={`
|
|
215
|
+
p-6
|
|
216
|
+
bg-white
|
|
217
|
+
border-2
|
|
218
|
+
border-gray-300
|
|
219
|
+
rounded-lg
|
|
220
|
+
shadow-md
|
|
221
|
+
hover:shadow-lg
|
|
222
|
+
hover:border-blue-500
|
|
223
|
+
transition-all
|
|
224
|
+
duration-200
|
|
225
|
+
cursor-pointer
|
|
226
|
+
text-center
|
|
227
|
+
h-full
|
|
228
|
+
flex
|
|
229
|
+
flex-col
|
|
230
|
+
items-center
|
|
231
|
+
justify-center
|
|
232
|
+
${isSelected ? 'border-blue-600 bg-blue-50' : ''}
|
|
233
|
+
${isPaigeLoading ? 'opacity-50 cursor-not-allowed' : ''}
|
|
234
|
+
`}>
|
|
235
|
+
<h3
|
|
236
|
+
className={`${isSelected ? 'font-bold' : 'font-medium'} text-gray-800`}
|
|
237
|
+
style={{ fontFamily: menu.font, fontSize: getFontSizeValue(menu.fontSize || 'text-xl') }}
|
|
238
|
+
>
|
|
239
|
+
{item.name}
|
|
240
|
+
</h3>
|
|
241
|
+
</div>
|
|
242
|
+
);
|
|
243
|
+
|
|
244
|
+
if (item.link_type === 'external' && item.external_url) {
|
|
245
|
+
return (
|
|
246
|
+
<a
|
|
247
|
+
key={item.name}
|
|
248
|
+
href={item.external_url}
|
|
249
|
+
target="_blank"
|
|
250
|
+
rel="noopener noreferrer"
|
|
251
|
+
className="block h-full"
|
|
252
|
+
>
|
|
253
|
+
{tileContent}
|
|
254
|
+
</a>
|
|
255
|
+
);
|
|
256
|
+
} else if (item.link_type === 'file' && item.file_name) {
|
|
257
|
+
return (
|
|
258
|
+
<a
|
|
259
|
+
key={item.name}
|
|
260
|
+
href={`/library/files/${item.file_name}`}
|
|
261
|
+
target="_blank"
|
|
262
|
+
rel="noopener noreferrer"
|
|
263
|
+
className="block h-full"
|
|
264
|
+
>
|
|
265
|
+
{tileContent}
|
|
266
|
+
</a>
|
|
267
|
+
);
|
|
268
|
+
} else if (item.page) {
|
|
269
|
+
const page = pages.find(p => p.id === item.page);
|
|
270
|
+
let linkUrl = '#';
|
|
271
|
+
|
|
272
|
+
if (page) {
|
|
273
|
+
let urlPath = page.name
|
|
274
|
+
.replace(/[^a-zA-Z0-9\s]/g, '')
|
|
275
|
+
.trim()
|
|
276
|
+
.replace(/\s+/g, '_')
|
|
277
|
+
.toLowerCase();
|
|
278
|
+
linkUrl = urlPath === 'home' || urlPath === 'index' ? '/' : `/${urlPath}`;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return (
|
|
282
|
+
<Link
|
|
283
|
+
key={item.name}
|
|
284
|
+
href={linkUrl}
|
|
285
|
+
onClick={(e) => {
|
|
286
|
+
e.preventDefault();
|
|
287
|
+
if (isPaigeLoading) {
|
|
288
|
+
console.log('Navigation blocked: Paige is currently processing a request');
|
|
289
|
+
return;
|
|
290
|
+
}
|
|
291
|
+
setSelectedPage(item.page);
|
|
292
|
+
onClick?.();
|
|
293
|
+
}}
|
|
294
|
+
className="block h-full"
|
|
295
|
+
>
|
|
296
|
+
{tileContent}
|
|
297
|
+
</Link>
|
|
298
|
+
);
|
|
299
|
+
} else {
|
|
300
|
+
return (
|
|
301
|
+
<div key={item.name} className="block h-full">
|
|
302
|
+
{tileContent}
|
|
303
|
+
</div>
|
|
304
|
+
);
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
|
|
190
308
|
return (
|
|
191
309
|
<>
|
|
310
|
+
{/* Tiled menu layout */}
|
|
311
|
+
{direction === 'tiled' && (
|
|
312
|
+
<div className={`grid gap-4 ${isMobile ? 'grid-cols-1' : 'grid-cols-2 md:grid-cols-3 lg:grid-cols-4'}`}>
|
|
313
|
+
{menu.items?.map((item, index) => renderTiledMenuItem(item, index)) || []}
|
|
314
|
+
</div>
|
|
315
|
+
)}
|
|
316
|
+
|
|
192
317
|
{/* Hamburger menu for mobile horizontal menus */}
|
|
193
318
|
{isMobile && direction === 'horizontal' && (
|
|
194
319
|
<div className="relative">
|
|
@@ -211,7 +336,7 @@ export default function Menu({ menu, onClick, pages = [] }: MenuProps) {
|
|
|
211
336
|
)}
|
|
212
337
|
|
|
213
338
|
{/* Regular menu for desktop or vertical menus */}
|
|
214
|
-
{(!isMobile || direction === 'vertical') && (
|
|
339
|
+
{(!isMobile || direction === 'vertical') && direction !== 'tiled' && (
|
|
215
340
|
<nav className={`${direction === 'horizontal' ? 'space-x-4' : 'flex flex-col'} ${menu.align === 'Left' ? 'justify-start' : menu.align === 'Center' ? 'justify-center' : menu.align === 'Right' ? 'justify-end' : ''}`}>
|
|
216
341
|
{menu.items?.filter(item => !item.hiddenOnDesktop).map((item, index) => renderMenuItem(item, index)) || []}
|
|
217
342
|
</nav>
|
|
@@ -112,7 +112,7 @@ export default function RTestimonial({ name, custom_view_description, design }:
|
|
|
112
112
|
<div className="flex items-center">
|
|
113
113
|
{testimonial.photoId && (
|
|
114
114
|
<img
|
|
115
|
-
src={`/
|
|
115
|
+
src={`/images/${testimonial.photoId}.jpg`}
|
|
116
116
|
alt={testimonial.attribution}
|
|
117
117
|
className="w-12 h-12 rounded-full object-cover mr-4"
|
|
118
118
|
onError={(e) => {
|