Skip to content

Commit 6b3726b

Browse files
committed
#4107 fixed naming
1 parent 3fa446c commit 6b3726b

3 files changed

Lines changed: 9 additions & 12 deletions

File tree

src/frontend/src/hooks/bom.hooks.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,10 +318,10 @@ export const useCreateMaterialType = () => {
318318
* @param wbsNum The wbs element the material belongs to
319319
* @returns mutation function to edit a material's status
320320
*/
321-
export const useEditMaterialStatus = (wbsNum: WbsNumber) => {
321+
export const useEditMaterialById = (wbsNum: WbsNumber) => {
322322
const queryClient = useQueryClient();
323323
return useMutation<Material, Error, { materialId: string; payload: MaterialDataSubmission }>(
324-
['materials', 'edit', 'status'],
324+
['materials', 'edit'],
325325
async ({ materialId, payload }) => {
326326
const data = await editMaterial(materialId, payload);
327327
return data;

src/frontend/src/pages/ProjectDetailPage/ProjectViewContainer/BOM/BOMTableCustomCells.tsx

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
/*
2-
* This file is part of NER's FinishLine and licensed under GNU AGPLv3.
3-
* See the LICENSE file in the repository root folder for details.
4-
*/
5-
61
import { useState } from 'react';
72
import { Box } from '@mui/system';
83
import { GridRenderCellParams } from '@mui/x-data-grid';
@@ -22,6 +17,8 @@ const getStatusColor = (status: MaterialStatus) => {
2217
return '#1b537a';
2318
case MaterialStatus.ReadyToOrder:
2419
return '#D34B27';
20+
default:
21+
return 'grey';
2522
}
2623
};
2724

src/frontend/src/pages/ProjectDetailPage/ProjectViewContainer/BOM/BOMTableWrapper.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import {
1313
useAssignMaterialToAssembly,
1414
useDeleteAssembly,
1515
useDeleteMaterial,
16-
useEditMaterialStatus,
16+
useEditMaterialById,
1717
useGetAllManufacturers,
1818
useGetAllMaterialTypes
1919
} from '../../../../hooks/bom.hooks';
@@ -51,8 +51,8 @@ const BOMTableWrapper: React.FC<BOMTableWrapperProps> = ({
5151
const [modalShow, setModalShow] = useState(false);
5252
const { mutateAsync: deleteMaterialMutateAsync, isLoading: deleteMaterialIsLoading } = useDeleteMaterial(project.wbsNum);
5353
const { mutateAsync: deleteAssemblyMutateAsync, isLoading: deleteAssemblyIsLoading } = useDeleteAssembly(project.wbsNum);
54-
const { mutateAsync: editMaterialStatus } = useEditMaterialStatus(project.wbsNum);
5554
const { mutateAsync: assignMaterialToAssembly } = useAssignMaterialToAssembly();
55+
const { mutateAsync: editMaterial } = useEditMaterialById(project.wbsNum);
5656
const { data: materialTypes } = useGetAllMaterialTypes();
5757
const { data: manufacturers } = useGetAllManufacturers();
5858

@@ -133,7 +133,6 @@ const BOMTableWrapper: React.FC<BOMTableWrapperProps> = ({
133133
const material = materials.find((m) => m.materialId === newRow.materialId);
134134
if (!material) return newRow;
135135

136-
// MUI writes the edited number directly to the field, so we detect changes via typeof
137136
const newQuantity = typeof newRow.quantity === 'number' ? (newRow.quantity as number) : null;
138137
const newPriceDollars = typeof newRow.price === 'number' ? (newRow.price as number) : null;
139138

@@ -174,7 +173,7 @@ const BOMTableWrapper: React.FC<BOMTableWrapperProps> = ({
174173
const quantityValue = newQuantity !== null ? newQuantity : Number(material.quantity);
175174

176175
try {
177-
await editMaterialStatus({
176+
await editMaterial({
178177
materialId: material.materialId,
179178
payload: {
180179
name: newRow.name,
@@ -370,6 +369,7 @@ const BOMTableWrapper: React.FC<BOMTableWrapperProps> = ({
370369
field: 'status',
371370
headerName: 'Status',
372371
renderCell: (params) => {
372+
// assemblies are not editable
373373
if (!params.value || String(params.row.id).startsWith('assembly')) return null;
374374
const material = materials.find((m) => m.materialId === params.row.materialId);
375375
if (!material) return null;
@@ -379,7 +379,7 @@ const BOMTableWrapper: React.FC<BOMTableWrapperProps> = ({
379379
disabled={!editPerms}
380380
onStatusChange={async (newStatus) => {
381381
try {
382-
await editMaterialStatus({
382+
await editMaterial({
383383
materialId: material.materialId,
384384
payload: {
385385
name: material.name,

0 commit comments

Comments
 (0)