2023-12-22 17:24:05 +05:30
|
|
|
import React from 'react';
|
|
|
|
|
|
2023-12-29 22:11:44 +05:30
|
|
|
import { Button } from './button';
|
2023-12-22 17:24:05 +05:30
|
|
|
import {
|
|
|
|
|
Dialog,
|
|
|
|
|
DialogContent,
|
|
|
|
|
DialogDescription,
|
|
|
|
|
DialogFooter,
|
2023-12-29 22:11:44 +05:30
|
|
|
DialogHeader,
|
|
|
|
|
DialogTitle,
|
|
|
|
|
} from './dialog';
|
|
|
|
|
import { Input } from './input';
|
2023-12-22 17:24:05 +05:30
|
|
|
|
|
|
|
|
type PasswordDialogProps = {
|
|
|
|
|
open: boolean;
|
|
|
|
|
onOpenChange: (_open: boolean) => void;
|
|
|
|
|
setPassword: (_password: string) => void;
|
2023-12-29 22:11:44 +05:30
|
|
|
onPasswordSubmit: () => void;
|
2023-12-22 17:24:05 +05:30
|
|
|
isError?: boolean;
|
2023-12-29 22:11:44 +05:30
|
|
|
};
|
2023-12-22 17:24:05 +05:30
|
|
|
|
2023-12-29 22:11:44 +05:30
|
|
|
export const PasswordDialog = ({
|
|
|
|
|
open,
|
|
|
|
|
onOpenChange,
|
|
|
|
|
onPasswordSubmit,
|
|
|
|
|
isError,
|
|
|
|
|
setPassword,
|
|
|
|
|
}: PasswordDialogProps) => {
|
2023-12-22 17:24:05 +05:30
|
|
|
return (
|
|
|
|
|
<Dialog open={open} onOpenChange={onOpenChange}>
|
|
|
|
|
<DialogContent className="max-w-md">
|
|
|
|
|
<DialogHeader>
|
|
|
|
|
<DialogTitle>Password Required</DialogTitle>
|
2023-12-29 22:11:44 +05:30
|
|
|
<DialogDescription className="text-muted-foreground">
|
|
|
|
|
This document is password protected. Please enter the password to view the document.
|
2023-12-22 17:24:05 +05:30
|
|
|
</DialogDescription>
|
|
|
|
|
</DialogHeader>
|
|
|
|
|
<DialogFooter className="flex w-full items-center justify-center gap-4">
|
|
|
|
|
<Input
|
|
|
|
|
type="password"
|
|
|
|
|
className="bg-background mt-1.5"
|
2023-12-29 22:11:44 +05:30
|
|
|
placeholder="Enter password"
|
2023-12-22 17:24:05 +05:30
|
|
|
onChange={(e) => setPassword(e.target.value)}
|
2023-12-29 22:11:44 +05:30
|
|
|
autoComplete="off"
|
2023-12-22 17:24:05 +05:30
|
|
|
/>
|
2023-12-29 22:11:44 +05:30
|
|
|
<Button onClick={onPasswordSubmit}>Submit</Button>
|
2023-12-22 17:24:05 +05:30
|
|
|
</DialogFooter>
|
2023-12-29 22:11:44 +05:30
|
|
|
{isError && (
|
|
|
|
|
<span className="text-xs text-red-500">
|
|
|
|
|
The password you entered is incorrect. Please try again.
|
|
|
|
|
</span>
|
|
|
|
|
)}
|
2023-12-22 17:24:05 +05:30
|
|
|
</DialogContent>
|
|
|
|
|
</Dialog>
|
|
|
|
|
);
|
|
|
|
|
};
|