From 28bfe4f96fcbb129c3a06314caccb3d55baa4593 Mon Sep 17 00:00:00 2001 From: Hyein Date: Wed, 24 Jun 2026 10:27:20 +0900 Subject: [PATCH] Show all steps in program comparison --- src/App.jsx | 130 ++++++++++++++++++++++++---------------------------- 1 file changed, 59 insertions(+), 71 deletions(-) diff --git a/src/App.jsx b/src/App.jsx index 7b23b63..769e200 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1241,29 +1241,34 @@ function ProgramComparePopup({ programs, comparisons, onComparisonChange, onClos const leftSteps = leftProgram?.steps ?? []; const rightSteps = rightProgram?.steps ?? []; const stepMatches = comparison.stepMatches ?? []; + const maxStepCount = Math.max(leftSteps.length, rightSteps.length); const updateComparison = (field, value) => { if (!leftProgramId || !rightProgramId || leftProgramId === rightProgramId) return; onComparisonChange(leftProgramId, rightProgramId, field, value); }; - const createStepMatch = () => ({ - id: `${Date.now()}-${Math.random().toString(36).slice(2)}`, - leftStepIndex: '0', - rightStepIndex: '0', - reason: '' - }); - const addStepMatch = () => { - updateComparison('stepMatches', [...stepMatches, createStepMatch()]); - }; - const updateStepMatch = (matchIndex, field, value) => { + const getStepMatch = (stepIndex) => + stepMatches.find( + (match) => String(match.leftStepIndex) === String(stepIndex) && String(match.rightStepIndex) === String(stepIndex) + ) ?? {}; + const updateStepReason = (stepIndex, value) => { + const existingIndex = stepMatches.findIndex( + (match) => String(match.leftStepIndex) === String(stepIndex) && String(match.rightStepIndex) === String(stepIndex) + ); + const nextMatch = { + ...(existingIndex >= 0 ? stepMatches[existingIndex] : {}), + id: `step-${stepIndex}`, + leftStepIndex: String(stepIndex), + rightStepIndex: String(stepIndex), + reason: value + }; updateComparison( 'stepMatches', - stepMatches.map((match, index) => (index === matchIndex ? { ...match, [field]: value } : match)) + existingIndex >= 0 + ? stepMatches.map((match, index) => (index === existingIndex ? nextMatch : match)) + : [...stepMatches, nextMatch] ); }; - const removeStepMatch = (matchIndex) => { - updateComparison('stepMatches', stepMatches.filter((_, index) => index !== matchIndex)); - }; const getStepLabel = (step, index) => `${index + 1}. ${step?.title ?? '-'}`; const renderProgramSummary = (program) => { @@ -1358,88 +1363,71 @@ function ProgramComparePopup({ programs, comparisons, onComparisonChange, onClos
-
+
-

스텝 1:1 매칭

+

전체 스텝 1:1 비교

- 왼쪽 스텝과 오른쪽 스텝을 연결하고, 가운데에 상용 프로그램을 쓰는 이유를 적습니다. + 두 프로그램의 스텝을 전부 펼친 뒤, 가운데에 해당 스텝에서 상용 프로그램을 쓰는 이유를 적습니다.

-
- {stepMatches.length === 0 ? ( + {maxStepCount === 0 ? (
- 아직 매칭된 스텝이 없습니다. `매칭 추가`를 눌러 스텝을 연결하세요. + 비교할 스텝이 없습니다.
) : ( - stepMatches.map((match, matchIndex) => ( + Array.from({ length: maxStepCount }).map((_, stepIndex) => { + const leftStep = leftSteps[stepIndex]; + const rightStep = rightSteps[stepIndex]; + const match = getStepMatch(stepIndex); + return (
-