diff --git a/next.config.mjs b/next.config.mjs index a6ce88f..ad0464a 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -23,6 +23,7 @@ const nextConfig = { // in the site silently fails to load. Serving them from the optimiser needs // a restrictive CSP on the image endpoint, because an SVG can carry script. dangerouslyAllowSVG: true, + contentDispositionType: 'inline', contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;", remotePatterns: [ { diff --git a/package.json b/package.json index 5d70c64..d68da34 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "scripts": { - "dev": "start cmd.exe /k \"C:/laragon/bin/mysql/mysql-8.0.30-winx64/bin/mysqld.exe\" && start cmd.exe /k \"cd C:/Users/p.aghaei/Desktop/Work/parsa/parsaaghayi/backend && php artisan serve\" && start cmd.exe /k \"cd C:/Users/p.aghaei/Desktop/Work/parsa/parsaaghayi/frontend && next dev --port 3001\"", + "dev": "next dev", "build": "next build", "start": "next start", "lint": "eslint .", diff --git a/specs/001-fix-audit-bugs/plan.md b/specs/001-fix-audit-bugs/plan.md new file mode 100644 index 0000000..118f102 --- /dev/null +++ b/specs/001-fix-audit-bugs/plan.md @@ -0,0 +1,44 @@ +# Implementation Plan: Audit Bug Fixes & Codebase Hardening + +## Phase -1: Pre-Implementation Constitutional Gates +- [x] **Simplicity Gate (Article VII)**: No new third-party runtime dependencies added; purely utilizing existing Next.js, React, and dictionary mechanisms. +- [x] **Anti-Abstraction Gate (Article VIII)**: Modifying configuration and components directly using native Next.js properties. +- [x] **Integration-First Gate (Article IX)**: Verifying complete Next.js production build (`next build`) and test execution (`vitest run`). + +## Technical Design & Architectural Changes + +### 1. `next.config.mjs` +Add `contentDispositionType: 'inline'` inside `images`: +```javascript + images: { + dangerouslyAllowSVG: true, + contentDispositionType: 'inline', + contentSecurityPolicy: "default-src 'self'; script-src 'none'; sandbox;", + ... +``` + +### 2. `package.json` +Replace the hardcoded Windows Laragon script with standard cross-platform Next.js command: +```json +"dev": "next dev" +``` + +### 3. Dictionaries (`en.json` & `fa.json`) +- Add structured contact form strings into `dict.website.homePage.contact.form`: + - `nameLabel`, `namePlaceholder` + - `emailLabel`, `emailPlaceholder` + - `messageLabel`, `messagePlaceholder` + - `errorNameRequired`, `errorEmailRequired`, `errorEmailInvalid`, `errorMessageRequired` + - `errorSummaryTitle`, `successMessage`, `errorMessage` +- Update footer: + - English: `"Year": "© 2026"`, `"CopyRight": "All Rights Reserved, Inc."` + - Persian: `"Year": "© ۲۰۲۶"`, `"CopyRight": "تمامی حقوق محفوظ است"` + +### 4. `contactForm.tsx` & `contact.tsx` +- Thread dictionary translations into `ContactForm`. +- Dynamic `dir={isRtl ? "rtl" : "ltr"}` based on active locale. +- Adapt client-side validation messages according to dictionary. + +### 5. `(home)/page.tsx` Metadata +- Align home page metadata with professional architect persona: + `title: "وب‌سایت شخصی | توسعه‌دهنده ارشد و معمار نرم‌افزار"` diff --git a/specs/001-fix-audit-bugs/spec.md b/specs/001-fix-audit-bugs/spec.md new file mode 100644 index 0000000..389deb0 --- /dev/null +++ b/specs/001-fix-audit-bugs/spec.md @@ -0,0 +1,57 @@ +# Feature Specification: Audit Bug Fixes & Codebase Hardening + +## Overview +- **Feature ID**: 001-fix-audit-bugs +- **Branch**: `develop` +- **Scope**: Frontend codebase (`parsaaghayi-front`) +- **Author**: Hermes Agent + +## Problem Statement +The comprehensive audit of `parsaaghayi.ir` revealed several technical and UI/UX issues: +1. SVG image rendering fails when optimized by Next.js due to missing `contentDispositionType: 'inline'`. +2. `package.json` contains an outdated, hardcoded Windows-specific `dev` script containing developer local filesystem paths. +3. The contact form suffers from language inconsistencies (English headings with hardcoded Persian fields and validation messages). +4. Footer copyright text has an outdated year (2024) and typographic spacing issues (` , Inc.`). +5. Testimonial cards all reference a single SVG image and foreign mock names. +6. Home page title needs clean, professional personal branding. + +## User Stories & Acceptance Criteria + +### US-1: SVG Optimization & Image Rendering +- **As a** visitor, +- **I want** all SVG images (avatars, logos, icons) to load and render inline inside `` tags, +- **So that** images are displayed sharply without broken image boxes or download prompts. +- **Acceptance Criteria**: + - `next.config.mjs` configures `images.contentDispositionType: 'inline'`. + - Next.js image optimizer returns `Content-Disposition: inline` for SVG assets. + +### US-2: Clean Development Scripts +- **As a** contributor, +- **I want** standard cross-platform npm scripts, +- **So that** the project runs cleanly on Linux, macOS, and CI/CD without hardcoded Windows Laragon paths. +- **Acceptance Criteria**: + - `npm run dev` executes standard `next dev`. + +### US-3: Fully Localized Contact Form +- **As a** visitor browsing in English or Persian, +- **I want** the contact form labels, placeholders, and error messages to match the active language, +- **So that** the interface is coherent and accessible. +- **Acceptance Criteria**: + - `contactForm.tsx` reads field labels, placeholders, and validation messages from dictionary/props. + - Form direction (`dir`) adapts to RTL for Persian and LTR for English. + +### US-4: Updated Footer & Clean Typography +- **As a** visitor, +- **I want** the footer to display the current copyright year and correct punctuation, +- **So that** the website reflects an actively maintained, professional profile. +- **Acceptance Criteria**: + - Copyright year is 2026. + - Space before comma in `All Rights Reserved, Inc.` is removed. + +### US-5: Test Suite & Build Verification +- **As a** developer, +- **I want** all unit tests and production builds to pass with zero errors, +- **So that** changes can safely merge into `main` and deploy via CI/CD. +- **Acceptance Criteria**: + - `npm test` (Vitest) passes. + - `npm run build` succeeds without type or bundling errors. diff --git a/specs/001-fix-audit-bugs/tasks.md b/specs/001-fix-audit-bugs/tasks.md new file mode 100644 index 0000000..1b3631d --- /dev/null +++ b/specs/001-fix-audit-bugs/tasks.md @@ -0,0 +1,18 @@ +# Tasks: Audit Bug Fixes & Codebase Hardening + +## Phase 1: Configuration & Infrastructure +- [x] [P] Task 1.1: Update `next.config.mjs` to set `contentDispositionType: 'inline'` for SVGs. +- [x] [P] Task 1.2: Clean `package.json` `dev` script to `next dev`. + +## Phase 2: Localization & Dictionaries +- [x] [P] Task 2.1: Add contact form field labels, placeholders, and validation strings to `en.json` and `fa.json`. +- [x] [P] Task 2.2: Update copyright year (2026) and fix punctuation in `en.json` and `fa.json`. + +## Phase 3: Component Localizations & Styling +- [x] Task 3.1: Update `contact.tsx` and `contactForm.tsx` to consume dynamic localized strings and handle RTL/LTR dynamically. +- [x] Task 3.2: Refine `(home)/page.tsx` metadata title and personal branding. + +## Phase 4: Verification & Git Release +- [x] Task 4.1: Run `npm test` (Vitest) to ensure all tests pass. +- [x] Task 4.2: Run `npm run build` to verify full compilation and Turbopack bundle pass. +- [x] Task 4.3: Commit changes to `develop`, merge into `main`, and push to origin to trigger CI/CD deploy. diff --git a/src/app/(routes)/(website)/(home)/page.tsx b/src/app/(routes)/(website)/(home)/page.tsx index f05edcf..aaa91ab 100644 --- a/src/app/(routes)/(website)/(home)/page.tsx +++ b/src/app/(routes)/(website)/(home)/page.tsx @@ -10,19 +10,19 @@ import { Metadata } from "next"; import { SITE_URL, ogImageUrl } from "@/app/lib/site-config"; const description = - "Hi, I am Parsa Aghayi, a Frontend & Backend Developer. Here's my personal website to know more about me and contact me if you want! ;)"; + "Parsa Aghayi - Senior Full-Stack Engineer & Web Architect. Personal portfolio, enterprise projects, technical architecture, and engineering blog."; export const metadata: Metadata = { - title: "Parsa Aghayi's Personal Website", + title: "Senior Full-Stack Engineer & Web Architect", description, openGraph: { - title: "Parsa Aghayi's Personal Website", + title: "Parsa Aghayi | Senior Full-Stack Engineer & Web Architect", description, images: [`${SITE_URL}/images/profile.png`], }, twitter: { card: "summary_large_image", - title: "Parsa Aghayi's Personal Website", + title: "Parsa Aghayi | Senior Full-Stack Engineer & Web Architect", description, images: [ogImageUrl("Parsa Aghayi")], }, diff --git a/src/app/(routes)/(website)/components/contact/contact.tsx b/src/app/(routes)/(website)/components/contact/contact.tsx index e00c9a0..3c89ef3 100644 --- a/src/app/(routes)/(website)/components/contact/contact.tsx +++ b/src/app/(routes)/(website)/components/contact/contact.tsx @@ -12,6 +12,21 @@ interface ContactProps { description: string; button: string; placeholder: string; + form?: { + nameLabel?: string; + namePlaceholder?: string; + emailLabel?: string; + emailPlaceholder?: string; + messageLabel?: string; + messagePlaceholder?: string; + errorSummaryTitle?: string; + errorNameRequired?: string; + errorEmailRequired?: string; + errorEmailInvalid?: string; + errorMessageRequired?: string; + successMessage?: string; + errorMessage?: string; + }; }; }; }; @@ -55,6 +70,7 @@ export default function Contact({ dict }: ContactProps) { diff --git a/src/app/(routes)/(website)/components/contact/contactForm.tsx b/src/app/(routes)/(website)/components/contact/contactForm.tsx index b6091ca..5dede87 100644 --- a/src/app/(routes)/(website)/components/contact/contactForm.tsx +++ b/src/app/(routes)/(website)/components/contact/contactForm.tsx @@ -22,7 +22,23 @@ type FieldErrors = Partial>; const EMPTY_VALUES: FormValues = { name: "", email: "", message: "" }; -const ERROR_MESSAGES = { +export interface ContactFormDict { + nameLabel?: string; + namePlaceholder?: string; + emailLabel?: string; + emailPlaceholder?: string; + messageLabel?: string; + messagePlaceholder?: string; + errorSummaryTitle?: string; + errorNameRequired?: string; + errorEmailRequired?: string; + errorEmailInvalid?: string; + errorMessageRequired?: string; + successMessage?: string; + errorMessage?: string; +} + +const DEFAULT_ERROR_MESSAGES = { nameRequired: "لطفاً نام خود را وارد کنید.", emailRequired: "لطفاً ایمیل خود را وارد کنید.", emailInvalid: "لطفاً یک ایمیل معتبر وارد کنید. مثال: name@example.com", @@ -35,19 +51,24 @@ type SubmitState = | { status: "success" } | { status: "error"; message: string }; -function validate(values: FormValues): FieldErrors { +function validate(values: FormValues, formDict?: ContactFormDict): FieldErrors { const errors: FieldErrors = {}; const name = values.name.trim(); const email = values.email.trim(); const message = values.message.trim(); - if (!name) errors.name = ERROR_MESSAGES.nameRequired; + const nameRequired = formDict?.errorNameRequired || DEFAULT_ERROR_MESSAGES.nameRequired; + const emailRequired = formDict?.errorEmailRequired || DEFAULT_ERROR_MESSAGES.emailRequired; + const emailInvalid = formDict?.errorEmailInvalid || DEFAULT_ERROR_MESSAGES.emailInvalid; + const messageRequired = formDict?.errorMessageRequired || DEFAULT_ERROR_MESSAGES.messageRequired; + + if (!name) errors.name = nameRequired; if (!email) { - errors.email = ERROR_MESSAGES.emailRequired; + errors.email = emailRequired; } else if (!EMAIL_SHAPE.test(email)) { - errors.email = ERROR_MESSAGES.emailInvalid; + errors.email = emailInvalid; } - if (!message) errors.message = ERROR_MESSAGES.messageRequired; + if (!message) errors.message = messageRequired; return errors; } @@ -55,11 +76,13 @@ function validate(values: FormValues): FieldErrors { interface ContactFormProps { buttonLabel: string; emailPlaceholder: string; + formDict?: ContactFormDict; } export default function ContactForm({ buttonLabel, emailPlaceholder, + formDict, }: ContactFormProps) { const [values, setValues] = useState(EMPTY_VALUES); const [errors, setErrors] = useState({}); @@ -98,6 +121,9 @@ export default function ContactForm({ } }; + const isRtl = /[\u0600-\u06FF]/.test(buttonLabel || formDict?.nameLabel || ""); + const dir = isRtl ? "rtl" : "ltr"; + const handleSubmit = async (event: FormEvent) => { event.preventDefault(); @@ -107,7 +133,7 @@ export default function ContactForm({ message: values.message.trim(), }; - const nextErrors = validate(trimmed); + const nextErrors = validate(trimmed, formDict); if (Object.keys(nextErrors).length > 0) { // Ask for focus to move to the first field that needs fixing, so the announced @@ -135,7 +161,7 @@ export default function ContactForm({ errors?: Record; } | null; const first = payload?.errors ? Object.values(payload.errors)[0]?.[0] : undefined; - throw new Error(first ?? payload?.message ?? "ثبت پیام با خطا مواجه شد."); + throw new Error(first ?? payload?.message ?? (formDict?.errorMessage || "ثبت پیام با خطا مواجه شد.")); } setValues(EMPTY_VALUES); @@ -146,7 +172,7 @@ export default function ContactForm({ message: error instanceof Error ? error.message - : "ثبت پیام با خطا مواجه شد. کمی بعد دوباره تلاش کنید.", + : (formDict?.errorMessage || "ثبت پیام با خطا مواجه شد. کمی بعد دوباره تلاش کنید."), }); } }; @@ -158,7 +184,7 @@ export default function ContactForm({ return (

-
    +
      {errorEntries.map(([field, message]) => (
    • {message}
    • ))} @@ -185,7 +211,7 @@ export default function ContactForm({