(fix:prompts) show delete only when possible

This commit is contained in:
ManishMadan2882
2025-06-19 02:18:20 +05:30
parent 55a1d867c3
commit 5bc28bd4fd
2 changed files with 11 additions and 4 deletions

View File

@@ -53,7 +53,7 @@ function Dropdown({
darkBorderColor?: string;
showEdit?: boolean;
onEdit?: (value: { name: string; id: string; type: string }) => void;
showDelete?: boolean;
showDelete?: boolean | ((option: any) => boolean);
onDelete?: (value: string) => void;
placeholder?: string;
placeholderTextColor?: string;
@@ -173,8 +173,15 @@ function Dropdown({
)}
{showDelete && onDelete && (
<button
onClick={() => onDelete(option.id)}
disabled={option.type === 'public'}
onClick={(e) => {
e.stopPropagation();
onDelete?.(typeof option === 'string' ? option : option.id);
}}
className={`${
typeof showDelete === 'function' && !showDelete(option)
? 'hidden'
: ''
} mr-2 h-4 w-4 cursor-pointer hover:opacity-50`}
>
<img
src={Trash}

View File

@@ -177,7 +177,7 @@ export default function Prompts({
rounded="3xl"
border="border"
showEdit
showDelete
showDelete={(prompt) => prompt.type !== 'public'}
onEdit={({
id,
name,