Skip to content

Commit

Permalink
Fix Boms
Browse files Browse the repository at this point in the history
  • Loading branch information
Peyton-McKee committed Jan 24, 2025
1 parent 9dee77d commit 24359f7
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 10 deletions.
8 changes: 6 additions & 2 deletions src/frontend/src/apis/bom.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,13 @@ export const assignMaterialToAssembly = async (materialId: string, payload: { as
};

export const getAssembliesForWbsElement = async (wbsNum: WbsNumber) => {
return axios.get<Assembly[]>(apiUrls.bomGetAssembliesByWbsNum(wbsNum));
return axios.get<Assembly[]>(apiUrls.bomGetAssembliesByWbsNum(wbsNum), {
transformResponse: (data) => JSON.parse(data)
});
};

export const getMaterialsForWbsElement = async (wbsNum: WbsNumber) => {
return axios.get<Material[]>(apiUrls.bomGetMaterialsByWbsNum(wbsNum));
return axios.get<Material[]>(apiUrls.bomGetMaterialsByWbsNum(wbsNum), {
transformResponse: (data) => JSON.parse(data)
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const BOMTable: React.FC<BOMTableProps> = ({ setHideColumn, columns, materials,
const [openRows, setOpenRows] = useState<String[]>([]);

const arrowSymbol = (rowId: string) => {
return openRows.includes(rowId) ? '' : '';
return openRows.includes(rowId) ? '' : '';
};

const noAssemblyMaterials = materials.filter((material) => !material.assembly);
Expand Down Expand Up @@ -49,9 +49,7 @@ const BOMTable: React.FC<BOMTableProps> = ({ setHideColumn, columns, materials,
type: '',
name: '',
manufacturer: '',
manufacturerPN: `Assembly - ${assembly.name}: $${centsToDollar(
assembly.materials.reduce(addMaterialCosts, 0)
)} ${arrowSymbol(assembly.assemblyId)}`,
manufacturerPN: `Assembly - ${assembly.name}: $${centsToDollar(assembly.materials.reduce(addMaterialCosts, 0))} ${arrowSymbol(assembly.assemblyId)}`,
pdmFileName: '',
quantity: '',
price: '',
Expand All @@ -66,7 +64,7 @@ const BOMTable: React.FC<BOMTableProps> = ({ setHideColumn, columns, materials,
return (
<Box
sx={{
height: 'calc(100vh - 180px)',
height: 'calc(100vh - 200px)',
width: '100%',
'& .super-app-theme--header': {
backgroundColor: '#ef4345'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const BOMTab = ({ project }: { project: Project }) => {

if (assembliesIsLoading || materialsIsLoading || !materials || !assemblies) return <LoadingIndicator />;

console.log(assemblies);
const totalCost = materials.reduce(addMaterialCosts, 0);

return (
Expand All @@ -55,7 +56,7 @@ const BOMTab = ({ project }: { project: Project }) => {
assemblies={assemblies}
/>
<CreateAssemblyModal open={showAddAssembly} onHide={() => setShowAddAssembly(false)} wbsElement={project} />
<Box sx={{ display: 'flex', flexDirection: 'column', justifyContent: 'space-between', height: 'calc(100vh - 220px)' }}>
<Box sx={{ display: 'flex', flexDirection: 'column', justifyContent: 'space-between' }}>
<BOMTableWrapper
project={project}
materials={materials}
Expand All @@ -64,7 +65,7 @@ const BOMTab = ({ project }: { project: Project }) => {
setHideColumn={setHideColumn}
/>
<Box justifyContent="space-between" display="flex" flexDirection="row">
<Box display="flex" gap="20px">
<Box display="flex" gap="20px" mb={1}>
<NERSuccessButton
variant="contained"
onClick={() => setShowAddMaterial(true)}
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/utils/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ const financeLeadershipApprove = (id: string) => `${financeEndpoints()}/${id}/le
const bomEndpoints = () => `${API_URL}/projects/bom`;
const materialEndpoints = () => `${bomEndpoints()}/material`;
const assemblyEndpoints = () => `${bomEndpoints()}/assembly`;
const bomGetMaterialsByWbsNum = (wbsNum: WbsNumber) => `${materialEndpoints}/${wbsPipe(wbsNum)}`;
const bomGetMaterialsByWbsNum = (wbsNum: WbsNumber) => `${bomEndpoints()}/${wbsPipe(wbsNum)}/materials`;
const bomGetAllUnits = () => `${bomEndpoints()}/units`;
const bomGetAllMaterialTypes = () => `${bomEndpoints()}/material-type`;
const bomGetAllManufacturers = () => `${bomEndpoints()}/manufacturer`;
Expand Down

0 comments on commit 24359f7

Please sign in to comment.