-
+
{selected.map((index) => (
-
-
- {options[index]?.text}
-
-
-
remove(index, e)}
- className="hover:text-red cursor-pointer pl-2"
+ className="ml-1 flex h-4 w-4 items-center justify-center rounded-full text-xs hover:bg-primary/20"
>
-
-
-
-
+ ×
+
+ )}
+
))}
{selected.length === 0 && (
-
-
- {placeholder}
-
-
+
+ {placeholder}
+
)}
-
-
+
{options.map((option, index) => (
-
+
handleSelect(index)}
+ >
handleSelect(index)}
+ className={cn(
+ "mr-3 h-4 w-4 rounded border-2",
+ option.selected
+ ? "border-primary bg-primary"
+ : "border-stroke dark:border-dark-3",
+ )}
>
-
+ {option.selected && (
+
+ )}
+ {option.text}
))}
+
{error && (
{error.message as string}
)}
);
}
+
export default MultiSelect;
diff --git a/src/components/FormElements/switch.tsx b/src/components/FormElements/switch.tsx
index 4054f06..358ad2b 100644
--- a/src/components/FormElements/switch.tsx
+++ b/src/components/FormElements/switch.tsx
@@ -50,14 +50,14 @@ export function Switch({
"absolute left-1 top-1 flex size-6 items-center justify-center rounded-full bg-white shadow-switch-1 transition peer-checked:right-1 peer-checked:translate-x-full peer-checked:[&_.check-icon]:block peer-checked:[&_.x-icon]:hidden",
{
"-top-1 left-0 size-7 shadow-switch-2": backgroundSize === "sm",
- "peer-checked:bg-primary peer-checked:dark:bg-white":
+ "peer-checked:bg-primary peer-checked:dark:bg-primary":
background !== "dark",
},
)}
>
{withIcon && (
<>
-
+
>
)}
diff --git a/src/components/Tables/admins/Skeleton.tsx b/src/components/Tables/admins/Skeleton.tsx
deleted file mode 100644
index 506c0bb..0000000
--- a/src/components/Tables/admins/Skeleton.tsx
+++ /dev/null
@@ -1,41 +0,0 @@
-import { Skeleton } from "@/components/ui/skeleton";
-import {
- Table,
- TableBody,
- TableCell,
- TableHead,
- TableHeader,
- TableRow,
-} from "@/components/ui/table";
-
-export function AdminsSkeleton() {
- return (
-
-
- Admins
-
-
-
-
-
- Full name
- Email
- Role
- Username
- Actions
-
-
-
-
- {Array.from({ length: 5 }).map((_, i) => (
-
-
-
-
-
- ))}
-
-
-
- );
-}
diff --git a/src/components/Tables/admins/index.tsx b/src/components/Tables/admins/index.tsx
index 4fc8f13..1442972 100644
--- a/src/components/Tables/admins/index.tsx
+++ b/src/components/Tables/admins/index.tsx
@@ -1,5 +1,7 @@
"use client";
+import { PencilSquareIcon, TrashIcon } from "@/assets/icons";
+import ConfirmationModal from "@/components/ui/ConfirmationModal";
import {
Table,
TableBody,
@@ -8,11 +10,9 @@ import {
TableHeader,
TableRow,
} from "@/components/ui/table";
-import { useAdminsPresenter } from "./useAdminsPresenter";
-import { PencilSquareIcon, TrashIcon } from "@/assets/icons";
-import ConfirmationModal from "@/components/ui/ConfirmationModal";
-import { AdminsSkeleton } from "./Skeleton";
+import TableSkeleton from "@/components/ui/TableSkeleton";
import Link from "next/link";
+import { useAdminsPresenter } from "./useAdminsPresenter";
const AdminsTable = () => {
const {
@@ -27,7 +27,6 @@ const AdminsTable = () => {
pathName,
} = useAdminsPresenter();
- if (isPending) return
;
return (
- {/*
-
- {isMutating ? (
-
- ) : (
- "Submit"
- )}
-
-
- Opt out
-
-
*/}
+
);
};
diff --git a/src/components/forms/companies/useCreateCompanyPresenter.ts b/src/components/forms/companies/useCreateCompanyPresenter.ts
index 3de3a0b..0a51258 100644
--- a/src/components/forms/companies/useCreateCompanyPresenter.ts
+++ b/src/components/forms/companies/useCreateCompanyPresenter.ts
@@ -1,8 +1,13 @@
"use client";
-import { useCreateCompany, useUpdateCompany } from "@/hooks/queries";
+import {
+ useCompanyCategoriesQuery,
+ useCreateCompany,
+ useUpdateCompany,
+} from "@/hooks/queries";
import { ICreateCompanyCredentials } from "@/lib/api";
import { useIsMutating } from "@tanstack/react-query";
import { useRouter } from "next/navigation";
+import { useEffect } from "react";
import { SubmitHandler, useForm } from "react-hook-form";
interface IProps {
@@ -17,9 +22,26 @@ const useCreateCompanyPresenter = ({ defaultValues, editMode, id }: IProps) => {
register,
formState: { errors },
handleSubmit,
+ watch,
+ setValue,
reset,
- } = useForm
({ mode: "onChange", defaultValues });
+ } = useForm({
+ mode: "onChange",
+ defaultValues: {
+ ...defaultValues,
+ },
+ });
+
+ useEffect(() => {
+ if (defaultValues) {
+ const categories = defaultValues?.tags.categories.map(
+ (item: any) => item.id,
+ );
+ setValue("tags.categories", categories);
+ }
+ }, [defaultValues]);
const router = useRouter();
+ const { data: companyCategories } = useCompanyCategoriesQuery();
const { mutate: createCompany, isPending: isCreating } = useCreateCompany();
const { mutate: updateCompany, isPending: isUpdating } = useUpdateCompany(
id as string,
@@ -30,33 +52,6 @@ const useCreateCompanyPresenter = ({ defaultValues, editMode, id }: IProps) => {
founded_year: data.founded_year ? +data.founded_year : 0,
employee_count: data.employee_count ? +data.employee_count : 0,
annual_revenue: data.annual_revenue ? +data.annual_revenue : 0,
- tags: {
- keywords: data.tags?.keywords
- ? (data.tags.keywords as unknown as string)
- .split(",")
- .map((s) => s.trim())
- : [],
- categories: data.tags?.categories
- ? (data.tags.categories as unknown as string)
- .split(",")
- .map((s) => s.trim())
- : [],
- specializations: data.tags?.specializations
- ? (data.tags.specializations as unknown as string)
- .split(",")
- .map((s) => s.trim())
- : [],
- certifications: data.tags?.certifications
- ? (data.tags.certifications as unknown as string)
- .split(",")
- .map((s) => s.trim())
- : [],
- cpv_codes: data.tags?.cpv_codes
- ? (data.tags.cpv_codes as unknown as string)
- .split(",")
- .map((s) => s.trim())
- : [],
- },
};
if (editMode) {
updateCompany({
@@ -80,7 +75,10 @@ const useCreateCompanyPresenter = ({ defaultValues, editMode, id }: IProps) => {
isMutating,
isCreating,
isUpdating,
- router
+ router,
+ watch,
+ setValue,
+ companyCategories,
};
};
diff --git a/src/components/forms/customers/CreateCustomer.tsx b/src/components/forms/customers/CreateCustomer.tsx
index e962cf0..51dc122 100644
--- a/src/components/forms/customers/CreateCustomer.tsx
+++ b/src/components/forms/customers/CreateCustomer.tsx
@@ -1,13 +1,14 @@
"use client";
+import { GlobeIcon } from "@/assets/icons";
+import InputGroup from "@/components/FormElements/InputGroup";
+import MultiSelect from "@/components/FormElements/MultiSelect";
+import { Select } from "@/components/FormElements/select";
+import { ShowcaseSection } from "@/components/Layouts/showcase-section";
+import FormFooter from "@/components/ui/FormFooter";
+import { FormErrorMessages } from "@/constants/Texts";
import { CreateCustomerCredentials } from "@/lib/api";
import useCreateCustomerPresenter from "./useCreateCustomerPresenter";
-import { ShowcaseSection } from "@/components/Layouts/showcase-section";
-import InputGroup from "@/components/FormElements/InputGroup";
-import { FormErrorMessages } from "@/constants/Texts";
-import { Select } from "@/components/FormElements/select";
-import MultiSelect from "@/components/FormElements/MultiSelect";
-import { GlobeIcon, UserIcon } from "@/assets/icons";
interface IProps {
editMode?: boolean;
@@ -170,27 +171,6 @@ const CreateCustomer = ({ defaultValues, editMode, id }: IProps) => {
{errors.phone.message}
)}
);
diff --git a/src/components/ui/Status.tsx b/src/components/ui/Status.tsx
index aa311b4..24e00d1 100644
--- a/src/components/ui/Status.tsx
+++ b/src/components/ui/Status.tsx
@@ -31,7 +31,7 @@ const Status = ({ status, children }: IProps) => {
return (