Files
zenn.inventory/scripts/state.js
zenn 526d310ac9 - 코드 정리
- 경고 클래스 수정
- 카드 비율 수정 3:4 > 4:5
2026-02-10 11:30:45 +09:00

28 lines
915 B
JavaScript

/** 앱 전역 상태 */
import products from '../data/index.js';
import { STATUS_META } from './config.js';
export const productsData = products;
// 초기 로드 시 세션 스토리지에서 선택 내역 불러오기
const savedIds = JSON.parse(sessionStorage.getItem('selectedProductIds') || '[]');
export const state = {
currentPage: 1,
activeCategories: new Set(['All']),
visibleProducts: [...products],
searchKeyword: '',
viewMode: 'grid', // 기본값
selectedIds: new Set(savedIds),
activeStatuses: new Set(
Object.entries(STATUS_META)
.filter(([_, meta]) => meta.defaultVisible)
.map(([status]) => status),
),
};
// 선택 내역이 변경될 때마다 세션 스토리지에 저장하는 헬퍼 함수
export function saveSelection() {
sessionStorage.setItem('selectedProductIds', JSON.stringify(Array.from(state.selectedIds)));
}