page.tsx 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. "use client";
  2. import { useState } from 'react';
  3. import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
  4. import { Button } from '@/components/ui/button';
  5. import { Upload, FileText, Database, BarChart3, CheckCircle } from 'lucide-react';
  6. import { UploadForm } from '@/app/components/uploadForm';
  7. interface FileData {
  8. id: string;
  9. filename: string;
  10. mimetype: string;
  11. size: number;
  12. createdAt: string;
  13. updatedAt: string;
  14. }
  15. export default function CintasCalendarSummaryPage() {
  16. const [currentStep, setCurrentStep] = useState(1);
  17. const [uploadedFile, setUploadedFile] = useState<FileData | null>(null);
  18. const [isProcessing, setIsProcessing] = useState(false);
  19. const handleFileUploaded = (file: FileData) => {
  20. setUploadedFile(file);
  21. setCurrentStep(2);
  22. };
  23. const steps = [
  24. {
  25. id: 1,
  26. title: 'Upload Excel File',
  27. description: 'Upload the Cintas Install Calendar Excel file to blob storage',
  28. icon: Upload,
  29. status: currentStep >= 1 ? 'completed' : 'pending',
  30. },
  31. {
  32. id: 2,
  33. title: 'Create Import Record',
  34. description: 'Create an import record with Cintas Install Calendar layout configuration',
  35. icon: FileText,
  36. status: currentStep >= 2 ? 'pending' : 'disabled',
  37. },
  38. {
  39. id: 3,
  40. title: 'Import Data',
  41. description: 'Read the Excel file and import data into PostgreSQL database',
  42. icon: Database,
  43. status: currentStep >= 3 ? 'pending' : 'disabled',
  44. },
  45. {
  46. id: 4,
  47. title: 'Generate Summary',
  48. description: 'Run summary calculation and display results',
  49. icon: BarChart3,
  50. status: currentStep >= 4 ? 'pending' : 'disabled',
  51. },
  52. ];
  53. const getStepStatusColor = (status: string) => {
  54. switch (status) {
  55. case 'completed':
  56. return 'text-green-600 bg-green-50 border-green-200';
  57. case 'pending':
  58. return 'text-blue-600 bg-blue-50 border-blue-200';
  59. case 'disabled':
  60. return 'text-gray-400 bg-gray-50 border-gray-200';
  61. default:
  62. return 'text-gray-600 bg-gray-50 border-gray-200';
  63. }
  64. };
  65. return (
  66. <div className="container mx-auto py-6 px-4 max-w-6xl">
  67. <div className="mb-8">
  68. <h1 className="text-3xl font-bold tracking-tight">Cintas Install Calendar Summary</h1>
  69. <p className="text-muted-foreground">
  70. Follow the workflow steps to upload and process the installation calendar data
  71. </p>
  72. </div>
  73. {/* Workflow Steps */}
  74. <div className="mb-8">
  75. <div className="grid grid-cols-1 md:grid-cols-4 gap-4">
  76. {steps.map((step) => {
  77. const Icon = step.icon;
  78. return (
  79. <Card
  80. key={step.id}
  81. className={`border-2 ${getStepStatusColor(step.status)}`}
  82. >
  83. <CardHeader className="pb-3">
  84. <div className="flex items-center space-x-2">
  85. <Icon className="h-5 w-5" />
  86. <CardTitle className="text-sm font-medium">
  87. Step {step.id}: {step.title}
  88. </CardTitle>
  89. </div>
  90. </CardHeader>
  91. <CardContent>
  92. <CardDescription className="text-xs">
  93. {step.description}
  94. </CardDescription>
  95. </CardContent>
  96. </Card>
  97. );
  98. })}
  99. </div>
  100. </div>
  101. {/* Step Content */}
  102. <div className="grid gap-6">
  103. {currentStep === 1 && (
  104. <Card>
  105. <CardHeader>
  106. <CardTitle>Step 1: Upload Excel File</CardTitle>
  107. <CardDescription>
  108. Upload your Cintas Install Calendar Excel file to begin processing
  109. </CardDescription>
  110. </CardHeader>
  111. <CardContent>
  112. <div className="space-y-4">
  113. <UploadForm onFileUploaded={handleFileUploaded} />
  114. {uploadedFile && (
  115. <div className="mt-4 p-4 bg-green-50 border border-green-200 rounded-lg">
  116. <div className="flex items-center space-x-2">
  117. <CheckCircle className="h-5 w-5 text-green-600" />
  118. <div>
  119. <p className="text-sm font-medium text-green-800">File uploaded successfully!</p>
  120. <p className="text-sm text-green-600">
  121. {uploadedFile.filename} ({(uploadedFile.size / 1024 / 1024).toFixed(2)} MB)
  122. </p>
  123. </div>
  124. </div>
  125. </div>
  126. )}
  127. </div>
  128. </CardContent>
  129. </Card>
  130. )}
  131. {currentStep === 2 && (
  132. <Card>
  133. <CardHeader>
  134. <CardTitle>Step 2: Create Import Record</CardTitle>
  135. <CardDescription>
  136. Creating import record with Cintas Install Calendar layout configuration
  137. </CardDescription>
  138. </CardHeader>
  139. <CardContent>
  140. <div className="space-y-4">
  141. <div className="flex items-center justify-center py-8">
  142. <div className="text-center">
  143. <FileText className="h-12 w-12 text-gray-400 mx-auto mb-4" />
  144. <p className="text-muted-foreground">
  145. Import record creation functionality coming soon...
  146. </p>
  147. </div>
  148. </div>
  149. </div>
  150. </CardContent>
  151. </Card>
  152. )}
  153. {currentStep === 3 && (
  154. <Card>
  155. <CardHeader>
  156. <CardTitle>Step 3: Import Data</CardTitle>
  157. <CardDescription>
  158. Processing Excel file and importing data into database
  159. </CardDescription>
  160. </CardHeader>
  161. <CardContent>
  162. <div className="flex items-center justify-center py-8">
  163. <div className="text-center">
  164. <Database className="h-12 w-12 text-gray-400 mx-auto mb-4" />
  165. <p className="text-muted-foreground">
  166. Data import functionality coming soon...
  167. </p>
  168. </div>
  169. </div>
  170. </CardContent>
  171. </Card>
  172. )}
  173. {currentStep === 4 && (
  174. <Card>
  175. <CardHeader>
  176. <CardTitle>Step 4: Generate Summary</CardTitle>
  177. <CardDescription>
  178. Running summary calculations and displaying results
  179. </CardDescription>
  180. </CardHeader>
  181. <CardContent>
  182. <div className="flex items-center justify-center py-8">
  183. <div className="text-center">
  184. <BarChart3 className="h-12 w-12 text-gray-400 mx-auto mb-4" />
  185. <p className="text-muted-foreground">
  186. Summary generation functionality coming soon...
  187. </p>
  188. </div>
  189. </div>
  190. </CardContent>
  191. </Card>
  192. )}
  193. {/* Navigation */}
  194. <div className="flex justify-between">
  195. <Button
  196. variant="outline"
  197. onClick={() => setCurrentStep(Math.max(1, currentStep - 1))}
  198. disabled={currentStep === 1}
  199. >
  200. Previous
  201. </Button>
  202. <Button
  203. onClick={() => setCurrentStep(Math.min(4, currentStep + 1))}
  204. disabled={currentStep === 4 || !uploadedFile}
  205. >
  206. Next
  207. </Button>
  208. </div>
  209. </div>
  210. </div>
  211. );
  212. }