Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
110 commits
Select commit Hold shift + click to select a range
2840bdb
refactor: 제품 목록을 상수 객체로 변경하고 변수명을 명확하게 수정
Jul 26, 2025
6b517b8
refactor: 비즈니스 로직 모듈 완전 분리
Jul 26, 2025
0ecefb1
refactor: 제품 선택기 기능을 리팩토링
Jul 26, 2025
7ac7daf
refactor: 장바구니 아이템 표시 및 추가 기능 리팩토링
Jul 26, 2025
7b33a5a
refactor: 주문 요약 컴포넌트 추가 및 장바구니 계산 로직 수정
Jul 26, 2025
6f44554
refactor: 장바구니 기능 개선 및 유틸리티 함수 구현
Jul 26, 2025
701343f
refactor: 비즈니스 로직 상수화 및 할인, 포인트 계산 로직 개선
Jul 26, 2025
0f64290
refactor: 이벤트 핸들러를 화살표 함수로 변경하고 코드 가독성 향상
Jul 26, 2025
eec85b3
refactor: 제품 선택 컴포넌트 관련 로직 분리
Jul 27, 2025
c827e0c
refactor: 장바구니 아이템 표시를 위한 CartDisplay 컴포넌트 분리
Jul 27, 2025
d1ad83d
refactor: 주문 요약 컴포넌트 및 렌더링 유틸리티 함수 분리
Jul 27, 2025
a0db463
refactor: 장바구니 및 주문 요약 관련 유틸리티 함수 통합 및 리팩토링
Jul 27, 2025
e54ed5b
chore: 화요일 관련 테스트 변경
Jul 28, 2025
9ca1b5e
docs: 커서룰 적용
Jul 28, 2025
cc1d71e
refactor: Header 추가 및 createHeader 함수 리팩토링
Jul 28, 2025
6aca3c1
refactor: 도움말 모달 컴포넌트 추가 및 메인 파일에 통합
Jul 28, 2025
40f100b
refactor: 장바구니 클릭 이벤트 핸들러 및 도움말 모달 클릭 핸들러 통합
Jul 28, 2025
5752750
refactor: 장바구니 및 주문 요약 컴포넌트의 상태 관리 로직을 로컬 상태 패턴으로 변경하고 관련 유틸리티 함수 제거
Jul 29, 2025
325ab69
refactor: 장바구니 및 주문 요약 관련 컴포넌트 추가 및 기존 렌더링 로직 제거
Jul 29, 2025
c908a9f
refactor: 장바구니 계산 및 포인트 관리 로직을 기능별 클래스로 분리하고 가격 업데이트 로직 개선
Jul 29, 2025
3ceda89
refactor: 파일 위치를 feature기반으로 변경
Jul 29, 2025
87a6afc
refactor: UIStore 클래스 및 관련 유틸리티 함수 삭제
Jul 29, 2025
7a3961a
refactor: 상태 관리를 위한 ProductStore 및 CartStore 추가, 전역 변수 제거 및 로컬 상태로 전환
Jul 29, 2025
926004c
docs: 새로운 단계별 프로세스 및 지침을 포함한 step.mdc 파일 추가
Jul 29, 2025
14adbb0
refactor: JSX 스타일 템플릿을 사용하여 컴포넌트 리팩토링 및 HTML 생성 로직 개선
Jul 29, 2025
4297521
refactor(structure): service → services 디렉터리명 통일
Jul 29, 2025
ca121df
refactor(constants): Feature별 상수 분산
Jul 29, 2025
eb237fc
refactor(components): Feature별 컴포넌트 분산
Jul 29, 2025
a9e315c
refactor(events): Feature별 이벤트 핸들러 분산
Jul 29, 2025
580c2e6
fix(cartItem): 파라미터 구조 통일 및 렌더링 개선
Jul 29, 2025
fce4f32
refactor(cleanup): 불필요한 DOM getter 함수들 제거 및 코드 정리
Jul 29, 2025
9da142d
refactor(state): 클래스 Store → React useState 스타일로 변경
Jul 29, 2025
66bf9fc
refactor(state): 과도한 API 제거하고 State 관리 단순화
Jul 29, 2025
a32c896
refactor(state): 상태 관리 단순화 및 리액트 스타일로 변경
Jul 29, 2025
99bb393
remove: StockManager.js 파일 제거 및 관련 코드 정리
Jul 29, 2025
3447ca1
refactor: 상품 및 포인트 관련 유틸리티 함수 추가 및 코드 정리
Jul 29, 2025
cc0b383
refactor(state): 상태 관리 방식 통일 및 코드 정리
Jul 29, 2025
acadaf7
refactor: 클래스 기반 구조를 순수 함수로 변경 및 코드 정리
Jul 29, 2025
6c50b03
chore: ESLint 및 Prettier 설정 추가 및 Husky로 커밋 전 검사 설정
Jul 30, 2025
91be86a
Fix ESLint errors and code formatting
Jul 30, 2025
5bd9616
feat: 코어 유틸리티 및 상태 관리 시스템 추가
Jul 30, 2025
c2464b6
refactor: 사용하지 않는 함수 및 파라미터 제거
Jul 30, 2025
13946e6
refactor: 컴포넌트를 React 스타일로 리팩토링
Jul 30, 2025
f2bdeca
feat: 장바구니 UI 서비스 및 할인 유틸리티 개선
Jul 30, 2025
e92e695
refactor: 이벤트 핸들러 및 기타 서비스 개선
Jul 30, 2025
6005896
chore: 불필요한 파일 제거 및 의존성 업데이트
Jul 30, 2025
5d3c467
refactor: 사용되지 않는 DOM 유틸리티 함수 제거
Jul 30, 2025
cca2831
refactor: 상태 관리 시스템에서 사용되지 않는 구독 기능 제거
Jul 30, 2025
53aa1fc
refactor: 사용되지 않는 유틸리티 함수 제거
Jul 30, 2025
9500100
chore: 나머지 사용되지 않는 파일들 정리
Jul 30, 2025
ccfad99
remove: 미사용 productConstants 제거
Jul 30, 2025
fb44267
refactor: 불필요한 주석 및 코드 정리
Jul 30, 2025
22ca845
refactor: lint 및 prettier 적용 및 vite path를 통한 path 정리
Jul 31, 2025
c98f2bc
refactor: elementIds로 파일명 수정
Jul 31, 2025
0b3de2b
refactor: 카멜 케이스로 파일명 수정
Jul 31, 2025
09e88b1
refactor: 기본 포인트 계산 로직 수정
Jul 31, 2025
4c785b9
refactor: 장바구니 이벤트 핸들러 및 재고 관리 로직 개선
Jul 31, 2025
92021d6
refactor: ProductSelector 옵션 생성 로직 개선
Jul 31, 2025
88151d3
refactor: getProductState() 사용으로 코드 일관성 향상
Jul 31, 2025
79971a5
feat: 장바구니 상태 관리 스토어 추가
Jul 31, 2025
ecd116e
feat: 애플리케이션 초기화 및 DOM 구조 개선
Jul 31, 2025
ccaf5cb
feat: 리팩터링 문서 추가 및 단계별 개선 사항 정리
Jul 31, 2025
4e881ff
refactor: pointsCalculator 파일 대소문자 수정
Jul 31, 2025
5d7ad38
refactor: 장바구니 수량 관리 로직 개선
Jul 31, 2025
7bec385
chore: React 및 TypeScript 관련 의존성 추가
Jul 31, 2025
138a3d5
chore: 리액트+타입스크립트 프로젝트 초기 설정
Jul 31, 2025
148fae4
refactor: App.js코드 위치 수정
Jul 31, 2025
e9bdbe8
feat: 장바구니 재고 및 수량 관리 로직 분리
Jul 31, 2025
5eacdfd
refactor: DOM 이벤트 핸들러 및 초기화 로직 개선
Jul 31, 2025
7097b72
refactor: 장바구니 총액 계산 로직 개선
Jul 31, 2025
fd002b6
remove: 미사용 intial코드 제거
Jul 31, 2025
7c51c63
refactor: 장바구니 관련 코드 구조 개선
Jul 31, 2025
72d8b5c
refactor: 상수 파일을 advanced로 이동 및 ts로 전환
Jul 31, 2025
d31edee
remove: App.tsx 및 main.tsx 파일 삭제, advanced/App.tsx 및 advanced/main.ad…
Jul 31, 2025
08e578c
refactor: 장바구니 서비스에서 미사용 코드 제거 및 재고 검증 함수 개선
Jul 31, 2025
7af5729
refactor: 장바구니 서비스에서 할인 가능한 상품 강조 기능 추가
Jul 31, 2025
17badde
refactor: 헤더 및 도움말 모달 컴포넌트 이동 및 tsx로 전환
Jul 31, 2025
0c745a5
refactor: 헤더 컴포넌트 JSX로 변환 및 App.tsx에 통합
Jul 31, 2025
38bb888
refactor: App 컴포넌트에서 헤더 추가 및 DOM 구조 개선
Jul 31, 2025
aa4576a
refactor: HelpModal 컴포넌트 상태 관리 추가 및 JSX로 변환
Jul 31, 2025
86ff25c
refactor: features 폴더 이동
Jul 31, 2025
8213ab0
refactor: jsconfig 및 tsconfig 경로 수정, package.json에 새로운 시작 스크립트 추가
Jul 31, 2025
285bd15
refactor: ProductSelector 컴포넌트를 TypeScript로 변환 및 App.tsx에 통합
Jul 31, 2025
b6571b4
refactor: App.tsx에서 제품 상태 관리 추가 및 초기 제품 목록 설정
Jul 31, 2025
1a8de16
refactor: 장바구니 기능 추가 및 CartItem 컴포넌트 통합
Jul 31, 2025
0aac13c
refactor: CartTotal 컴포넌트를 TypeScript로 변환 및 파일 구조 개선
Jul 31, 2025
55ec833
refactor: OrderSummaryDetails 컴포넌트를 TypeScript로 변환 및 React 컴포넌트로 재작성
Jul 31, 2025
bcc6caf
feat: 할인 계산 유틸리티 함수 추가 및 OrderSummaryDetails 컴포넌트 수정
Jul 31, 2025
6b69a31
feat: OrderSummaryDetails 컴포넌트 통합 및 데이터 계산 로직 추가
Jul 31, 2025
9e45354
feat: 장바구니 상태 관리 리팩토링 및 App.tsx 통합
Jul 31, 2025
0d32f03
remove: 불필요한 장바구니 이벤트 핸들러 파일 삭제
Jul 31, 2025
e71b7aa
feat: CartItem 컴포넌트에 할인 가능 수량 로직 추가 및 가격 표시 개선
Jul 31, 2025
7169e07
feat: 재고 관련 유틸 함수들을 TypeScript로 변환
Jul 31, 2025
ea32b8b
feat: 재고 관리 로직 개선 및 수량 조정 기능 추가
Jul 31, 2025
f0eb10e
feat: 포인트 계산 로직 추가 및 App.tsx 수정
Jul 31, 2025
16e69fd
feat: App.tsx에서 재고 상태 관리 로직 추가 및 포인트 계산 유틸리티 수정
Jul 31, 2025
3bd8235
feat: 상품 상태 관리 및 서비스 관련 파일 삭제
Jul 31, 2025
43311e6
feat: 프로모션 서비스 및 가격 서비스 TypeScript로 변환
Jul 31, 2025
8991845
feat: App.tsx 및 장바구니 상태 관리 개선
Jul 31, 2025
ad4f499
feat: 장바구니 계산 및 서비스 관련 파일 삭제
Jul 31, 2025
4891b4c
feat: 장바구니 계산 로직 통합 및 할인 정보 표시 추가
Jul 31, 2025
ce08693
feat: 패키지 및 빌드 설정 업데이트
Jul 31, 2025
e49d315
feat: App.tsx에서 프로모션 콜백 로직 개선
Jul 31, 2025
1966175
feat: 프로모션 타이머 및 콜백 통합 개선
Jul 31, 2025
c42ce3d
feat: 상품 타입 정의 및 관련 파일 수정
Jul 31, 2025
a99d3c8
feat: 장바구니 아이템 타입 분리 및 코드 정리
Jul 31, 2025
b4903f3
feat: 상품 타입 임포트 경로 수정
Jul 31, 2025
4bf0b0e
feat: 테스트 파일 확장자 변경 및 새로운 의존성 추가
Aug 1, 2025
809b9c6
test: 테스트 파일 삭제 및 새로운 테스트 파일 추가
Aug 1, 2025
6e525b3
docs: 프로젝트 테스트 작성 가이드 추가
Aug 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
201 changes: 201 additions & 0 deletions .cursor/rules/dev.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
---
description:
globs:
alwaysApply: false
---
# 🛠️ JavaScript to React-Like Refactoring Cursorules

## Purpose

This document defines strict refactoring rules for transforming legacy JavaScript "spaghetti" code into a React-like structure. The goal is **to improve maintainability without altering existing business logic**, inspired by JSX-style rendering, event delegation, and isolated state handling.

> ⚠️ Never modify existing business logic.
> ⚠️ Only restructure code without changing its behavior.

---

## 👑 Role Assumed

The refactoring is executed by a senior JavaScript expert (CTO-level) responsible for safe architectural migration, ensuring minimal friction and zero regression.

---

## ✅ Principles

### 1. Componentization First

Extract related DOM + logic into modular components.

* ✅ Good: `function ProductCard(props) { ... }`
* ❌ Bad: `function renderProductBlock() { ... }`

### 2. JSX-Like Function Structure

Structure the component's return to reflect JSX semantics via:

* Template literals
* `document.createElement`
* Consistent nesting and layout hierarchy

### 3. Event Delegation Pattern

Avoid direct event listeners inside loops or for every element.

* ✅ `container.addEventListener('click', handleClick)`
* ❌ `el.addEventListener('click', ...)` inside `.forEach`

### 4. State Isolation

Simulate `useState` behavior via top-level scope isolation.

* ✅ `let isOpen = false` with updater function
* ❌ Mutating state directly inside a handler

### 5. Immutable Thinking

Prefer immutable operations. Avoid in-place mutations unless absolutely necessary.

### 6. Render Function Convention

* Use PascalCase or `renderX` naming
* Must accept `props` (or equivalent arguments)
* Must be pure and side-effect free

### 7. Early Return in Handlers

Avoid deep nesting in event handlers.

* ✅ `if (!target) return;`
* ❌ Deep `if-else` or `switch-case` chains

### 8. Naming Convention

* ✅ Use **camelCase** for variables, functions, and handlers
* ✅ Use **PascalCase** only for component-like pure render functions (like React)
* ❌ Avoid snake\_case or inconsistent casing

---

## 🧩 Directory Structure

```plaintext
src/
├── components/
│ └── ProductCard.js ← React-like component
├── dom/
│ └── domHelpers.js ← DOM abstraction helpers
├── state/
│ └── stateStore.js ← isolated state manager
└── events/
└── clickDelegates.js ← centralized event delegation
```

---

## 🔒 Safety Rules

* ❌ Never rename variables or functions unless unused
* ❌ Never alter logic branches or flow
* ✅ Use `// TODO:` comments to mark refactored boundaries
* ✅ Add `/** Pure render function */` JSDoc for all JSX-like components

---

## 🧪 Testing & QA

> 🔁 Refactoring without regression is non-negotiable.

* ✅ **Always run tests via `pnpm test` before and after changes**
* ✅ **Run tests frequently during refactor**, especially after any structural or state change
* ❌ **Do not commit if any test fails**, even if the failure seems unrelated
* ✅ Perform DOM snapshot diffing (if available)
* ✅ Use `console.assert` to validate structural equivalence
* ⚠️ Temporary logs allowed **within component scope only**, and must be removed before commit
* ✅ Component output must be **visually and functionally identical** pre/post refactor

---

## 📝 Example Conversion

### Before

```js
const button = document.createElement('button');
button.innerText = 'Click me';
button.onclick = function () {
alert('clicked');
};
document.body.appendChild(button);
```

### After

```ts
/** Pure render function */
function ClickButton(): HTMLElement {
const button = document.createElement('button');
button.innerText = 'Click me';
button.addEventListener('click', handleClick);
return button;
}

function handleClick() {
alert('clicked');
}

document.body.appendChild(ClickButton());
```

---

## 🧭 Migration Phases

1. **Phase 1** – Extract component boundaries
2. **Phase 2** – Centralize event delegation
3. **Phase 3** – Isolate state per component
4. **Phase 4** – JSX/React compatibility pass

---

## 🛑 Anti-Patterns

| Pattern | Why to Avoid |
| -------------------------------- | ----------------------------- |
| `.innerHTML = ...` | XSS-prone, hard to test |
| Global `let count = 0` | Shared state = bugs |
| Direct DOM mutation | Untrackable, brittle |
| Nested functions in render logic | Unreadable and non-composable |

---

## 📌 PR Checklist

* [ ] No logic modifications
* [ ] JSX-style component naming used
* [ ] Event handlers prefixed with `handle`
* [ ] No loop-level `.addEventListener`
* [ ] `// TODO:` comment added where necessary
* [ ] ✅ `pnpm test` passes locally **before each commit**

---

## 📎 Git Commit Tags

Use these prefixes in commit messages:

* `refactor(component):` Refactor logic into a React-like component
* `refactor(event):` Apply event delegation pattern
* `refactor(state):` Isolate or lift state cleanly
* `test(regression):` Add missing test or fix test artifact
* `docs(cursorules):` Update cursorule documentation

---

## ✍️ Notes

This document evolves alongside the codebase.
Suggest additions and improvements via pull request under the tag:

```text
docs(cursorules): update rulebook
```
104 changes: 104 additions & 0 deletions .cursor/rules/step.mdc
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
---
description:
globs:
alwaysApply: false
---

---
description:
globs:
alwaysApply: true
---

## Core Directive
You are a senior software engineer AI assistant. For EVERY task request, you MUST follow the three-phase process below in exact order. Each phase must be completed with expert-level precision and detail.

## Guiding Principles
- **Minimalistic Approach**: Implement high-quality, clean solutions while avoiding unnecessary complexity
- **Expert-Level Standards**: Every output must meet professional software engineering standards
- **Concrete Results**: Provide specific, actionable details at each step

---

## Phase 1: Codebase Exploration & Analysis
**REQUIRED ACTIONS:**
1. **Systematic File Discovery**
- List ALL potentially relevant files, directories, and modules
- Search for related keywords, functions, classes, and patterns
- Examine each identified file thoroughly

2. **Convention & Style Analysis**
- Document coding conventions (naming, formatting, architecture patterns)
- Identify existing code style guidelines
- Note framework/library usage patterns
- Catalog error handling approaches

**OUTPUT FORMAT:**
```
### Codebase Analysis Results
**Relevant Files Found:**
- [file_path]: [brief description of relevance]

**Code Conventions Identified:**
- Naming: [convention details]
- Architecture: [pattern details]
- Styling: [format details]

**Key Dependencies & Patterns:**
- [library/framework]: [usage pattern]
```

---

## Phase 2: Implementation Planning
**REQUIRED ACTIONS:**
Based on Phase 1 findings, create a detailed implementation roadmap.

**OUTPUT FORMAT:**
```markdown
## Implementation Plan

### Module: [Module Name]
**Summary:** [1-2 sentence description of what needs to be implemented]

**Tasks:**
- [ ] [Specific implementation task]
- [ ] [Specific implementation task]

**Acceptance Criteria:**
- [ ] [Measurable success criterion]
- [ ] [Measurable success criterion]
- [ ] [Performance/quality requirement]

### Module: [Next Module Name]
[Repeat structure above]
```

---

## Phase 3: Implementation Execution
**REQUIRED ACTIONS:**
1. Implement each module following the plan from Phase 2
2. Verify ALL acceptance criteria are met before proceeding
3. Ensure code adheres to conventions identified in Phase 1

**QUALITY GATES:**
- [ ] All acceptance criteria validated
- [ ] Code follows established conventions
- [ ] Minimalistic approach maintained
- [ ] Expert-level implementation standards met

---

## Success Validation
Before completing any task, confirm:
- ✅ All three phases completed sequentially
- ✅ Each phase output meets specified format requirements
- ✅ Implementation satisfies all acceptance criteria
- ✅ Code quality meets professional standards

## Response Structure
Always structure your response as:
1. **Phase 1 Results**: [Codebase analysis findings]
2. **Phase 2 Plan**: [Implementation roadmap]
3. **Phase 3 Implementation**: [Actual code with validation]
39 changes: 39 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# Dependencies
node_modules/

# Build outputs
dist/
build/

# Test coverage
coverage/

# IDE files
.vscode/
.idea/

# OS files
.DS_Store
Thumbs.db

# Logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Environment files
.env
.env.local
.env.development.local
.env.test.local
.env.production.local

# HTML files
*.html

# Config files
vite.config.js

# original
src/main.original.js
Loading