Remove job status dropdown
Don't need it anymore
This commit is contained in:
@@ -47,18 +47,6 @@ const JobCardDetails: React.FC<JobCardDetailsProps> = ({ job }) => {
|
||||
}).replace(',', '');
|
||||
};
|
||||
|
||||
const roundToSignificantDigits = (num: number, digits: number = 4): number => {
|
||||
if (num === 0) return 0;
|
||||
const magnitude = Math.floor(Math.log10(Math.abs(num)));
|
||||
const factor = Math.pow(10, digits - 1 - magnitude);
|
||||
return Math.round(num * factor) / factor;
|
||||
};
|
||||
|
||||
const handleFieldClick = (fieldName: string, currentValue: string | null, e: React.MouseEvent) => {
|
||||
setEditingField(fieldName);
|
||||
setTempValues({ ...tempValues, [fieldName]: currentValue || '' });
|
||||
};
|
||||
|
||||
const handleJobIdClick = async (e: React.MouseEvent) => {
|
||||
e.stopPropagation();
|
||||
await copyToClipboard(job.id, 'id', 'Job ID copied to clipboard');
|
||||
@@ -358,7 +346,7 @@ const PriceDisplay: React.FC<PriceDisplayProps> = ({ job }) => {
|
||||
<DollarSign className="w-4 h-4" />
|
||||
<span>Adjusted Break-even{taxSuffix}:</span>
|
||||
</div>
|
||||
|
||||
|
||||
<div className="flex items-center gap-1 text-lg justify-center">
|
||||
<span
|
||||
className="cursor-pointer hover:text-blue-400 transition-colors inline-flex items-center gap-1 text-white"
|
||||
|
@@ -5,7 +5,6 @@ import { IndJob } from '@/lib/types';
|
||||
import { useClipboard } from '@/hooks/useClipboard';
|
||||
import { useJobs } from '@/hooks/useDataService';
|
||||
import { useState } from 'react';
|
||||
import JobStatusDropdown from './JobStatusDropdown';
|
||||
import JobStatusNavigation from './JobStatusNavigation';
|
||||
import BOMActions from './BOMActions';
|
||||
import EditableProduced from './EditableProduced';
|
||||
@@ -71,7 +70,6 @@ const JobCardHeader: React.FC<JobCardHeaderProps> = ({
|
||||
</div>
|
||||
<div className="flex flex-col gap-2 flex-shrink-0 items-end">
|
||||
<div className="flex items-center gap-2">
|
||||
<JobStatusDropdown job={job} />
|
||||
<Button
|
||||
variant="outline"
|
||||
size="sm"
|
||||
|
@@ -1,97 +0,0 @@
|
||||
|
||||
import {
|
||||
DropdownMenu,
|
||||
DropdownMenuContent,
|
||||
DropdownMenuItem,
|
||||
DropdownMenuTrigger,
|
||||
} from '@/components/ui/dropdown-menu';
|
||||
import { IndJob } from '@/lib/types';
|
||||
import { getStatusColor, JOB_STATUSES } from '@/utils/jobStatusUtils';
|
||||
import { useJobs } from '@/hooks/useDataService';
|
||||
import { useToast } from '@/hooks/use-toast';
|
||||
|
||||
interface JobStatusDropdownProps {
|
||||
job: IndJob;
|
||||
}
|
||||
|
||||
const JobStatusDropdown: React.FC<JobStatusDropdownProps> = ({ job }) => {
|
||||
const { updateJob } = useJobs();
|
||||
const { toast } = useToast();
|
||||
|
||||
const handleStatusChange = async (newStatus: string, e: React.MouseEvent) => {
|
||||
try {
|
||||
const currentTime = new Date().toISOString();
|
||||
const updates: { status: string; [key: string]: any } = { status: newStatus };
|
||||
|
||||
// Automatically assign dates based on status
|
||||
switch (newStatus) {
|
||||
case 'Running':
|
||||
updates.jobStart = currentTime;
|
||||
break;
|
||||
case 'Done':
|
||||
updates.jobEnd = currentTime;
|
||||
break;
|
||||
case 'Selling':
|
||||
updates.saleStart = currentTime;
|
||||
break;
|
||||
case 'Closed':
|
||||
updates.saleEnd = currentTime;
|
||||
break;
|
||||
}
|
||||
|
||||
await updateJob(job.id, updates);
|
||||
|
||||
const dateMessages = [];
|
||||
if (updates.jobStart) dateMessages.push('job start date set');
|
||||
if (updates.jobEnd) dateMessages.push('job end date set');
|
||||
if (updates.saleStart) dateMessages.push('sale start date set');
|
||||
if (updates.saleEnd) dateMessages.push('sale end date set');
|
||||
|
||||
const description = dateMessages.length > 0
|
||||
? `Job status changed to ${newStatus} and ${dateMessages.join(', ')}`
|
||||
: `Job status changed to ${newStatus}`;
|
||||
|
||||
toast({
|
||||
title: "Status Updated",
|
||||
description,
|
||||
duration: 2000,
|
||||
});
|
||||
} catch (error) {
|
||||
console.error('Error updating status:', error);
|
||||
toast({
|
||||
title: "Error",
|
||||
description: "Failed to update status",
|
||||
variant: "destructive",
|
||||
duration: 2000,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<DropdownMenu>
|
||||
<DropdownMenuTrigger asChild>
|
||||
<div
|
||||
className={`${getStatusColor(job.status)} text-white px-3 py-1 rounded-sm text-xs font-semibold cursor-pointer hover:opacity-80 transition-opacity`}
|
||||
data-no-navigate
|
||||
>
|
||||
{job.status}
|
||||
</div>
|
||||
</DropdownMenuTrigger>
|
||||
<DropdownMenuContent className="bg-gray-800/50 border-gray-600 text-white">
|
||||
{JOB_STATUSES.map((status) => (
|
||||
<DropdownMenuItem
|
||||
key={status}
|
||||
onClick={(e) => handleStatusChange(status, e)}
|
||||
className="hover:bg-gray-700 cursor-pointer"
|
||||
data-no-navigate
|
||||
>
|
||||
<div className={`w-3 h-3 rounded-sm ${getStatusColor(status)} mr-2`} />
|
||||
{status}
|
||||
</DropdownMenuItem>
|
||||
))}
|
||||
</DropdownMenuContent>
|
||||
</DropdownMenu>
|
||||
);
|
||||
};
|
||||
|
||||
export default JobStatusDropdown;
|
Reference in New Issue
Block a user