Remove date fields and add job dump import
Removed date fields from the job form and added a text area for importing job dumps.
This commit is contained in:
@@ -1,8 +1,10 @@
|
|||||||
|
|
||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||||
import { Button } from '@/components/ui/button';
|
import { Button } from '@/components/ui/button';
|
||||||
import { Input } from '@/components/ui/input';
|
import { Input } from '@/components/ui/input';
|
||||||
import { Label } from '@/components/ui/label';
|
import { Label } from '@/components/ui/label';
|
||||||
|
import { Textarea } from '@/components/ui/textarea';
|
||||||
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select';
|
||||||
import { IndJobStatusOptions, IndJobRecordNoId } from '@/lib/pbtypes';
|
import { IndJobStatusOptions, IndJobRecordNoId } from '@/lib/pbtypes';
|
||||||
import { IndJob } from '@/lib/types';
|
import { IndJob } from '@/lib/types';
|
||||||
@@ -14,48 +16,23 @@ interface JobFormProps {
|
|||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const formatDateForInput = (dateString: string | undefined | null): string => {
|
|
||||||
if (!dateString) return '';
|
|
||||||
|
|
||||||
// Create a date object in local timezone
|
|
||||||
const date = new Date(dateString);
|
|
||||||
|
|
||||||
// Format to YYYY-MM-DD
|
|
||||||
const year = date.getFullYear();
|
|
||||||
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
||||||
const day = String(date.getDate()).padStart(2, '0');
|
|
||||||
|
|
||||||
// Format to HH:MM
|
|
||||||
const hours = String(date.getHours()).padStart(2, '0');
|
|
||||||
const minutes = String(date.getMinutes()).padStart(2, '0');
|
|
||||||
|
|
||||||
// Combine into format required by datetime-local (YYYY-MM-DDTHH:MM)
|
|
||||||
return `${year}-${month}-${day}T${hours}:${minutes}`;
|
|
||||||
};
|
|
||||||
|
|
||||||
const JobForm: React.FC<JobFormProps> = ({ job, onSubmit, onCancel }) => {
|
const JobForm: React.FC<JobFormProps> = ({ job, onSubmit, onCancel }) => {
|
||||||
const [formData, setFormData] = useState({
|
const [formData, setFormData] = useState({
|
||||||
outputItem: job?.outputItem || '',
|
outputItem: job?.outputItem || '',
|
||||||
outputQuantity: job?.outputQuantity || 0,
|
outputQuantity: job?.outputQuantity || 0,
|
||||||
jobStart: formatDateForInput(job?.jobStart),
|
|
||||||
jobEnd: formatDateForInput(job?.jobEnd),
|
|
||||||
saleStart: formatDateForInput(job?.saleStart),
|
|
||||||
saleEnd: formatDateForInput(job?.saleEnd),
|
|
||||||
status: job?.status || IndJobStatusOptions.Planned,
|
status: job?.status || IndJobStatusOptions.Planned,
|
||||||
projectedCost: job?.projectedCost || 0,
|
projectedCost: job?.projectedCost || 0,
|
||||||
projectedRevenue: job?.projectedRevenue || 0
|
projectedRevenue: job?.projectedRevenue || 0
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const [jobDump, setJobDump] = useState('');
|
||||||
|
|
||||||
const handleSubmit = (e: React.FormEvent) => {
|
const handleSubmit = (e: React.FormEvent) => {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
onSubmit({
|
onSubmit({
|
||||||
outputItem: formData.outputItem,
|
outputItem: formData.outputItem,
|
||||||
outputQuantity: formData.outputQuantity,
|
outputQuantity: formData.outputQuantity,
|
||||||
jobStart: formData.jobStart || undefined,
|
|
||||||
jobEnd: formData.jobEnd || undefined,
|
|
||||||
saleStart: formData.saleStart || undefined,
|
|
||||||
saleEnd: formData.saleEnd || undefined,
|
|
||||||
status: formData.status,
|
status: formData.status,
|
||||||
projectedCost: formData.projectedCost,
|
projectedCost: formData.projectedCost,
|
||||||
projectedRevenue: formData.projectedRevenue
|
projectedRevenue: formData.projectedRevenue
|
||||||
@@ -122,64 +99,6 @@ const JobForm: React.FC<JobFormProps> = ({ job, onSubmit, onCancel }) => {
|
|||||||
</Select>
|
</Select>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="grid grid-cols-2 gap-4">
|
|
||||||
<div className="space-y-2">
|
|
||||||
<Label htmlFor="startDate" className="text-gray-300">Start Date & Time</Label>
|
|
||||||
<Input
|
|
||||||
id="startDate"
|
|
||||||
type="datetime-local"
|
|
||||||
value={formData.jobStart}
|
|
||||||
onChange={(e) => setFormData({
|
|
||||||
...formData,
|
|
||||||
jobStart: e.target.value
|
|
||||||
})}
|
|
||||||
className="bg-gray-800 border-gray-600 text-white"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="space-y-2">
|
|
||||||
<Label htmlFor="endDate" className="text-gray-300">End Date & Time</Label>
|
|
||||||
<Input
|
|
||||||
id="endDate"
|
|
||||||
type="datetime-local"
|
|
||||||
value={formData.jobEnd}
|
|
||||||
onChange={(e) => setFormData({
|
|
||||||
...formData,
|
|
||||||
jobEnd: e.target.value
|
|
||||||
})}
|
|
||||||
className="bg-gray-800 border-gray-600 text-white"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="grid grid-cols-2 gap-4">
|
|
||||||
<div className="space-y-2">
|
|
||||||
<Label htmlFor="saleStartDate" className="text-gray-300">Sale Start Date & Time</Label>
|
|
||||||
<Input
|
|
||||||
id="saleStartDate"
|
|
||||||
type="datetime-local"
|
|
||||||
value={formData.saleStart}
|
|
||||||
onChange={(e) => setFormData({
|
|
||||||
...formData,
|
|
||||||
saleStart: e.target.value
|
|
||||||
})}
|
|
||||||
className="bg-gray-800 border-gray-600 text-white"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
<div className="space-y-2">
|
|
||||||
<Label htmlFor="saleEndDate" className="text-gray-300">Sale End Date & Time</Label>
|
|
||||||
<Input
|
|
||||||
id="saleEndDate"
|
|
||||||
type="datetime-local"
|
|
||||||
value={formData.saleEnd}
|
|
||||||
onChange={(e) => setFormData({
|
|
||||||
...formData,
|
|
||||||
saleEnd: e.target.value
|
|
||||||
})}
|
|
||||||
className="bg-gray-800 border-gray-600 text-white"
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="grid grid-cols-2 gap-4">
|
<div className="grid grid-cols-2 gap-4">
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Label htmlFor="projectedCost" className="text-gray-300">Projected Cost</Label>
|
<Label htmlFor="projectedCost" className="text-gray-300">Projected Cost</Label>
|
||||||
@@ -209,6 +128,18 @@ const JobForm: React.FC<JobFormProps> = ({ job, onSubmit, onCancel }) => {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div className="space-y-2">
|
||||||
|
<Label htmlFor="jobDump" className="text-gray-300">Job Dump Import</Label>
|
||||||
|
<Textarea
|
||||||
|
id="jobDump"
|
||||||
|
value={jobDump}
|
||||||
|
onChange={(e) => setJobDump(e.target.value)}
|
||||||
|
placeholder="Paste job dump here: Standup Light Guided Bomb 100 285,224,182 771,342,930 Megacyte 37 Zydrine 84 ..."
|
||||||
|
className="bg-gray-800 border-gray-600 text-white min-h-[120px]"
|
||||||
|
rows={6}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="flex gap-2 pt-4">
|
<div className="flex gap-2 pt-4">
|
||||||
<Button type="submit" className="flex-1 bg-blue-600 hover:bg-blue-700">
|
<Button type="submit" className="flex-1 bg-blue-600 hover:bg-blue-700">
|
||||||
{job ? 'Update Job' : 'Create Job'}
|
{job ? 'Update Job' : 'Create Job'}
|
||||||
|
Reference in New Issue
Block a user