fixed imports from shared libary
This commit is contained in:
@@ -1,20 +1,11 @@
|
||||
"use client";
|
||||
import {
|
||||
FieldValues,
|
||||
Path,
|
||||
RegisterOptions,
|
||||
UseFormReturn,
|
||||
} from "react-hook-form";
|
||||
import SelectTemplate, {
|
||||
Props as SelectTemplateProps,
|
||||
StylesConfig,
|
||||
} from "react-select";
|
||||
import { cn } from "../../../helper/cn";
|
||||
import { FieldValues, Path, RegisterOptions, UseFormReturn } from "react-hook-form";
|
||||
import SelectTemplate, { Props as SelectTemplateProps, StylesConfig } from "react-select";
|
||||
import { cn } from "@repo/shared-components";
|
||||
import dynamic from "next/dynamic";
|
||||
import { CSSProperties } from "react";
|
||||
|
||||
interface SelectProps<T extends FieldValues>
|
||||
extends Omit<SelectTemplateProps, "form"> {
|
||||
interface SelectProps<T extends FieldValues> extends Omit<SelectTemplateProps, "form"> {
|
||||
label?: any;
|
||||
name: Path<T>;
|
||||
form: UseFormReturn<T> | any;
|
||||
@@ -70,9 +61,7 @@ const SelectCom = <T extends FieldValues>({
|
||||
}: SelectProps<T>) => {
|
||||
return (
|
||||
<div>
|
||||
<span className="label-text text-lg flex items-center gap-2">
|
||||
{label}
|
||||
</span>
|
||||
<span className="label-text text-lg flex items-center gap-2">{label}</span>
|
||||
<SelectTemplate
|
||||
onChange={(newValue: any) => {
|
||||
if (Array.isArray(newValue)) {
|
||||
@@ -89,12 +78,8 @@ const SelectCom = <T extends FieldValues>({
|
||||
}}
|
||||
value={
|
||||
(inputProps as any)?.isMulti
|
||||
? (inputProps as any).options?.filter((o: any) =>
|
||||
form.watch(name)?.includes(o.value),
|
||||
)
|
||||
: (inputProps as any).options?.find(
|
||||
(o: any) => o.value === form.watch(name),
|
||||
)
|
||||
? (inputProps as any).options?.filter((o: any) => form.watch(name)?.includes(o.value))
|
||||
: (inputProps as any).options?.find((o: any) => o.value === form.watch(name))
|
||||
}
|
||||
styles={customStyles as any}
|
||||
className={cn("w-full placeholder:text-neutral-600", className)}
|
||||
@@ -102,17 +87,13 @@ const SelectCom = <T extends FieldValues>({
|
||||
{...inputProps}
|
||||
/>
|
||||
{form.formState.errors[name]?.message && (
|
||||
<p className="text-error">
|
||||
{form.formState.errors[name].message as string}
|
||||
</p>
|
||||
<p className="text-error">{form.formState.errors[name].message as string}</p>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
const SelectWrapper = <T extends FieldValues>(props: SelectProps<T>) => (
|
||||
<SelectCom {...props} />
|
||||
);
|
||||
const SelectWrapper = <T extends FieldValues>(props: SelectProps<T>) => <SelectCom {...props} />;
|
||||
|
||||
export const Select = dynamic(() => Promise.resolve(SelectWrapper), {
|
||||
ssr: false,
|
||||
|
||||
Reference in New Issue
Block a user