generated from muhtadeetaron/nextjs-template
fix(api): fix api endpoint logic #3
This commit is contained in:
@ -1,14 +1,6 @@
|
||||
import { Input } from "@/components/ui/input";
|
||||
import { Label } from "@/components/ui/label";
|
||||
|
||||
interface UserData {
|
||||
name: string;
|
||||
institution: string;
|
||||
sscRoll: string;
|
||||
hscRoll: string;
|
||||
email: string;
|
||||
phone: string;
|
||||
}
|
||||
import { UserData } from "@/types/auth";
|
||||
|
||||
interface ProfileManagerProps {
|
||||
userData: UserData | undefined;
|
||||
@ -23,57 +15,63 @@ export default function ProfileManager({
|
||||
}: ProfileManagerProps) {
|
||||
if (!userData) return null;
|
||||
|
||||
const handleChange = (field: keyof UserData, value: string) => {
|
||||
const handleChange = (field: keyof UserData, value: string | number) => {
|
||||
setUserData((prev) => (prev ? { ...prev, [field]: value } : prev));
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="mx-auto">
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<Label htmlFor="name" className="text-sm font-semibold text-gray-700">
|
||||
Name
|
||||
</Label>
|
||||
<Input
|
||||
id="name"
|
||||
type="text"
|
||||
value={userData.name}
|
||||
onChange={(e) => handleChange("name", e.target.value)}
|
||||
className="bg-gray-50 py-6"
|
||||
readOnly={!edit}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Full Name */}
|
||||
<div className="space-y-2">
|
||||
<Label
|
||||
htmlFor="institution"
|
||||
htmlFor="full_name"
|
||||
className="text-sm font-semibold text-gray-700"
|
||||
>
|
||||
Institution
|
||||
Full Name
|
||||
</Label>
|
||||
<Input
|
||||
id="institution"
|
||||
id="full_name"
|
||||
type="text"
|
||||
value={userData.institution}
|
||||
onChange={(e) => handleChange("institution", e.target.value)}
|
||||
value={userData.full_name}
|
||||
onChange={(e) => handleChange("full_name", e.target.value)}
|
||||
className="bg-gray-50 py-6"
|
||||
readOnly={!edit}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* College */}
|
||||
<div className="space-y-2">
|
||||
<Label
|
||||
htmlFor="college"
|
||||
className="text-sm font-semibold text-gray-700"
|
||||
>
|
||||
College
|
||||
</Label>
|
||||
<Input
|
||||
id="college"
|
||||
type="text"
|
||||
value={userData.college}
|
||||
onChange={(e) => handleChange("college", e.target.value)}
|
||||
className="bg-gray-50 py-6"
|
||||
readOnly={!edit}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* SSC & HSC Rolls */}
|
||||
<div className="flex gap-4">
|
||||
<div className="space-y-2 w-full">
|
||||
<Label
|
||||
htmlFor="sscRoll"
|
||||
htmlFor="ssc_roll"
|
||||
className="text-sm font-semibold text-gray-700"
|
||||
>
|
||||
SSC Roll
|
||||
</Label>
|
||||
<Input
|
||||
id="sscRoll"
|
||||
type="text"
|
||||
value={userData.sscRoll}
|
||||
onChange={(e) => handleChange("sscRoll", e.target.value)}
|
||||
id="ssc_roll"
|
||||
type="number"
|
||||
value={userData.ssc_roll}
|
||||
onChange={(e) => handleChange("ssc_roll", Number(e.target.value))}
|
||||
className="bg-gray-50 py-6"
|
||||
readOnly={!edit}
|
||||
/>
|
||||
@ -81,22 +79,23 @@ export default function ProfileManager({
|
||||
|
||||
<div className="space-y-2 w-full">
|
||||
<Label
|
||||
htmlFor="hscRoll"
|
||||
htmlFor="hsc_roll"
|
||||
className="text-sm font-semibold text-gray-700"
|
||||
>
|
||||
HSC Roll
|
||||
</Label>
|
||||
<Input
|
||||
id="hscRoll"
|
||||
type="text"
|
||||
value={userData.hscRoll}
|
||||
onChange={(e) => handleChange("hscRoll", e.target.value)}
|
||||
id="hsc_roll"
|
||||
type="number"
|
||||
value={userData.hsc_roll}
|
||||
onChange={(e) => handleChange("hsc_roll", Number(e.target.value))}
|
||||
className="bg-gray-50 py-6"
|
||||
readOnly={!edit}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Email */}
|
||||
<div className="space-y-2">
|
||||
<Label
|
||||
htmlFor="email"
|
||||
@ -114,18 +113,19 @@ export default function ProfileManager({
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Phone */}
|
||||
<div className="space-y-2">
|
||||
<Label
|
||||
htmlFor="phone"
|
||||
htmlFor="phone_number"
|
||||
className="text-sm font-semibold text-gray-700"
|
||||
>
|
||||
Phone
|
||||
</Label>
|
||||
<Input
|
||||
id="phone"
|
||||
id="phone_number"
|
||||
type="tel"
|
||||
value={userData.phone}
|
||||
onChange={(e) => handleChange("phone", e.target.value)}
|
||||
value={userData.phone_number}
|
||||
onChange={(e) => handleChange("phone_number", e.target.value)}
|
||||
className="bg-gray-50 py-6"
|
||||
readOnly={!edit}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user