Document Upload Dialogue update

This commit is contained in:
Koncept Kit
2026-01-02 15:35:30 +07:00
parent a6c2475092
commit 33a4d8f4c4
3 changed files with 47 additions and 26 deletions

View File

@@ -44,7 +44,7 @@ const AdminBylaws = () => {
version: '',
effective_date: '',
document_url: '',
document_type: 'google_drive',
document_type: 'link',
is_current: false
});
const [submitting, setSubmitting] = useState(false);
@@ -71,9 +71,10 @@ const AdminBylaws = () => {
version: '',
effective_date: new Date().toISOString().split('T')[0],
document_url: '',
document_type: 'google_drive',
document_type: 'link',
is_current: bylaws.length === 0 // Auto-check if this is the first bylaws
});
setUploadedFile(null);
setDialogOpen(true);
};
@@ -246,7 +247,7 @@ const AdminBylaws = () => {
<div className="flex items-center gap-4 text-sm text-[#664fa3]">
<span>Effective Date: <strong>{formatDate(currentBylaws.effective_date)}</strong></span>
<span></span>
<span>Document Type: <strong>{currentBylaws.document_type === 'google_drive' ? 'Google Drive' : currentBylaws.document_type.toUpperCase()}</strong></span>
<span>Document Type: <strong>{currentBylaws.document_type === 'upload' ? 'PDF Upload' : 'Link'}</strong></span>
</div>
</Card>
) : (
@@ -363,14 +364,16 @@ const AdminBylaws = () => {
<Label htmlFor="document_type">Document Type *</Label>
<Select
value={formData.document_type}
onValueChange={(value) => setFormData({ ...formData, document_type: value })}
onValueChange={(value) => {
setFormData({ ...formData, document_type: value, document_url: '' });
setUploadedFile(null);
}}
>
<SelectTrigger>
<SelectValue />
</SelectTrigger>
<SelectContent>
<SelectItem value="google_drive">Google Drive</SelectItem>
<SelectItem value="pdf">PDF</SelectItem>
<SelectItem value="link">Link</SelectItem>
<SelectItem value="upload">Upload</SelectItem>
</SelectContent>
</Select>
@@ -391,6 +394,11 @@ const AdminBylaws = () => {
Selected: {uploadedFile.name}
</p>
)}
{selectedBylaws && !uploadedFile && (
<p className="text-sm text-[#664fa3] mt-1">
Current file will be kept if no new file is selected
</p>
)}
</div>
) : (
<div>
@@ -399,12 +407,11 @@ const AdminBylaws = () => {
id="document_url"
value={formData.document_url}
onChange={(e) => setFormData({ ...formData, document_url: e.target.value })}
placeholder="https://drive.google.com/file/d/..."
placeholder="https://docs.google.com/... or https://example.com/file.pdf"
required
/>
<p className="text-sm text-[#664fa3] mt-1">
{formData.document_type === 'google_drive' && 'Paste the shareable link to your Google Drive file'}
{formData.document_type === 'pdf' && 'Paste the URL to your PDF file'}
Paste the shareable link to your document (Google Drive, Dropbox, PDF URL, etc.)
</p>
</div>
)}