Refactor: Use new services and types
Update frontend components to use the new services and types for job management, including facilities, jobs, and transactions. Remove old type definitions and integrate the new ones.
This commit is contained in:
@@ -1,17 +1,16 @@
|
||||
|
||||
import React, { useState } from 'react';
|
||||
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
||||
import { Button } from '@/components/ui/button';
|
||||
import { Textarea } from '@/components/ui/textarea';
|
||||
import { Label } from '@/components/ui/label';
|
||||
import { Import, Download, FileText } from 'lucide-react';
|
||||
import { BillOfMaterialsItem, ConsumedMaterialsItem } from '@/services/jobService';
|
||||
import { IndBillitemRecord } from '@/lib/pbtypes';
|
||||
|
||||
interface MaterialsImportExportProps {
|
||||
billOfMaterials: BillOfMaterialsItem[];
|
||||
consumedMaterials: ConsumedMaterialsItem[];
|
||||
onBillOfMaterialsUpdate: (materials: BillOfMaterialsItem[]) => void;
|
||||
onConsumedMaterialsUpdate: (materials: ConsumedMaterialsItem[]) => void;
|
||||
billOfMaterials: IndBillitemRecord[];
|
||||
consumedMaterials: { name: string; required: number }[];
|
||||
onBillOfMaterialsUpdate: (materials: IndBillitemRecord[]) => void;
|
||||
onConsumedMaterialsUpdate: (materials: { name: string; required: number }[]) => void;
|
||||
}
|
||||
|
||||
const MaterialsImportExport: React.FC<MaterialsImportExportProps> = ({
|
||||
@@ -23,21 +22,27 @@ const MaterialsImportExport: React.FC<MaterialsImportExportProps> = ({
|
||||
const [bomInput, setBomInput] = useState('');
|
||||
const [consumedInput, setConsumedInput] = useState('');
|
||||
|
||||
const parseBillOfMaterials = (text: string): BillOfMaterialsItem[] => {
|
||||
const parseBillOfMaterials = (text: string): IndBillitemRecord[] => {
|
||||
return text.split('\n')
|
||||
.filter(line => line.trim())
|
||||
.map(line => {
|
||||
const parts = line.trim().split(/\s+/);
|
||||
const quantity = parseInt(parts[parts.length - 1]);
|
||||
const name = parts.slice(0, -1).join(' ');
|
||||
return { name, quantity };
|
||||
return {
|
||||
id: '',
|
||||
name,
|
||||
quantity,
|
||||
created: undefined,
|
||||
updated: undefined
|
||||
};
|
||||
})
|
||||
.filter(item => item.name && !isNaN(item.quantity));
|
||||
};
|
||||
|
||||
const parseConsumedMaterials = (text: string): ConsumedMaterialsItem[] => {
|
||||
const parseConsumedMaterials = (text: string): { name: string; required: number }[] => {
|
||||
const lines = text.split('\n').filter(line => line.trim());
|
||||
const materials: ConsumedMaterialsItem[] = [];
|
||||
const materials: { name: string; required: number }[] = [];
|
||||
|
||||
for (const line of lines) {
|
||||
const parts = line.trim().split('\t');
|
||||
|
Reference in New Issue
Block a user