'use client';
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 { Textarea } from '@kandev/ui/textarea';
// --- 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;
};
export function CommitDialog({
open,
onOpenChange,
commitMessage,
onCommitMessageChange,
onCommit,
isLoading,
stagedFileCount,
stagedAdditions,
stagedDeletions,
}: CommitDialogProps) {
return (
);
}
function CommitDialogStats({
stagedFileCount,
stagedAdditions,
stagedDeletions,
}: {
stagedFileCount: number;
stagedAdditions: number;
stagedDeletions: number;
}) {
return (
{stagedFileCount > 0 ? (
{stagedFileCount}{' '}
staged file{stagedFileCount !== 1 ? 's' : ''}
{(stagedAdditions > 0 || stagedDeletions > 0) && (
(+{stagedAdditions}
{' / '}
-{stagedDeletions})
)}
) : (
No staged files to commit
)}
);
}
// --- Create PR Dialog ---
type PRDialogProps = {
open: boolean;
onOpenChange: (open: boolean) => void;
prTitle: string;
onPrTitleChange: (value: string) => void;
prBody: string;
onPrBodyChange: (value: string) => void;
prDraft: boolean;
onPrDraftChange: (value: boolean) => void;
onCreatePR: () => void;
isLoading: boolean;
displayBranch: string | null;
baseBranch: string | undefined;
};
export function PRDialog({
open,
onOpenChange,
prTitle,
onPrTitleChange,
prBody,
onPrBodyChange,
prDraft,
onPrDraftChange,
onCreatePR,
isLoading,
displayBranch,
baseBranch,
}: PRDialogProps) {
return (
);
}
function PRBranchInfo({
displayBranch,
baseBranch,
}: {
displayBranch: string;
baseBranch: string | undefined;
}) {
return (
{baseBranch ? (
Creating PR from{' '}
{displayBranch}{' '}
→{' '}
{baseBranch}
) : (
Creating PR from{' '}
{displayBranch}
)}
);
}