### Run Maternix Frontend Locally Source: https://github.com/dreiiiiim/maternix-frontend-backend/blob/main/README.md Commands to navigate to the frontend directory, install dependencies, and start the development server. ```bash cd frontend npm install npm run dev ``` -------------------------------- ### Configure Project Environment Source: https://context7.com/dreiiiiim/maternix-frontend-backend/llms.txt Commands for installing dependencies and managing the development and production lifecycle of the Next.js application. ```bash # Navigate to frontend directory cd frontend # Install dependencies npm install # Start development server npm run dev # Build for production npm run build # Start production server npm start ``` -------------------------------- ### Implement Root Layout Source: https://context7.com/dreiiiiim/maternix-frontend-backend/llms.txt The main layout wrapper providing global styling and the navigation header for the application. ```tsx // frontend/src/app/layout.tsx import type { Metadata } from "next"; import "./globals.css"; import { Header } from "@/components/Header"; export const metadata: Metadata = { title: "Maternix Track", description: "Advanced clinical tracking for nursing students and instructors in maternal health education.", }; export default function RootLayout({ children, }: Readonly<{ children: React.ReactNode; }>) { return (
{children} ); } ``` -------------------------------- ### Create Header Component Source: https://context7.com/dreiiiiim/maternix-frontend-backend/llms.txt Responsive navigation header that conditionally renders based on the current route using Framer Motion for animations. ```tsx // frontend/src/components/Header.tsx 'use client'; import Link from 'next/link'; import { usePathname } from 'next/navigation'; import { motion } from 'framer-motion'; import Image from 'next/image'; export function Header() { const pathname = usePathname(); const isAuthPage = pathname === '/login' || pathname === '/signup'; const isDashboardPage = pathname.startsWith('/student') || pathname.startsWith('/instructor') || pathname.startsWith('/admin'); // Hide header on auth and dashboard pages (they have their own headers) if (isAuthPage || isDashboardPage) return null; return (
Maternix Track
About Us Login Sign Up
); } ``` -------------------------------- ### Implement Instructor Dashboard Component Source: https://context7.com/dreiiiiim/maternix-frontend-backend/llms.txt Provides a tabbed interface for navigating between announcements, procedure management, and student masterlist views. ```tsx // frontend/src/components/InstructorDashboard.tsx 'use client'; import { useState } from 'react'; import { Bell, FileText, Users } from 'lucide-react'; import { AnnouncementForm } from './instructor/AnnouncementForm'; import { ProcedureManagement } from './instructor/ProcedureManagement'; import { StudentMasterlist } from './instructor/StudentMasterlist'; type TabType = 'announcements' | 'procedures' | 'students'; export function InstructorDashboard() { const [activeTab, setActiveTab] = useState('announcements'); const tabs = [ { id: 'announcements', label: 'Announcements', icon: Bell }, { id: 'procedures', label: 'Procedures', icon: FileText }, { id: 'students', label: 'Student Masterlist', icon: Users }, ]; return (
{/* Tab Navigation */}
{tabs.map((tab) => ( ))}
{/* Tab Content */} {activeTab === 'announcements' && } {activeTab === 'procedures' && } {activeTab === 'students' && }
); } ``` -------------------------------- ### Define Application Routes Source: https://context7.com/dreiiiiim/maternix-frontend-backend/llms.txt Overview of the Next.js App Router structure for public, authentication, and dashboard pages. ```typescript // Route structure (frontend/src/app/*) / // Landing page - public marketing page /about // About Us page /login // User login with role selection /signup // User registration (student/instructor) /student/dashboard // Student dashboard with procedures and announcements /student/profile // Student profile settings /instructor/dashboard // Instructor dashboard with tabs /admin/dashboard // Admin dashboard for system management /announcements // Announcements listing page ``` -------------------------------- ### Login Page Component with Role Selection Source: https://context7.com/dreiiiiim/maternix-frontend-backend/llms.txt Handles user login with email and password, and allows selection of user type (student, instructor, admin) before routing to the appropriate dashboard. Clears session storage for announcements on submit. ```tsx // frontend/src/components/LoginPage.tsx 'use client'; import { useState } from 'react'; import { useRouter } from 'next/navigation'; export function LoginPage() { const router = useRouter(); const [email, setEmail] = useState(''); const [password, setPassword] = useState(''); const [userType, setUserType] = useState<'student' | 'instructor' | 'admin'>('student'); const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); sessionStorage.removeItem('announcementPopupShown'); // Route to appropriate dashboard based on user type if (userType === 'instructor') { router.push('/instructor/dashboard'); } else if (userType === 'admin') { router.push('/admin/dashboard'); } else { router.push('/student/dashboard'); } }; return (
{/* User type selection buttons */}
{(['student', 'instructor', 'admin'] as const).map((type) => ( ))}
{/* Email and password inputs */} setEmail(e.target.value)} required /> setPassword(e.target.value)} required />
); } ``` -------------------------------- ### Implement Announcement Form Component Source: https://context7.com/dreiiiiim/maternix-frontend-backend/llms.txt Handles the creation and deletion of announcements with category selection and local state management. ```tsx // frontend/src/components/instructor/AnnouncementForm.tsx 'use client'; import { useState } from 'react'; export function AnnouncementForm() { const [formData, setFormData] = useState({ title: '', content: '', category: 'Academic' }); const [announcements, setAnnouncements] = useState([ { id: 1, title: 'New Clinical Modules Available', category: 'Academic', date: 'April 12, 2026' }, ]); const categories = ['Academic', 'Schedule', 'Assessment', 'Event', 'Policy']; const handleSubmit = (e: React.FormEvent) => { e.preventDefault(); const newAnnouncement = { id: Math.max(...announcements.map((a) => a.id), 0) + 1, title: formData.title, category: formData.category, date: new Date().toLocaleDateString('en-US', { year: 'numeric', month: 'long', day: 'numeric' }), }; setAnnouncements([newAnnouncement, ...announcements]); setFormData({ title: '', content: '', category: 'Academic' }); }; const handleDelete = (id: number) => { if (confirm('Are you sure you want to delete this announcement?')) { setAnnouncements(announcements.filter((a) => a.id !== id)); } }; return (
setFormData({ ...formData, title: e.target.value })} placeholder="Announcement Title" required />