"use client"; import { useState } from "react"; import { IconGitCommit, IconGitPullRequest, IconLoader2, IconCheck } from "@tabler/icons-react"; import { Button } from "@kandev/ui/button"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter, DialogClose, } from "@kandev/ui/dialog"; import { AlertDialog, AlertDialogAction, AlertDialogCancel, AlertDialogContent, AlertDialogDescription, AlertDialogFooter, AlertDialogHeader, AlertDialogTitle, } from "@kandev/ui/alert-dialog"; import { Checkbox } from "@kandev/ui/checkbox"; import { Label } from "@kandev/ui/label"; import { Input } from "@kandev/ui/input"; import { Textarea } from "@kandev/ui/textarea"; import { RadioGroup, RadioGroupItem } from "@kandev/ui/radio-group"; // --- Discard Confirmation Dialog --- type DiscardDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; fileToDiscard: string | null; onConfirm: () => void; }; export function DiscardDialog({ open, onOpenChange, fileToDiscard, onConfirm, }: DiscardDialogProps) { return ( Discard changes? This will permanently discard all changes to{" "} {fileToDiscard}. This action cannot be undone. Cancel Discard ); } // --- Commit Dialog --- type CommitDialogProps = { open: boolean; onOpenChange: (open: boolean) => void; commitMessage: string; onCommitMessageChange: (value: string) => void; onCommit: () => void; isLoading: boolean; stagedFileCount: number; stagedAdditions: number; stagedDeletions: number; isAmend?: boolean; onAmendChange?: (amend: boolean) => void; lastCommitMessage?: string | null; }; export function CommitDialog({ open, onOpenChange, commitMessage, onCommitMessageChange, onCommit, isLoading, stagedFileCount, stagedAdditions, stagedDeletions, isAmend = false, onAmendChange, lastCommitMessage, }: CommitDialogProps) { return ( {isAmend ? "Amend Commit" : "Commit Changes"}
{onAmendChange && (
{ onAmendChange(checked === true); // Pre-fill with last commit message when enabling amend if (checked === true && lastCommitMessage && !commitMessage.trim()) { onCommitMessageChange(lastCommitMessage); } }} />
)}