completed user admin page

This commit is contained in:
PxlLoewe
2025-03-15 11:09:55 -07:00
parent abf3475c7c
commit 37d02ea0bc
23 changed files with 567 additions and 106 deletions

View File

@@ -1,25 +1,43 @@
import { ButtonHTMLAttributes, DetailedHTMLProps } from 'react';
import { cn } from '../../../helper/cn';
import {
ButtonHTMLAttributes,
DetailedHTMLProps,
useEffect,
useState,
} from "react";
import { cn } from "../../../helper/cn";
export const Button = ({
isLoading,
...props
isLoading,
...props
}: DetailedHTMLProps<
ButtonHTMLAttributes<HTMLButtonElement>,
HTMLButtonElement
ButtonHTMLAttributes<HTMLButtonElement>,
HTMLButtonElement
> & {
isLoading?: boolean;
isLoading?: boolean;
}) => {
return (
<button
{...(props as any)}
className={cn('btn', props.className)}
disabled={isLoading || props.disabled}
>
{isLoading && (
<span className="loading loading-spinner loading-sm"></span>
)}
{props.children as any}
</button>
);
const [isLoadingState, setIsLoadingState] = useState(isLoading);
useEffect(() => {
setIsLoadingState(isLoading);
}, [isLoading]);
return (
<button
{...(props as any)}
className={cn("btn", props.className)}
disabled={isLoadingState || props.disabled}
onClick={async (e) => {
if (props.onClick) {
setIsLoadingState(true);
await props.onClick(e);
setIsLoadingState(false);
}
}}
>
{isLoadingState && (
<span className="loading loading-spinner loading-sm"></span>
)}
{props.children as any}
</button>
);
};

View File

@@ -76,11 +76,16 @@ const SelectCom = <T extends FieldValues>({
<SelectTemplate
onChange={(newValue: any) => {
if (Array.isArray(newValue)) {
form.setValue(name, newValue.map((v: any) => v.value) as any);
form.setValue(name, newValue.map((v: any) => v.value) as any, {
shouldDirty: true,
});
} else {
form.setValue(name, newValue.value);
form.setValue(name, newValue.value, {
shouldDirty: true,
});
}
form.trigger(name);
form.Dirty;
}}
value={
(inputProps as any)?.isMulti