fix: update expert section

This commit is contained in:
Sabda Yagra 2025-11-18 00:08:18 +07:00
parent 68b9439f23
commit 6951ccd137
2 changed files with 32 additions and 13 deletions

View File

@ -107,6 +107,10 @@ interface Detail {
createdAt: string;
};
};
userRolePlacements?: {
roleId: number;
userLevelId: number;
}[];
}
export default function UpdateExpertForm() {
@ -163,6 +167,7 @@ export default function UpdateExpertForm() {
useEffect(() => {
if (!detail) return;
// Isi semua form field
form.reset({
name: detail.fullname || "",
username: detail.username || "",
@ -177,6 +182,19 @@ export default function UpdateExpertForm() {
: "",
company: detail?.userProfilesAdditional?.companyName || "",
});
// 🔥 Masukkan posisi existing
if (detail.userRolePlacements && detail.userRolePlacements.length > 0) {
const mapped = detail.userRolePlacements.map(
(item: any, idx: number) => ({
index: idx,
roleId: String(item.roleId),
userLevelId: Number(item.userLevelId),
})
);
setPlacementRows(mapped);
}
}, [detail]);
if (!detail) return <div>Loading...</div>;
@ -385,6 +403,7 @@ export default function UpdateExpertForm() {
)}
/>
<FormField
disabled
control={form.control}
name="username"
render={({ field }) => (
@ -450,7 +469,7 @@ export default function UpdateExpertForm() {
</FormItem>
)}
/>
<FormField
{/* <FormField
control={form.control}
name="password"
render={({ field }) => (
@ -472,7 +491,7 @@ export default function UpdateExpertForm() {
</div>
</FormItem>
)}
/>
/> */}
{/* <FormField
control={form.control}
name="password"
@ -598,6 +617,7 @@ export default function UpdateExpertForm() {
{placementRows?.map((row: any) => (
<div key={row.index} className="flex items-center gap-2 my-2">
<Select
value={row.roleId}
onValueChange={(e) =>
handleSelectionChange(row.index, "roleId", e)
}
@ -634,6 +654,7 @@ export default function UpdateExpertForm() {
</SelectContent>
</Select> */}
<Select
value={row.userLevelId}
onValueChange={(e) =>
handleSelectionChange(row.index, "userLevelId", e)
}

View File

@ -1,6 +1,4 @@
import {
getPublicCategoryDataNew,
} from "@/service/landing/landing";
import { getPublicCategoryDataNew } from "@/service/landing/landing";
import React, { useEffect, useState } from "react";
import { Reveal } from "./Reveal";
import { useTranslations } from "next-intl";
@ -95,13 +93,13 @@ const ContentCategory = (props: { group?: string; type: string }) => {
{(seeAllValue ? categories : categories?.slice(0, 4))?.map(
(category: any) => (
<div key={category?.id}>
<Link
href={prefixPath + `/all/filter?category=${category?.id}`}
// onClick={() =>
// router.push(
// `${prefixPath}all/filter?category=${category?.id}`
// )
// }
<div
// href={prefixPath + `/all/filter?category=${category?.id}`}
onClick={() =>
router.push(
`${prefixPath + `/all/filter?category=${category?.id}`}`
)
}
className="cursor-pointer relative group rounded-md overflow-hidden shadow-md hover:shadow-lg block"
>
{/* Gambar */}
@ -133,7 +131,7 @@ const ContentCategory = (props: { group?: string; type: string }) => {
{category?.name}
</h3>
</div>
</Link>
</div>
</div>
)
)}