fix: link href in category, and add isAdmin in update add-experts
This commit is contained in:
parent
3b0bf64e39
commit
ae61d19a61
|
|
@ -37,32 +37,43 @@ import { Eye, EyeOff } from "lucide-react";
|
||||||
import { useParams } from "next/navigation";
|
import { useParams } from "next/navigation";
|
||||||
|
|
||||||
const FormSchema = z.object({
|
const FormSchema = z.object({
|
||||||
name: z.string({
|
name: z.string().optional(),
|
||||||
required_error: "Required",
|
username: z.string().optional(),
|
||||||
}),
|
password: z.string().optional(),
|
||||||
username: z.string({
|
phoneNumber: z.string().optional(),
|
||||||
required_error: "Required",
|
email: z.string().optional(),
|
||||||
}),
|
skills: z.string().optional(),
|
||||||
password: z.string({
|
experiences: z.string().optional(),
|
||||||
required_error: "Required",
|
company: z.string().optional(),
|
||||||
}),
|
|
||||||
phoneNumber: z.string({
|
|
||||||
required_error: "Required",
|
|
||||||
}),
|
|
||||||
email: z.string({
|
|
||||||
required_error: "Required",
|
|
||||||
}),
|
|
||||||
skills: z.string({
|
|
||||||
required_error: "Required",
|
|
||||||
}),
|
|
||||||
experiences: z.string({
|
|
||||||
required_error: "Required",
|
|
||||||
}),
|
|
||||||
company: z.string({
|
|
||||||
required_error: "Required",
|
|
||||||
}),
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// const FormSchema = z.object({
|
||||||
|
// name: z.string({
|
||||||
|
// required_error: "Required",
|
||||||
|
// }),
|
||||||
|
// username: z.string({
|
||||||
|
// required_error: "Required",
|
||||||
|
// }),
|
||||||
|
// password: z.string({
|
||||||
|
// required_error: "Required",
|
||||||
|
// }),
|
||||||
|
// phoneNumber: z.string({
|
||||||
|
// required_error: "Required",
|
||||||
|
// }),
|
||||||
|
// email: z.string({
|
||||||
|
// required_error: "Required",
|
||||||
|
// }),
|
||||||
|
// skills: z.string({
|
||||||
|
// required_error: "Required",
|
||||||
|
// }),
|
||||||
|
// experiences: z.string({
|
||||||
|
// required_error: "Required",
|
||||||
|
// }),
|
||||||
|
// company: z.string({
|
||||||
|
// required_error: "Required",
|
||||||
|
// }),
|
||||||
|
// });
|
||||||
|
|
||||||
export type Placements = {
|
export type Placements = {
|
||||||
index: number;
|
index: number;
|
||||||
roleId?: string;
|
roleId?: string;
|
||||||
|
|
@ -189,18 +200,35 @@ export default function UpdateExpertForm() {
|
||||||
|
|
||||||
const dataReq = {
|
const dataReq = {
|
||||||
id: detail?.id,
|
id: detail?.id,
|
||||||
firstName: data.name,
|
firstName: data.name || detail.fullname,
|
||||||
username: data.username,
|
username: data.username || detail.username,
|
||||||
email: data.email,
|
email: data.email || detail.email,
|
||||||
password: data.password,
|
password: data.password || undefined,
|
||||||
address: "",
|
address: "",
|
||||||
roleId: "EXP-ID",
|
roleId: "EXP-ID",
|
||||||
phoneNumber: data.phoneNumber,
|
phoneNumber: data.phoneNumber || detail.phoneNumber,
|
||||||
userCompetencyId: data.skills,
|
userCompetencyId:
|
||||||
userExperienceId: data.experiences,
|
data.skills || detail.userProfilesAdditional?.userCompetency?.id,
|
||||||
companyName: data.company,
|
userExperienceId:
|
||||||
|
data.experiences || detail.userProfilesAdditional?.userExperienceId,
|
||||||
|
companyName: data.company || detail.userProfilesAdditional?.companyName,
|
||||||
|
isAdmin: true,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// const dataReq = {
|
||||||
|
// id: detail?.id,
|
||||||
|
// firstName: data.name,
|
||||||
|
// username: data.username,
|
||||||
|
// email: data.email,
|
||||||
|
// password: data.password,
|
||||||
|
// address: "",
|
||||||
|
// roleId: "EXP-ID",
|
||||||
|
// phoneNumber: data.phoneNumber,
|
||||||
|
// userCompetencyId: data.skills,
|
||||||
|
// userExperienceId: data.experiences,
|
||||||
|
// companyName: data.company,
|
||||||
|
// };
|
||||||
|
|
||||||
loading();
|
loading();
|
||||||
const res = await saveUserInternal(dataReq);
|
const res = await saveUserInternal(dataReq);
|
||||||
const resData = res?.data?.data;
|
const resData = res?.data?.data;
|
||||||
|
|
@ -322,10 +350,15 @@ export default function UpdateExpertForm() {
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Nama Lengkap</FormLabel>
|
<FormLabel>Nama Lengkap</FormLabel>
|
||||||
<Input
|
{/* <Input
|
||||||
defaultValue={detail?.fullname}
|
defaultValue={detail?.fullname}
|
||||||
placeholder="Masukkan Nama Lengkap"
|
placeholder="Masukkan Nama Lengkap"
|
||||||
onChange={field.onChange}
|
onChange={field.onChange}
|
||||||
|
/> */}
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
defaultValue={detail?.fullname}
|
||||||
|
placeholder="Masukkan Nama Lengkap"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
|
|
@ -338,13 +371,18 @@ export default function UpdateExpertForm() {
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Username</FormLabel>
|
<FormLabel>Username</FormLabel>
|
||||||
<Input
|
{/* <Input
|
||||||
type="text"
|
type="text"
|
||||||
defaultValue={detail?.username}
|
defaultValue={detail?.username}
|
||||||
placeholder="Masukkan"
|
placeholder="Masukkan"
|
||||||
onChange={field.onChange}
|
onChange={field.onChange}
|
||||||
|
/> */}
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
type="text"
|
||||||
|
defaultValue={detail?.username}
|
||||||
|
placeholder="Masukkan"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
|
|
@ -355,11 +393,17 @@ export default function UpdateExpertForm() {
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>No. HP</FormLabel>
|
<FormLabel>No. HP</FormLabel>
|
||||||
<Input
|
{/* <Input
|
||||||
type="number"
|
type="number"
|
||||||
defaultValue={detail?.phoneNumber}
|
defaultValue={detail?.phoneNumber}
|
||||||
placeholder="Masukkan No.Hp"
|
placeholder="Masukkan No.Hp"
|
||||||
onChange={field.onChange}
|
onChange={field.onChange}
|
||||||
|
/> */}
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
type="number"
|
||||||
|
defaultValue={detail?.phoneNumber}
|
||||||
|
placeholder="Masukkan"
|
||||||
/>
|
/>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
|
|
@ -371,17 +415,46 @@ export default function UpdateExpertForm() {
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Email</FormLabel>
|
<FormLabel>Email</FormLabel>
|
||||||
<Input
|
{/* <Input
|
||||||
type="email"
|
type="email"
|
||||||
defaultValue={detail?.email}
|
defaultValue={detail?.email}
|
||||||
placeholder="Masukkan email"
|
placeholder="Masukkan email"
|
||||||
onChange={field.onChange}
|
onChange={field.onChange}
|
||||||
|
/> */}
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
type="email"
|
||||||
|
defaultValue={detail?.email}
|
||||||
|
placeholder="Masukkan email"
|
||||||
/>
|
/>
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
<FormField
|
<FormField
|
||||||
|
control={form.control}
|
||||||
|
name="password"
|
||||||
|
render={({ field }) => (
|
||||||
|
<FormItem>
|
||||||
|
<FormLabel>Password (Opsional)</FormLabel>
|
||||||
|
<div className="relative">
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
type={showPassword ? "text" : "password"}
|
||||||
|
placeholder="Kosongkan jika tidak ingin mengubah password"
|
||||||
|
/>
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
onClick={() => setShowPassword(!showPassword)}
|
||||||
|
className="absolute right-3 top-1/2 -translate-y-1/2"
|
||||||
|
>
|
||||||
|
{showPassword ? <EyeOff size={18} /> : <Eye size={18} />}
|
||||||
|
</button>
|
||||||
|
</div>
|
||||||
|
</FormItem>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
{/* <FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="password"
|
name="password"
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
|
|
@ -406,7 +479,7 @@ export default function UpdateExpertForm() {
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
/>
|
/> */}
|
||||||
<FormField
|
<FormField
|
||||||
control={form.control}
|
control={form.control}
|
||||||
name="skills"
|
name="skills"
|
||||||
|
|
@ -481,12 +554,21 @@ export default function UpdateExpertForm() {
|
||||||
render={({ field }) => (
|
render={({ field }) => (
|
||||||
<FormItem>
|
<FormItem>
|
||||||
<FormLabel>Nama Institusi/Perusahaan</FormLabel>
|
<FormLabel>Nama Institusi/Perusahaan</FormLabel>
|
||||||
<Input
|
{/* <Input
|
||||||
type="text"
|
type="text"
|
||||||
value={detail?.userProfilesAdditional?.companyName || ""}
|
value={detail?.userProfilesAdditional?.companyName || ""}
|
||||||
placeholder="Nama Institusi/Perusahaan"
|
placeholder="Nama Institusi/Perusahaan"
|
||||||
onChange={field.onChange}
|
onChange={field.onChange}
|
||||||
|
/> */}
|
||||||
|
<Input
|
||||||
|
{...field}
|
||||||
|
type="text"
|
||||||
|
defaultValue={
|
||||||
|
detail?.userProfilesAdditional?.companyName || ""
|
||||||
|
}
|
||||||
|
placeholder="Nama Institusi/Perusahaan"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<FormMessage />
|
<FormMessage />
|
||||||
</FormItem>
|
</FormItem>
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
|
|
@ -152,12 +152,12 @@ const CampaignListTable = () => {
|
||||||
<div className="flex justify-between mb-10 items-center">
|
<div className="flex justify-between mb-10 items-center">
|
||||||
<p className="text-xl font-medium text-default-900">Daftar Campaign</p>
|
<p className="text-xl font-medium text-default-900">Daftar Campaign</p>
|
||||||
<div className="flex flex-row gap-2">
|
<div className="flex flex-row gap-2">
|
||||||
<Link href="/admin/broadcast/campaign-list/account-list">
|
{/* <Link href="/admin/broadcast/campaign-list/account-list">
|
||||||
<Button color="primary" size="md" className="text-sm">
|
<Button color="primary" size="md" className="text-sm">
|
||||||
<UserIcon />
|
<UserIcon />
|
||||||
Daftar Akun
|
Daftar Akun
|
||||||
</Button>
|
</Button>
|
||||||
</Link>
|
</Link> */}
|
||||||
<Link href="/admin/broadcast/campaign-list/create">
|
<Link href="/admin/broadcast/campaign-list/create">
|
||||||
<Button color="primary" size="md" className="text-sm">
|
<Button color="primary" size="md" className="text-sm">
|
||||||
<NewCampaignIcon size={23} />
|
<NewCampaignIcon size={23} />
|
||||||
|
|
|
||||||
|
|
@ -569,18 +569,19 @@ export default function FilterPage() {
|
||||||
</label>
|
</label>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
<div className="mt-4 flex gap-2 justify-center items-center">
|
<div className="mt-4 flex justify-center items-center gap-2 flex-wrap">
|
||||||
|
{/* Tombol Prev */}
|
||||||
<button
|
<button
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
setCategoryPage((prev) => Math.max(prev - 1, 1))
|
setCategoryPage((prev) => Math.max(prev - 1, 1))
|
||||||
}
|
}
|
||||||
disabled={categoryPage === 1}
|
disabled={categoryPage === 1}
|
||||||
className="px-3 py-1 border rounded disabled:opacity-50"
|
className="px-2 py-1 border rounded disabled:opacity-50 flex items-center justify-center"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
width="24"
|
width="16"
|
||||||
height="24"
|
height="16"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
|
|
@ -590,20 +591,41 @@ export default function FilterPage() {
|
||||||
</svg>
|
</svg>
|
||||||
</button>
|
</button>
|
||||||
|
|
||||||
{Array.from({ length: categoryTotalPages }, (_, i) => (
|
{(() => {
|
||||||
|
const maxVisible = 4;
|
||||||
|
let startPage = Math.max(
|
||||||
|
1,
|
||||||
|
Math.min(
|
||||||
|
categoryPage - Math.floor(maxVisible / 2),
|
||||||
|
categoryTotalPages - maxVisible + 1
|
||||||
|
)
|
||||||
|
);
|
||||||
|
const endPage = Math.min(
|
||||||
|
categoryTotalPages,
|
||||||
|
startPage + maxVisible - 1
|
||||||
|
);
|
||||||
|
|
||||||
|
const visiblePages = [];
|
||||||
|
for (let i = startPage; i <= endPage; i++) {
|
||||||
|
visiblePages.push(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
return visiblePages.map((pageNum) => (
|
||||||
<button
|
<button
|
||||||
key={i}
|
key={pageNum}
|
||||||
onClick={() => setCategoryPage(i + 1)}
|
onClick={() => setCategoryPage(pageNum)}
|
||||||
className={`px-3 py-1 border rounded ${
|
className={`px-3 py-1 border rounded text-sm transition-colors ${
|
||||||
categoryPage === i + 1
|
categoryPage === pageNum
|
||||||
? "bg-[#bb3523] text-white"
|
? "bg-[#bb3523] text-white"
|
||||||
: ""
|
: "bg-white dark:bg-gray-800"
|
||||||
}`}
|
}`}
|
||||||
>
|
>
|
||||||
{i + 1}
|
{pageNum}
|
||||||
</button>
|
</button>
|
||||||
))}
|
));
|
||||||
|
})()}
|
||||||
|
|
||||||
|
{/* Tombol Next */}
|
||||||
<button
|
<button
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
setCategoryPage((prev) =>
|
setCategoryPage((prev) =>
|
||||||
|
|
@ -611,12 +633,12 @@ export default function FilterPage() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
disabled={categoryPage === categoryTotalPages}
|
disabled={categoryPage === categoryTotalPages}
|
||||||
className="px-3 py-1 border rounded disabled:opacity-50"
|
className="px-2 py-1 border rounded disabled:opacity-50 flex items-center justify-center"
|
||||||
>
|
>
|
||||||
<svg
|
<svg
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
xmlns="http://www.w3.org/2000/svg"
|
||||||
width="24"
|
width="16"
|
||||||
height="24"
|
height="16"
|
||||||
viewBox="0 0 24 24"
|
viewBox="0 0 24 24"
|
||||||
>
|
>
|
||||||
<path
|
<path
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,4 @@
|
||||||
import {
|
import {
|
||||||
getCategoryData,
|
|
||||||
getPublicCategoryData,
|
|
||||||
getPublicCategoryDataNew,
|
getPublicCategoryDataNew,
|
||||||
} from "@/service/landing/landing";
|
} from "@/service/landing/landing";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
|
|
@ -8,15 +6,7 @@ import { Reveal } from "./Reveal";
|
||||||
import { useTranslations } from "next-intl";
|
import { useTranslations } from "next-intl";
|
||||||
import { usePathname } from "next/navigation";
|
import { usePathname } from "next/navigation";
|
||||||
import { useParams } from "next/navigation";
|
import { useParams } from "next/navigation";
|
||||||
import Image from "next/image";
|
import { Link, useRouter } from "@/i18n/routing";
|
||||||
import {
|
|
||||||
Carousel,
|
|
||||||
CarouselContent,
|
|
||||||
CarouselItem,
|
|
||||||
CarouselNext,
|
|
||||||
CarouselPrevious,
|
|
||||||
} from "../ui/carousel";
|
|
||||||
import { useRouter } from "@/i18n/routing";
|
|
||||||
import { Button } from "../ui/button";
|
import { Button } from "../ui/button";
|
||||||
import ImageBlurry from "../ui/image-blurry";
|
import ImageBlurry from "../ui/image-blurry";
|
||||||
|
|
||||||
|
|
@ -105,12 +95,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}>
|
||||||
<div
|
<Link
|
||||||
onClick={() =>
|
href={prefixPath + `/all/filter?category=${category?.id}`}
|
||||||
router.push(
|
// onClick={() =>
|
||||||
`${prefixPath}all/filter?category=${category?.id}`
|
// router.push(
|
||||||
)
|
// `${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 */}
|
||||||
|
|
@ -142,7 +133,7 @@ const ContentCategory = (props: { group?: string; type: string }) => {
|
||||||
{category?.name}
|
{category?.name}
|
||||||
</h3>
|
</h3>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</Link>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
)}
|
)}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue