Skip to content

Commit 1811a64

Browse files
committed
add optional input prop to confirmation modal
1 parent 472d068 commit 1811a64

2 files changed

Lines changed: 14 additions & 9 deletions

File tree

src/app/trips/[id]/itinerary/_components/ItineraryAccordion.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,8 +392,9 @@ function ItineraryAccordion({ trip }: DailyItineraryAccordionProps) {
392392
buttonText="Delete"
393393
icon="Trash"
394394
iconColor="red-500"
395-
text="Are you sure you want to delete this itinerary item?"
395+
text="Are you sure you want to delete this item?"
396396
confirmation="Delete"
397+
showInput={false}
397398
onConfirm={() => handleDeleteItem(item.id)}
398399
/>
399400
</>

src/app/trips/_components/ConfirmationModal.tsx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ interface ConfirmationModalProps {
1616
confirmation: string;
1717
icon?: string;
1818
iconColor?: string;
19-
onConfirm: () => Promise<void>; // async now
19+
onConfirm: () => Promise<void>;
20+
showInput?: boolean;
2021
}
2122

2223
function ConfirmationModal({
@@ -25,6 +26,7 @@ function ConfirmationModal({
2526
confirmation,
2627
icon,
2728
iconColor = "black",
29+
showInput = true,
2830
onConfirm,
2931
}: ConfirmationModalProps) {
3032
const [inputValue, setInputValue] = useState("");
@@ -68,15 +70,17 @@ function ConfirmationModal({
6870
</DialogHeader>
6971

7072
<div className="flex flex-col items-center justify-center space-y-5">
71-
<Input
72-
value={inputValue}
73-
onChange={(e) => setInputValue(e.target.value)}
74-
placeholder={`Type "${confirmation}" to confirm`}
75-
disabled={loading}
76-
/>
73+
{showInput && (
74+
<Input
75+
value={inputValue}
76+
onChange={(e) => setInputValue(e.target.value)}
77+
placeholder={`Type "${confirmation}" to confirm`}
78+
disabled={loading}
79+
/>
80+
)}
7781
<Button
7882
variant="destructive"
79-
disabled={!isMatch || loading}
83+
disabled={showInput ? !isMatch || loading : loading}
8084
onClick={handleConfirm}
8185
>
8286
{icon && <Icon name={icon} size="20" />}

0 commit comments

Comments
 (0)