From cb58d8fd330663c4a6f5bbf4bdeaa649f20f780d Mon Sep 17 00:00:00 2001 From: chark1es Date: Wed, 19 Feb 2025 06:14:51 -0800 Subject: [PATCH] add animation and more information --- .../dashboard/reimbursement/ReceiptForm.tsx | 367 +++++---- .../reimbursement/ReimbursementForm.tsx | 634 +++++++++++---- .../reimbursement/ReimbursementList.tsx | 762 ++++++++++++------ .../ReimbursementManagementPortal.tsx | 250 +++++- .../dashboard/reimbursement/ToastProvider.tsx | 19 + 5 files changed, 1464 insertions(+), 568 deletions(-) create mode 100644 src/components/dashboard/reimbursement/ToastProvider.tsx diff --git a/src/components/dashboard/reimbursement/ReceiptForm.tsx b/src/components/dashboard/reimbursement/ReceiptForm.tsx index 81a3015..1b63346 100644 --- a/src/components/dashboard/reimbursement/ReceiptForm.tsx +++ b/src/components/dashboard/reimbursement/ReceiptForm.tsx @@ -1,6 +1,8 @@ import React, { useState } from 'react'; import { Icon } from '@iconify/react'; import FilePreview from '../universal/FilePreview'; +import { toast } from 'react-hot-toast'; +import { motion, AnimatePresence } from 'framer-motion'; interface ExpenseItem { description: string; @@ -33,6 +35,30 @@ const EXPENSE_CATEGORIES = [ 'Other' ]; +// Add these animation variants +const containerVariants = { + hidden: { opacity: 0 }, + visible: { + opacity: 1, + transition: { + staggerChildren: 0.1 + } + } +}; + +const itemVariants = { + hidden: { opacity: 0, y: 20 }, + visible: { + opacity: 1, + y: 0, + transition: { + type: "spring", + stiffness: 300, + damping: 24 + } + } +}; + export default function ReceiptForm({ onSubmit, onCancel }: ReceiptFormProps) { const [file, setFile] = useState(null); const [previewUrl, setPreviewUrl] = useState(''); @@ -52,12 +78,14 @@ export default function ReceiptForm({ onSubmit, onCancel }: ReceiptFormProps) { // Validate file type if (!selectedFile.type.match('image/*') && selectedFile.type !== 'application/pdf') { + toast.error('Only images and PDF files are allowed'); setError('Only images and PDF files are allowed'); return; } // Validate file size (5MB limit) if (selectedFile.size > 5 * 1024 * 1024) { + toast.error('File size must be less than 5MB'); setError('File size must be less than 5MB'); return; } @@ -65,6 +93,7 @@ export default function ReceiptForm({ onSubmit, onCancel }: ReceiptFormProps) { setFile(selectedFile); setPreviewUrl(URL.createObjectURL(selectedFile)); setError(''); + toast.success('File uploaded successfully'); } }; @@ -121,232 +150,298 @@ export default function ReceiptForm({ onSubmit, onCancel }: ReceiptFormProps) { }; return ( -
+ {/* Left side - Form */} -
-
- {error && ( -
- - {error} -
- )} + + + + {error && ( + + + {error} + + )} + {/* File Upload */} -
+ - -
+
+ +
+ +
+
+
{/* Date */} -
+ setDate(e.target.value)} required /> -
+ {/* Location Name */} -
+ setLocationName(e.target.value)} required /> -
+ {/* Location Address */} -
+ setLocationAddress(e.target.value)} required /> -
+ {/* Notes */} -
+