fix: update expert section
This commit is contained in:
parent
68b9439f23
commit
6951ccd137
|
|
@ -107,6 +107,10 @@ interface Detail {
|
||||||
createdAt: string;
|
createdAt: string;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
userRolePlacements?: {
|
||||||
|
roleId: number;
|
||||||
|
userLevelId: number;
|
||||||
|
}[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function UpdateExpertForm() {
|
export default function UpdateExpertForm() {
|
||||||
|
|
@ -163,6 +167,7 @@ export default function UpdateExpertForm() {
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (!detail) return;
|
if (!detail) return;
|
||||||
|
|
||||||
|
// Isi semua form field
|
||||||
form.reset({
|
form.reset({
|
||||||
name: detail.fullname || "",
|
name: detail.fullname || "",
|
||||||
username: detail.username || "",
|
username: detail.username || "",
|
||||||
|
|
@ -177,6 +182,19 @@ export default function UpdateExpertForm() {
|
||||||
: "",
|
: "",
|
||||||
company: detail?.userProfilesAdditional?.companyName || "",
|
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]);
|
}, [detail]);
|
||||||
|
|
||||||
if (!detail) return <div>Loading...</div>;
|
if (!detail) return <div>Loading...</div>;
|
||||||
|
|
@ -385,6 +403,7 @@ export default function UpdateExpertForm() {
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<FormField
|
<FormField
|
||||||
|
disabled
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="username"
|
name="username"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
|
|
@ -450,7 +469,7 @@ export default function UpdateExpertForm() {
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<FormField
|
{/* <FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="password"
|
name="password"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
|
|
@ -472,7 +491,7 @@ export default function UpdateExpertForm() {
|
||||||
</div>
|
</div>
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/> */}
|
||||||
{/* <FormField
|
{/* <FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="password"
|
name="password"
|
||||||
|
|
@ -598,6 +617,7 @@ export default function UpdateExpertForm() {
|
||||||
{placementRows?.map((row: any) => (
|
{placementRows?.map((row: any) => (
|
||||||
<div key={row.index} className="flex items-center gap-2 my-2">
|
<div key={row.index} className="flex items-center gap-2 my-2">
|
||||||
<Select
|
<Select
|
||||||
|
value={row.roleId}
|
||||||
onValueChange={(e) =>
|
onValueChange={(e) =>
|
||||||
handleSelectionChange(row.index, "roleId", e)
|
handleSelectionChange(row.index, "roleId", e)
|
||||||
}
|
}
|
||||||
|
|
@ -634,6 +654,7 @@ export default function UpdateExpertForm() {
|
||||||
</SelectContent>
|
</SelectContent>
|
||||||
</Select> */}
|
</Select> */}
|
||||||
<Select
|
<Select
|
||||||
|
value={row.userLevelId}
|
||||||
onValueChange={(e) =>
|
onValueChange={(e) =>
|
||||||
handleSelectionChange(row.index, "userLevelId", e)
|
handleSelectionChange(row.index, "userLevelId", e)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
import {
|
import { getPublicCategoryDataNew } from "@/service/landing/landing";
|
||||||
getPublicCategoryDataNew,
|
|
||||||
} from "@/service/landing/landing";
|
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { Reveal } from "./Reveal";
|
import { Reveal } from "./Reveal";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
|
|
@ -95,13 +93,13 @@ const ContentCategory = (props: { group?: string; type: string }) => {
|
||||||
{(seeAllValue ? categories : categories?.slice(0, 4))?.map(
|
{(seeAllValue ? categories : categories?.slice(0, 4))?.map(
|
||||||
(category: any) => (
|
(category: any) => (
|
||||||
<div key={category?.id}>
|
<div key={category?.id}>
|
||||||
<Link
|
<div
|
||||||
href={prefixPath + `/all/filter?category=${category?.id}`}
|
// href={prefixPath + `/all/filter?category=${category?.id}`}
|
||||||
// onClick={() =>
|
onClick={() =>
|
||||||
// router.push(
|
router.push(
|
||||||
// `${prefixPath}all/filter?category=${category?.id}`
|
`${prefixPath + `/all/filter?category=${category?.id}`}`
|
||||||
// )
|
)
|
||||||
// }
|
}
|
||||||
className="cursor-pointer relative group rounded-md overflow-hidden shadow-md hover:shadow-lg block"
|
className="cursor-pointer relative group rounded-md overflow-hidden shadow-md hover:shadow-lg block"
|
||||||
>
|
>
|
||||||
{/* Gambar */}
|
{/* Gambar */}
|
||||||
|
|
@ -133,7 +131,7 @@ const ContentCategory = (props: { group?: string; type: string }) => {
|
||||||
{category?.name}
|
{category?.name}
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
</Link>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue