![]() Server : Apache/2 System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64 User : gositeme ( 1004) PHP Version : 8.2.29 Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname Directory : /home/gositeme/domains/lavocat.ca/private_html/src/pages/hire/ |
import React, { useState } from 'react';
import { useRouter } from 'next/router';
import { useSession } from 'next-auth/react';
import Head from 'next/head';
import LayoutWithSidebar from '../../components/LayoutWithSidebar';
import StructuredData, { createHowToStructuredData } from '../../components/StructuredData';
import OpenGraphMeta from '../../components/OpenGraphMeta';
import { motion } from 'framer-motion';
import {
FileText, ArrowLeft, ArrowRight, Scale,
DollarSign, Calendar, AlertCircle, User, Users
} from 'lucide-react';
import toast from 'react-hot-toast';
import NewCaseForm from '../../components/NewCaseForm';
const NewCasePage: React.FC = () => {
const router = useRouter();
const { data: session } = useSession();
const [submitting, setSubmitting] = useState(false);
const [formData, setFormData] = useState({
title: '',
caseType: 'CIVIL',
priority: 'MEDIUM',
budget: '',
description: '',
assignedTo: '',
isPublic: false
});
const { lawyerId } = router.query;
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>) => {
const { name, value, type } = e.target;
const checked = type === 'checkbox' ? (e.target as HTMLInputElement).checked : undefined;
setFormData(prev => ({
...prev,
[name]: type === 'checkbox' ? checked : value
}));
};
const handleSubmit = async (e: React.FormEvent) => {
e.preventDefault();
if (!formData.title || !formData.description) {
toast.error('Please fill in all required fields');
return;
}
setSubmitting(true);
try {
// Use the universal case API endpoint
const response = await fetch('/api/cases', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
...formData,
status: 'PENDING',
budget: formData.budget ? parseFloat(formData.budget) : null,
assignedTo: formData.assignedTo || null,
isPublic: formData.isPublic
}),
});
if (response.ok) {
const data = await response.json();
toast.success('Case created successfully!');
// Redirect based on user role
if (session?.user?.role === 'CLIENT') {
router.push('/client/dashboard');
} else if (session?.user?.role === 'LAWYER') {
router.push('/lawyer/dashboard');
} else if (session?.user?.role === 'ADMIN' || session?.user?.role === 'SUPERADMIN' || session?.user?.role === 'SUPERADMIN') {
router.push('/admin/cases');
} else {
router.push('/admin/cases');
}
} else {
const error = await response.json();
toast.error(error.error || 'Failed to create case');
}
} catch (error) {
console.error('Error creating case:', error);
toast.error('Failed to create case');
} finally {
setSubmitting(false);
}
};
const caseTypes = [
{ value: 'CIVIL', label: 'Civil Litigation' },
{ value: 'CRIMINAL', label: 'Criminal Defense' },
{ value: 'FAMILY', label: 'Family Law' },
{ value: 'CORPORATE', label: 'Corporate Law' },
{ value: 'REAL_ESTATE', label: 'Real Estate' },
{ value: 'INTELLECTUAL_PROPERTY', label: 'Intellectual Property' },
{ value: 'EMPLOYMENT', label: 'Employment Law' },
{ value: 'IMMIGRATION', label: 'Immigration' },
{ value: 'MEDIATION', label: 'Mediation' },
{ value: 'INVESTIGATION', label: 'Investigation' },
{ value: 'EXPERT_TESTIMONY', label: 'Expert Testimony' },
{ value: 'NOTARIAL', label: 'Notarial Services' },
{ value: 'OTHER', label: 'Other' }
];
const priorities = [
{ value: 'LOW', label: 'Low Priority' },
{ value: 'MEDIUM', label: 'Medium Priority' },
{ value: 'HIGH', label: 'High Priority' },
{ value: 'URGENT', label: 'Urgent' }
];
// Role-based features
const isAdmin = session?.user?.role === 'ADMIN' || session?.user?.role === 'SUPERADMIN' || session?.user?.role === 'SUPERADMIN';
const isLawyer = session?.user?.role === 'LAWYER';
const isClient = session?.user?.role === 'CLIENT';
return (
<>
<OpenGraphMeta
title="Create New Case - Legal Case Management - Liberté Même en Prison"
description="Learn how to create a new legal case in our comprehensive case management system. Step-by-step guide for clients, lawyers, and administrators."
url="/hire/new-case"
type="website"
tags={[
'case creation',
'legal case',
'case management',
'legal services',
'lawyer hiring'
]}
image="/images/WebAd/1.png"
/>
<StructuredData
type="howTo"
data={createHowToStructuredData({
name: "How to Create a New Legal Case",
description: "Step-by-step guide to create a new case in the legal case management system",
steps: [
{
name: "Access Case Creation",
text: "Navigate to the new case creation page through the dashboard or hire section of the platform."
},
{
name: "Fill Case Title",
text: "Enter a brief but descriptive title for your case that clearly explains the legal matter."
},
{
name: "Select Case Type",
text: "Choose the appropriate case type from the dropdown menu (Civil, Criminal, Family, Corporate, etc.)."
},
{
name: "Set Priority Level",
text: "Determine the urgency of your case by selecting Low, Medium, High, or Urgent priority."
},
{
name: "Define Budget",
text: "Enter your estimated budget for legal services, if applicable, to help lawyers understand your financial constraints."
},
{
name: "Write Detailed Description",
text: "Provide a comprehensive description of your case, including key facts, timeline, and desired outcomes."
},
{
name: "Choose Assignment",
text: "Select a specific lawyer to assign the case to, or leave unassigned for review by administrators."
},
{
name: "Set Public Visibility",
text: "Decide whether to make the case public for other users to view or keep it private."
},
{
name: "Submit Case",
text: "Review all information and submit the case. You'll receive confirmation and be redirected to your dashboard."
}
],
totalTime: "PT15M",
estimatedCost: {
currency: "CAD",
value: "0"
},
supply: [
"Case details and documentation",
"Contact information",
"Relevant legal documents"
],
tool: [
"Computer or mobile device",
"Internet connection",
"Case management platform"
]
})}
/>
<LayoutWithSidebar>
<Head>
<title>Create New Case</title>
</Head>
<NewCaseForm />
</LayoutWithSidebar>
</>
);
};
export default NewCasePage;