Skip to content

Commit

Permalink
Merge pull request #41 from Jingil-Integrated-Management/develop
Browse files Browse the repository at this point in the history
Release v4
  • Loading branch information
therealjamesjung authored Jan 15, 2022
2 parents 5839d36 + 466c186 commit cfa8af1
Show file tree
Hide file tree
Showing 19 changed files with 229 additions and 61 deletions.
9 changes: 5 additions & 4 deletions src/components/drawers/add/DrawingInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const DrawingInput = (props: drawingInputProps) => {
<input
className="w-full text-sm mt-2 h-48 pl-12 rounded-8 bg-palette-purple-input flex items-center"
placeholder="내용을 입력하세요."
onChange={(e) => {
onChange={e => {
onInputChange('name', e.target.value);
}}
></input>
Expand All @@ -76,7 +76,8 @@ const DrawingInput = (props: drawingInputProps) => {
className="w-full text-sm mt-2 h-48 pl-12 rounded-8 bg-palette-purple-input flex items-center"
list="clientList"
placeholder="내용을 입력하세요."
onChange={(e) => {
autoComplete="off"
onChange={e => {
onInputChange(
'client',
getClientID(props.clientList, e.target.value)
Expand All @@ -85,7 +86,7 @@ const DrawingInput = (props: drawingInputProps) => {
></input>
<datalist id="clientList">
<option value="">회사 선택</option>
{props.clientList.map((client: ClientData) => {
{props.clientList?.map((client: ClientData) => {
return <option key={client.id} value={client.name} />;
})}
</datalist>
Expand Down Expand Up @@ -113,7 +114,7 @@ const DrawingInput = (props: drawingInputProps) => {
<input
className="w-full text-sm mt-2 h-48 pl-12 rounded-8 bg-palette-purple-input flex items-center"
placeholder="내용을 입력하세요."
onChange={(e) => {
onChange={e => {
onInputChange('comment', e.target.value);
}}
></input>
Expand Down
16 changes: 12 additions & 4 deletions src/components/drawers/add/OutSourceInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { OutsourceData, ClientData } from '../../../types';
import getClientID from '../../../utils/getClientID';

import OUTSOURCE from '../../../constants/OUTSOURCE.json';
import getClientName from '../../../utils/getClientName';

interface outSourceControlProps {
osParts: OutsourceData[];
Expand Down Expand Up @@ -55,12 +56,19 @@ const OutSourceControl = (props: outSourceControlProps) => {
<input
className="os_drawer_input text-sm pl-12 two"
placeholder={(OUTSOURCE.os_subjects_dict as any)[props.subject]}
onChange={(e) => {
value={getClientName(
props.clientList,
props.osParts[props.index][
(props.subject + '_client') as keyof OutsourceData
] as number
)}
onChange={e => {
onInputChange(
(props.subject + '_client') as keyof OutsourceData,
getClientID(props.clientList, e.target.value)
);
}}
autoComplete="off"
list={`osClientList${props.index}`}
/>
<datalist id={`osClientList${props.index}`}>
Expand All @@ -78,11 +86,11 @@ const OutSourceControl = (props: outSourceControlProps) => {
className="w-full text-sm h-44 pl-12 rounded-8 bg-palette-purple-input"
placeholder="내용을 입력하세요."
value={
props.osParts[props.index][
(props.osParts[props.index][
(props.subject + '_price') as keyof OutsourceData
] as string
] as string) || ''
}
onChange={(e) => {
onChange={e => {
onInputChange(
(props.subject + '_price') as keyof OutsourceData,
e.target.value
Expand Down
22 changes: 12 additions & 10 deletions src/components/drawers/add/PartInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ const PartInput = (props: partInputProps) => {
id={`file_${props.index}`}
ref={inputFile}
style={{ display: 'none' }}
onChange={(e) => {
onChange={e => {
previewImage(e, props.index);
}}
/>
Expand Down Expand Up @@ -147,10 +147,11 @@ const PartInput = (props: partInputProps) => {
className="client w-full text-sm mt-2 h-48 pl-12 rounded-8 bg-palette-purple-input"
placeholder="메인 구분을 선택하세요."
value={selectedMainDivision}
onChange={(e) => {
onChange={e => {
setSelectedMainDivision(e.target.value);
onInputChange('division', -1);
}}
autoComplete="off"
/>
<datalist id={`main_div${props.index}`}>
{props.mainDivisions.map(
Expand All @@ -168,11 +169,12 @@ const PartInput = (props: partInputProps) => {
list={`sub_div${props.index}`}
className="flex items-center client w-full text-sm mt-2 h-48 pl-12 rounded-8 bg-palette-purple-input"
placeholder="세부 구분을 선택하세요."
autoComplete="off"
value={getSubDivisionName(
divisionList,
props.parts[props.index].division
)}
onChange={(e) => {
onChange={e => {
onInputChange(
'division',
getDivisionID(divisionList, e.target.value)
Expand Down Expand Up @@ -204,7 +206,7 @@ const PartInput = (props: partInputProps) => {
className="w-full text-sm mt-2 h-48 pl-12 rounded-8 bg-palette-purple-input flex items-center"
placeholder="내용을 입력하세요."
value={props.parts[props.index].x}
onChange={(e) => {
onChange={e => {
onInputChange('x', e.target.value);
}}
></input>
Expand All @@ -217,7 +219,7 @@ const PartInput = (props: partInputProps) => {
className="w-full text-sm mt-2 h-48 pl-12 rounded-8 bg-palette-purple-input flex items-center"
placeholder="내용을 입력하세요."
value={props.parts[props.index].y}
onChange={(e) => {
onChange={e => {
onInputChange('y', e.target.value);
}}
></input>
Expand All @@ -230,7 +232,7 @@ const PartInput = (props: partInputProps) => {
className="w-full text-sm mt-2 h-48 pl-12 rounded-8 bg-palette-purple-input flex items-center"
placeholder="내용을 입력하세요."
value={props.parts[props.index].z}
onChange={(e) => {
onChange={e => {
onInputChange('z', e.target.value);
}}
></input>
Expand All @@ -244,7 +246,7 @@ const PartInput = (props: partInputProps) => {
<select
className="w-full text-sm mt-2 h-48 px-12 rounded-8 bg-palette-purple-input flex items-center outline-none"
value={props.parts[props.index].material}
onChange={(e) => onInputChange('material', e.target.value)}
onChange={e => onInputChange('material', e.target.value)}
>
{props.materialList.map((material, index) => {
return (
Expand All @@ -263,7 +265,7 @@ const PartInput = (props: partInputProps) => {
className="w-full text-sm mt-2 h-48 pl-12 rounded-8 bg-palette-purple-input flex items-center"
placeholder="내용을 입력하세요."
value={props.parts[props.index].quantity}
onChange={(e) => {
onChange={e => {
onInputChange('quantity', Number(e.target.value));
}}
></input>
Expand All @@ -282,7 +284,7 @@ const PartInput = (props: partInputProps) => {
? (props.parts[props.index].price as string)
: ''
}
onChange={(e) => {
onChange={e => {
onInputChange('price', e.target.value);
}}
></input>
Expand All @@ -299,7 +301,7 @@ const PartInput = (props: partInputProps) => {
? (props.parts[props.index].comment as string)
: ''
}
onChange={(e) => {
onChange={e => {
onInputChange('comment', e.target.value);
}}
></input>
Expand Down
5 changes: 1 addition & 4 deletions src/components/drawers/info/DrawingInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ const DrawingInfo = (props: drawingInfoProps) => {
return (
<div className="w-full h-220">
<div className="flex mt-53">
<div className="flex justify-center items-center w-40 h-40 bg-palette-purple-index rounded-panel">
0
</div>
<div className="flex justify-center items-center w-95 h-40 ml-10 rounded-panel bg-palette-grey">
<div className="flex justify-center items-center w-95 h-40 sticky rounded-panel bg-palette-grey">
도면 정보
</div>
{props.drawing.is_outsource ? (
Expand Down
30 changes: 24 additions & 6 deletions src/components/drawers/info/Info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ import PartInfo from './PartInfo';
import DrawingInfo from './DrawingInfo';

//types
import { DrawingData, PartData } from '../../../types';
import { DrawingData, OutsourceData, PartData } from '../../../types';

import OUTSOURCE from '../../../constants/OUTSOURCE.json';

interface tableDrawerProps {
target: string;
Expand All @@ -23,7 +25,10 @@ interface tableDrawerProps {

const Info = (props: tableDrawerProps) => {
const finishDrawing = async () => {
if (!isClosed()) return;
if (!isClosed()) {
alert('가격이 확정되지 않은 파트가 존재합니다.');
return;
}

try {
await webClient.patch(`drawing/${props.drawing?.id}`, {
Expand Down Expand Up @@ -75,10 +80,23 @@ const Info = (props: tableDrawerProps) => {

const isClosed = () => {
for (let i = 0; i < props.parts.length; i++) {
if (props.parts[i].price === '' || props.parts[i].price === null) {
alert('가격이 확정되지 않은 파트가 존재합니다.');
return false;
}
let isClosed = true;

if (props.parts[i].price === '' || props.parts[i].price === null)
isClosed = false;

if (!isClosed) return isClosed;

OUTSOURCE.os_subjects.forEach(subject => {
const tmpOs = props.parts[i].outsource_info;
if (
tmpOs &&
tmpOs[(subject + '_client') as keyof OutsourceData] &&
!tmpOs[(subject + '_price') as keyof OutsourceData]
)
isClosed = false;
});
if (!isClosed) return isClosed;
}

return true;
Expand Down
39 changes: 25 additions & 14 deletions src/components/drawers/patch/Patch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useEffect, useState } from 'react';
//icons
import { ReactComponent as CloseIcon } from '../../../resources/svg/closeIcon.svg';


//types
import {
DrawingData,
Expand All @@ -24,7 +23,13 @@ import PatchPart from './PatchPart';
import PatchDrawing from './PatchDrawing';

//utils
import { isExistClient } from '../../../utils/validatePatch';
import {
isExistClient,
validateClient,
validateDrawingName,
validateParts,
} from '../../../utils/validatePatch';
import { reload } from '../../../utils/reload';

interface PatchProps {
target: String;
Expand Down Expand Up @@ -67,7 +72,11 @@ const Patch = (props: PatchProps) => {
};

const patchDrawing = async () => {
if (!props.drawing || !isExistClient(targetDrawing?.client)) {
if (
!props.drawing ||
!isExistClient(targetDrawing?.client) ||
!validateDrawingName(targetDrawing?.name)
) {
return;
}

Expand All @@ -79,31 +88,30 @@ const Patch = (props: PatchProps) => {
};

const patchParts = async () => {
if (!validateParts(targetPartList)) return;

for (let index = 0; index < props.parts.length; index++) {
let partId = props.parts[index].id!;

try {
const response: AxiosResponse = await webClient.patch(
`/part/${partId}`,
targetPartList[index]
);
console.log(response);
await webClient.patch(`/part/${partId}`, targetPartList[index]);
} catch (error) {
console.log(error);
}
}
};

const patchOutSource = async () => {
if (!props.parts[0].drawing__is_outsource) return;
if (
!props.parts[0].drawing__is_outsource ||
!validateClient(targetOutSourcePartList)
) {
return;
}

targetOutSourcePartList.forEach(async outsource => {
try {
const response: AxiosResponse = await webClient.patch(
`/outsource/${outsource.id}`,
outsource
);
console.log(response);
await webClient.patch(`/outsource/${outsource.id}`, outsource);
} catch (error) {
console.log(error);
}
Expand Down Expand Up @@ -171,6 +179,9 @@ const Patch = (props: PatchProps) => {
patchDrawing();
patchParts();
patchOutSource();
setTimeout(() => {
reload('성공적으로 수정되었습니다.');
}, 500);
}}
>
완료하기
Expand Down
1 change: 1 addition & 0 deletions src/components/drawers/patch/PatchDrawing.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ const PatchDrawing = (props: PatchDrawingProps) => {
className="w-full text-sm mt-2 h-48 pl-12 rounded-8 bg-palette-purple-input flex items-center"
list="patch-drawing-client-list"
value={clientName}
autoComplete="off"
onChange={e => {
setClientName(e.target.value);
props.setTargetDrawing({
Expand Down
3 changes: 2 additions & 1 deletion src/components/drawers/patch/PatchOutSourcePart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ const OutSource = (props: outSourceProps) => {
<div className="text-14 font-medium leading-1.14 text-palette-grey-menuicons">
외주 추가하기
</div>
<div className="w-544 h-48 mt-8 item-border bg-palette-gray-osbox flex items-center justify-center">
<div className="w-544 h-48 mt-8 rounded-8 item-border bg-palette-purple-input flex items-center justify-center">
{OUTSOURCE.os_subjects.map((subject, index) => (
<button
key={index}
Expand Down Expand Up @@ -132,6 +132,7 @@ const OutSourceInput = (props: OutSourceInputProps) => {
<input
className="os_drawer_input text-sm pl-12 two"
placeholder={(OUTSOURCE.os_subjects_dict as any)[props.subject]}
autoComplete="off"
value={
props.targetOutSourcePartList[props.index][
`${props.subject}_client__name` as keyof OutsourceData
Expand Down
3 changes: 3 additions & 0 deletions src/components/drawers/patch/PatchPart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ const PatchPart = (props: PatchPartProps) => {
className="client w-full text-sm mt-2 h-48 pl-12 rounded-8 bg-palette-purple-input flex items-center"
list={`main_division_list_${index}`}
value={partInputForm.main_division}
autoComplete="off"
onChange={e => {
setPartInputForm({
...partInputForm,
Expand All @@ -167,6 +168,7 @@ const PatchPart = (props: PatchPartProps) => {
className="client w-full text-sm mt-2 h-48 pl-12 rounded-8 bg-palette-purple-input flex items-center"
list={`sub_division_list_${index}`}
value={partInputForm.sub_division}
autoComplete="off"
onChange={e => {
setPartInputForm({
...partInputForm,
Expand Down Expand Up @@ -231,6 +233,7 @@ const PatchPart = (props: PatchPartProps) => {
<input
className="w-full text-sm mt-2 h-48 pl-12 rounded-8 bg-palette-purple-input flex items-center"
list={`material_list_${index}`}
autoComplete="off"
value={props.targetPartList[props.index].material}
onChange={e => onInputChange('material', e.target.value)}
/>
Expand Down
Loading

0 comments on commit cfa8af1

Please sign in to comment.