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AU,eAAA,KAAc,CAAA;+CAQmC,YAAA,QAAW;AAAA,iDAA6D,YAAA,QAAW;AAAA,2DAI9I,YAAA,QAAW,IAAA,MAAA,EAAA,KACZA,eAAA,UAAU,YAAA,KAAW,CAAA,wMAQpB,cAAA,KAAa;AA6BSC,oBAAA,2BAAA,QAAf,gBAAW;8HAMkBD,eAAA,YAAY,IAAI,KAAOA,eAAA,YAAY,IAAI;AAKjE,YAAA,YAAY,cAAS,MAAA;;QAKhB,WAAA,YAAY,cAAS,QAAA;;;;;mFAOzB,UAAU,YAAY,SAAS,CAAA;UAKc,wBAAA,YAAY,WAAM;AAAA,UAA0D,0BAAA,YAAY,WAAM;AAAA,qDAMlJA,eAAA,YAAY,WAAM,QAAA,OAAA,IAAA;UAMkC,wBAAA,YAAY,WAAM;AAAA,UAA0D,0BAAA,YAAY,WAAM;AAAA,qDAM9IA,eAAA,YAAY,SAAM,IAAA,MAAA,EAAA,mBACjB,UAAU,YAAY,MAAM,CAAA;;;;;;;;;;;;","names":["_ssrRenderAttrs","_mergeProps","_unref","_ssrInterpolate","_ssrRenderList"],"sources":["../../../../pages/mypage/history.vue"],"sourcesContent":["<script setup>\nimport { ref, computed, onMounted } from \"vue\";\nimport { useDateFilter } from \"~/composables/useDateFilter\";\nimport { useBet } from \"~/composables/useBet\";\n\ndefinePageMeta({\n  layout: \"mypage\",\n});\n\n// ===== Composables =====\nconst {\n  dateOptions: options,\n  selectedType,\n  selectRef,\n  handleSelectChange,\n  applyDateFilter,\n} = useDateFilter();\n\nconst { getBettingHistory } = useBet();\n\n// ===== 상태 =====\nconst transactionHistory = ref([]);\nconst isLoading = ref(false);\n\n// ===== API 호출 =====\nconst loadBettingHistory = async () => {\n  isLoading.value = true;\n  try {\n    const result = await getBettingHistory(100); // 최근 100개\n    if (result.success && result.history) {\n      transactionHistory.value = result.history.map((item, index) => ({\n        id: item.roundId + '-' + item.type + '-' + index, // roundId + type으로 unique ID 생성\n        date: item.date, // 날짜 (Y-m-d)\n        time: item.time, // 시간 (H:i)\n        direction: item.type.toLowerCase(), // type을 direction으로\n        betAmount: item.originalAmount, // 배팅금액 (원래금액)\n        result: item.result === '승리' ? 'win' : (item.result === '패배' ? 'lose' : 'pending'),\n        profit: item.profit || 0,\n      }));\n      // console.log('[History] Loaded', transactionHistory.value.length, 'records');\n    } else {\n      console.error('[History] API failed:', result.message);\n    }\n  } catch (error) {\n    console.error('베팅 내역 로드 실패:', error);\n  } finally {\n    isLoading.value = false;\n  }\n};\n\n// 컴포넌트 마운트 시 데이터 로드\nonMounted(() => {\n  loadBettingHistory();\n});\n\n// ===== 계산된 값 =====\n// 필터링된 배팅 내역 (날짜 필터 적용)\nconst filteredTransactionHistory = computed(() => {\n  return applyDateFilter(transactionHistory.value);\n});\n\n// 총 배팅금액 (모든 배팅 금액의 합계)\nconst totalBetAmount = computed(() => {\n  return filteredTransactionHistory.value.reduce(\n    (sum, transaction) => sum + transaction.betAmount,\n    0\n  );\n});\n\n// 총 당첨금액 (승리한 배팅의 profit 합계, 양수만)\nconst totalWinAmount = computed(() => {\n  return filteredTransactionHistory.value\n    .filter((transaction) => transaction.result === \"win\")\n    .reduce((sum, transaction) => sum + transaction.profit, 0);\n});\n\n// 이익 (모든 profit의 합계)\nconst totalProfit = computed(() => {\n  return filteredTransactionHistory.value.reduce(\n    (sum, transaction) => sum + transaction.profit,\n    0\n  );\n});\n\n// 배팅건수\nconst totalBetCount = computed(() => {\n  return filteredTransactionHistory.value.length;\n});\n\n// ===== 함수 =====\n// 원화 포맷팅 함수 (천 단위 콤마 추가)\nconst formatKRW = (amount) => {\n  return amount.toLocaleString(\"ko-KR\");\n};\n</script>\n\n<template>\n  <div class=\"mypage__wallet\">\n    <!-- ===== 필터 영역 ===== -->\n    <div\n      class=\"mypage__wallet-item mypage__wallet-item--column mypage__wallet-item--history\"\n    >\n      <div class=\"mypage__wallet-history-filter\">\n        <strong class=\"mypage__wallet-history-title\">배팅내역</strong>\n        <!-- 날짜 필터 선택 (지난 N일 또는 날짜 범위 선택) -->\n        <div class=\"mypage__wallet-history-filter-select\">\n          <Select\n            ref=\"selectRef\"\n            v-model=\"selectedType\"\n            :options=\"options\"\n            placeholder=\"전체\"\n            size=\"md\"\n            @change=\"handleSelectChange\"\n          />\n        </div>\n      </div>\n    </div>\n\n    <!-- ===== 통계 영역 ===== -->\n    <div\n      class=\"mypage__wallet-item mypage__wallet-item--column mypage__wallet-item--history\"\n    >\n      <ul class=\"mypage__wallet-total\">\n        <!-- 총 배팅금액 -->\n        <li class=\"mypage__wallet-total-item\">\n          <span class=\"mypage__wallet-total-title\">총 배팅금액</span>\n          <strong class=\"mypage__wallet-total-value\"\n            >{{ formatKRW(totalBetAmount) }}원</strong\n          >\n        </li>\n        <!-- 총 당첨금액 (primary 색상) -->\n        <li class=\"mypage__wallet-total-item\">\n          <span class=\"mypage__wallet-total-title\">총 당첨금액</span>\n          <strong\n            class=\"mypage__wallet-total-value mypage__wallet-total-value--primary\"\n            >{{ formatKRW(totalWinAmount) }}원</strong\n          >\n        </li>\n        <!-- 이익 (양수: primary, 음수: secondary 색상) -->\n        <li class=\"mypage__wallet-total-item\">\n          <span class=\"mypage__wallet-total-title\">이익</span>\n          <strong\n            class=\"mypage__wallet-total-value\"\n            :class=\"{\n              'mypage__wallet-total-value--primary': totalProfit > 0,\n              'mypage__wallet-total-value--secondary': totalProfit < 0,\n            }\"\n            >{{ totalProfit > 0 ? \"+\" : \"\" }}\n            {{ formatKRW(totalProfit) }}원</strong\n          >\n        </li>\n        <!-- 배팅건수 -->\n        <li class=\"mypage__wallet-total-item\">\n          <span class=\"mypage__wallet-total-title\">배팅건수</span>\n          <strong\n            class=\"mypage__wallet-total-value mypage__wallet-total-value--case\"\n            >{{ totalBetCount }}건</strong\n          >\n        </li>\n      </ul>\n    </div>\n\n    <!-- ===== 테이블 영역 ===== -->\n    <div class=\"mypage__wallet-item mypage__wallet-item--column\">\n      <div class=\"table__inner\">\n        <div class=\"table__wrap\">\n          <table class=\"table table--b\">\n            <colgroup>\n              <col width=\"160px\" />\n              <col width=\"105px\" />\n              <col width=\"122px\" />\n              <col width=\"80px\" />\n              <col width=\"122px\" />\n            </colgroup>\n            <thead class=\"table__head\">\n              <tr class=\"table__row table__row--th\">\n                <th class=\"table__cell table__cell--th\">날짜</th>\n                <th class=\"table__cell table__cell--th\">유형</th>\n                <th class=\"table__cell table__cell--th\">배팅금액</th>\n                <th class=\"table__cell table__cell--th\">결과</th>\n                <th class=\"table__cell table__cell--th\">수익</th>\n              </tr>\n            </thead>\n            <tbody class=\"table__body\">\n              <tr\n                v-for=\"transaction in filteredTransactionHistory\"\n                :key=\"transaction.id\"\n                class=\"table__row table__row--td\"\n              >\n                <!-- 날짜 -->\n                <td class=\"table__cell table__cell--td\">\n                  <span class=\"table__cell-date\">{{ transaction.date }} {{ transaction.time }}</span>\n                </td>\n                <!-- 유형 (UP/Down, badge 스타일 적용) -->\n                <td class=\"table__cell table__cell--td\">\n                  <span\n                    v-if=\"transaction.direction === 'up'\"\n                    class=\"badge badge--up badge--md ico-after ico-up\"\n                    >UP</span\n                  >\n                  <span\n                    v-else-if=\"transaction.direction === 'down'\"\n                    class=\"badge badge--down badge--md ico-after ico-down\"\n                    >Down</span\n                  >\n                </td>\n                <!-- 배팅금액 (원화 포맷) -->\n                <td class=\"table__cell table__cell--td\">\n                  <span>{{ formatKRW(transaction.betAmount) }}</span>\n                </td>\n                <!-- 결과 (승리/손실, primary/secondary 색상 적용) -->\n                <td\n                  class=\"table__cell table__cell--td\"\n                  :class=\"{\n                    'table__cell--primary': transaction.result === 'win',\n                    'table__cell--secondary': transaction.result === 'lose',\n                  }\"\n                >\n                  <span>{{\n                    transaction.result === \"win\" ? \"승리\" : \"손실\"\n                  }}</span>\n                </td>\n                <!-- 수익 (승리: +, primary 색상, 패배: -, secondary 색상, 원화 포맷) -->\n                <td\n                  class=\"table__cell table__cell--td\"\n                  :class=\"{\n                    'table__cell--primary': transaction.result === 'win',\n                    'table__cell--secondary': transaction.result === 'lose',\n                  }\"\n                >\n                  <span\n                    >{{ transaction.profit > 0 ? \"+\" : \"\"\n                    }}{{ formatKRW(transaction.profit) }}</span\n                  >\n                </td>\n              </tr>\n            </tbody>\n          </table>\n        </div>\n      </div>\n    </div>\n  </div>\n</template>\n<style></style>\n"],"version":3}