fix: resolve all TypeScript errors in web app
This commit is contained in:
@@ -45,8 +45,16 @@ const AlertDialogContext = React.createContext<{
|
||||
}>({});
|
||||
|
||||
export function AlertDialog({ open, onOpenChange, children }: AlertDialogProps) {
|
||||
const contextValue: { open?: boolean; onOpenChange?: (open: boolean) => void } = {};
|
||||
if (open !== undefined) {
|
||||
contextValue.open = open;
|
||||
}
|
||||
if (onOpenChange !== undefined) {
|
||||
contextValue.onOpenChange = onOpenChange;
|
||||
}
|
||||
|
||||
return (
|
||||
<AlertDialogContext.Provider value={{ open, onOpenChange }}>
|
||||
<AlertDialogContext.Provider value={contextValue}>
|
||||
{children}
|
||||
</AlertDialogContext.Provider>
|
||||
);
|
||||
|
||||
@@ -3,9 +3,9 @@ import type { ButtonProps as BaseButtonProps } from "@mosaic/ui";
|
||||
import type { ReactNode, ButtonHTMLAttributes } from "react";
|
||||
|
||||
// Extend Button to support additional variants
|
||||
type ExtendedVariant = "primary" | "secondary" | "danger" | "ghost" | "outline" | "destructive" | "link";
|
||||
type ExtendedVariant = "default" | "primary" | "secondary" | "danger" | "ghost" | "outline" | "destructive" | "link";
|
||||
|
||||
export interface ButtonProps extends Omit<BaseButtonProps, "variant"> {
|
||||
export interface ButtonProps extends Omit<BaseButtonProps, "variant" | "size"> {
|
||||
variant?: ExtendedVariant;
|
||||
size?: "sm" | "md" | "lg" | "icon";
|
||||
children: ReactNode;
|
||||
@@ -13,6 +13,7 @@ export interface ButtonProps extends Omit<BaseButtonProps, "variant"> {
|
||||
|
||||
// Map extended variants to base variants
|
||||
const variantMap: Record<string, "primary" | "secondary" | "danger" | "ghost"> = {
|
||||
"default": "primary",
|
||||
"outline": "ghost",
|
||||
"destructive": "danger",
|
||||
"link": "ghost",
|
||||
|
||||
@@ -48,8 +48,20 @@ export function Select({ value, onValueChange, defaultValue, disabled, children
|
||||
setIsOpen(false);
|
||||
};
|
||||
|
||||
const contextValue: {
|
||||
value?: string;
|
||||
onValueChange?: (value: string) => void;
|
||||
isOpen: boolean;
|
||||
setIsOpen: (open: boolean) => void;
|
||||
} = { isOpen, setIsOpen };
|
||||
|
||||
if (currentValue !== undefined) {
|
||||
contextValue.value = currentValue;
|
||||
}
|
||||
contextValue.onValueChange = handleValueChange;
|
||||
|
||||
return (
|
||||
<SelectContext.Provider value={{ value: currentValue, onValueChange: handleValueChange, isOpen, setIsOpen }}>
|
||||
<SelectContext.Provider value={contextValue}>
|
||||
<div className="relative">{children}</div>
|
||||
</SelectContext.Provider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user