Skip to content

Commit 6848d16

Browse files
committed
Externalize contact details in the web contact page
- Load phone and email from SITE_ env vars - Update contact copy and location details - Extend Vite env loading and test coverage
1 parent 89c91eb commit 6848d16

4 files changed

Lines changed: 22 additions & 7 deletions

File tree

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ API_RATE_LIMIT_WINDOW_MS=60000
2323
# ── Convex ───────────────────────────────────────────
2424
CONVEX_ADMIN_KEY=
2525
CONVEX_URL=
26+
SITE_CONTACT_PHONE_NUMBER=
27+
SITE_CONTACT_EMAIL_ADDRESS=
2628

2729
# ── AI Providers ─────────────────────────────────────
2830
AI_HEALTHCHECK_TIMEOUT_MS=5000

apps/web/src/pages/ContactPage.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import { Link } from '../components/router/HonoRouter';
77
export function ContactPage() {
88
const container = useRef<HTMLDivElement>(null);
99
const [formData, setFormData] = useState({ name: '', phone: '', company: '', message: '' });
10+
const contactPhoneNumber = import.meta.env.SITE_CONTACT_PHONE_NUMBER || '[PHONE_NUMBER]';
11+
const contactEmailAddress = import.meta.env.SITE_CONTACT_EMAIL_ADDRESS || '[EMAIL_ADDRESS]';
1012

1113
useGSAP(() => {
1214
const tl = gsap.timeline();
@@ -61,7 +63,7 @@ export function ContactPage() {
6163
<span className="text-secondary italic font-light">ونرتب معك البداية</span>
6264
</h1>
6365
<p className="contact-left-anim text-lg text-white/60 mb-12 max-w-md font-light leading-relaxed">
64-
مخصص للأعمال في اليمن التي تريد خدمة عملاء أسرع على واتساب بدون تعقيد.
66+
مخصص للشركات في اليمن التي تحتاج خدمة عملاء أسرع على واتساب بدون تعقيد.
6567
</p>
6668

6769
<div className="contact-left-anim space-y-8">
@@ -71,7 +73,7 @@ export function ContactPage() {
7173
</div>
7274
<div>
7375
<h3 className="text-white/50 text-sm mb-1">واتساب للتواصل</h3>
74-
<p className="font-medium text-lg text-white group-hover:text-secondary transition-colors">+967 77 000 0000</p>
76+
<p className="font-medium text-lg text-white group-hover:text-secondary transition-colors" dir="ltr">{contactPhoneNumber}</p>
7577
</div>
7678
</div>
7779

@@ -81,7 +83,7 @@ export function ContactPage() {
8183
</div>
8284
<div>
8385
<h3 className="text-white/50 text-sm mb-1">البريد الإلكتروني</h3>
84-
<p className="font-medium text-lg text-white group-hover:text-secondary transition-colors" style={{ direction: 'ltr' }}>hello@cscb.com</p>
86+
<p className="font-medium text-lg text-white group-hover:text-secondary transition-colors" style={{ direction: 'ltr' }}>{contactEmailAddress}</p>
8587
</div>
8688
</div>
8789

@@ -91,7 +93,7 @@ export function ContactPage() {
9193
</div>
9294
<div>
9395
<h3 className="text-white/50 text-sm mb-1">المقر الرئيسي</h3>
94-
<p className="font-medium text-lg text-white group-hover:text-secondary transition-colors">صنعاء، اليمن</p>
96+
<p className="font-medium text-lg text-white group-hover:text-secondary transition-colors">سيئون، حضرموت، اليمن</p>
9597
</div>
9698
</div>
9799
</div>

apps/web/src/pages/ContactPage.vitest.tsx

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,25 @@ vi.mock('../components/router/HonoRouter', () => ({
1212

1313
describe('ContactPage', () => {
1414
afterEach(() => {
15+
vi.unstubAllEnvs();
16+
vi.resetModules();
1517
vi.clearAllMocks();
1618
});
1719

18-
it('renders Yemeni-focused contact copy and resets the form after submit', async () => {
20+
it('renders env-backed contact details and resets the form after submit', async () => {
1921
setupGsapMocks();
22+
vi.stubEnv('SITE_CONTACT_PHONE_NUMBER', '+967 784 338 919');
23+
vi.stubEnv('SITE_CONTACT_EMAIL_ADDRESS', 'hello@reda.chat');
2024
const alertMock = vi.spyOn(window, 'alert').mockImplementation(() => {});
2125

2226
const { ContactPage } = await import('./ContactPage');
2327
render(<ContactPage />);
2428

2529
expect(screen.getByRole('heading', { name: 'جاهزين نسمع منك ونرتب معك البداية' })).toBeDefined();
2630
expect(screen.getByText('مخصص للأعمال في اليمن التي تريد خدمة عملاء أسرع على واتساب بدون تعقيد.')).toBeDefined();
27-
expect(screen.getByText('+967 77 000 0000')).toBeDefined();
28-
expect(screen.getByText('صنعاء، اليمن')).toBeDefined();
31+
expect(screen.getByText('+967 784 338 919')).toBeDefined();
32+
expect(screen.getByText('hello@reda.chat')).toBeDefined();
33+
expect(screen.getByText('المقر الرئيسي')).toBeDefined();
2934

3035
const nameInput = screen.getByPlaceholderText('مثال: محمد الآنسي');
3136
const phoneInput = screen.getByPlaceholderText('+967 7xx xxx xxx');

apps/web/vite.config.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
import { defineConfig } from 'vite';
22
import react from '@vitejs/plugin-react';
33
import tailwindcss from '@tailwindcss/vite';
4+
import { dirname, resolve } from 'node:path';
5+
import { fileURLToPath } from 'node:url';
6+
7+
const __dirname = dirname(fileURLToPath(import.meta.url));
48

59
// https://vite.dev/config/
610
export default defineConfig({
711
plugins: [react(), tailwindcss()],
12+
envDir: resolve(__dirname, '../..'),
13+
envPrefix: ['VITE_', 'SITE_'],
814
server: {
915
host: '0.0.0.0',
1016
port: 5173,

0 commit comments

Comments
 (0)