feat: 매장 등록·표시 금액 단위 만원으로 변경
Deploy Startover / deploy (push) Failing after 0s

- /stores/new 폼: 권리금/창업비용/월매출/월수익/보증금/월세 라벨을
  "(원)" → "(만원)"으로 변경, placeholder도 만원 단위로 (예: 12000)
- actions.ts: 입력값을 × 10000 변환 후 DB 저장 (DB는 원 단위 유지)
- /stores/[id] 상세: formatKRW에서 원→억/만원 표시 (예: 1억 9500만원)
- /stores 리스트: "만"/"억" 표기에 "원" 접미 추가 (예: 9900만원, 1.2억원)
This commit is contained in:
chpark
2026-04-30 21:54:32 +09:00
parent eb28c6a719
commit b1a07e7a87
4 changed files with 35 additions and 22 deletions
+9 -1
View File
@@ -46,7 +46,15 @@ async function handleDeleteDraft(formData: FormData) {
function formatKRW(value: number | null | undefined): string { function formatKRW(value: number | null | undefined): string {
if (value == null) return '-'; if (value == null) return '-';
return `${Number(value).toLocaleString('ko-KR')}`; // DB는 원 단위 → 표시는 만원/억 단위로
const won = Number(value);
if (won === 0) return '0원';
const eok = Math.floor(won / 100_000_000);
const man = Math.floor((won % 100_000_000) / 10_000);
if (eok > 0 && man > 0) return `${eok}${man.toLocaleString('ko-KR')}만원`;
if (eok > 0) return `${eok}억원`;
if (man > 0) return `${man.toLocaleString('ko-KR')}만원`;
return `${won.toLocaleString('ko-KR')}`;
} }
function formatMargin(sales?: number | null, profit?: number | null): string { function formatMargin(sales?: number | null, profit?: number | null): string {
+12 -7
View File
@@ -91,6 +91,11 @@ export async function createStoreDraftAction(
locationHighlight || locationHighlight ||
saleReason; saleReason;
// 폼 입력은 만원 단위 → DB는 원 단위로 저장 (× 10000)
const MAN = 10000;
const toWon = (v: string | null) => (v ? Number(v) * MAN : undefined);
const toWonRequired = (v: string | null) => (v ? Number(v) * MAN : 0);
const input: CreateStoreDraftInput = { const input: CreateStoreDraftInput = {
ownerUserId: session.user.dbId, ownerUserId: session.user.dbId,
listingTitle, listingTitle,
@@ -100,9 +105,9 @@ export async function createStoreDraftAction(
...(depositAmount || monthlyRentAmount || premiumAmount || remainingLeaseMonths ...(depositAmount || monthlyRentAmount || premiumAmount || remainingLeaseMonths
? { ? {
lease: { lease: {
depositAmount: depositAmount ? Number(depositAmount) : 0, depositAmount: toWonRequired(depositAmount),
monthlyRentAmount: monthlyRentAmount ? Number(monthlyRentAmount) : 0, monthlyRentAmount: toWonRequired(monthlyRentAmount),
premiumAmount: premiumAmount ? Number(premiumAmount) : 0, premiumAmount: toWonRequired(premiumAmount),
remainingLeaseMonths: remainingLeaseMonths remainingLeaseMonths: remainingLeaseMonths
? parseInt(remainingLeaseMonths, 10) ? parseInt(remainingLeaseMonths, 10)
: undefined, : undefined,
@@ -112,10 +117,10 @@ export async function createStoreDraftAction(
...(hasSale ...(hasSale
? { ? {
sale: { sale: {
premiumAmount: premiumAmount ? Number(premiumAmount) : undefined, premiumAmount: toWon(premiumAmount),
monthlySalesAmount: monthlySalesAmount ? Number(monthlySalesAmount) : undefined, monthlySalesAmount: toWon(monthlySalesAmount),
monthlyProfitAmount: monthlyProfitAmount ? Number(monthlyProfitAmount) : undefined, monthlyProfitAmount: toWon(monthlyProfitAmount),
startupCostAmount: startupCostAmount ? Number(startupCostAmount) : undefined, startupCostAmount: toWon(startupCostAmount),
listingDescription: listingDescription || undefined, listingDescription: listingDescription || undefined,
locationHighlight: locationHighlight || undefined, locationHighlight: locationHighlight || undefined,
saleReason: saleReason || undefined, saleReason: saleReason || undefined,
+12 -12
View File
@@ -124,21 +124,21 @@ export default function NewStorePage() {
<div className="space-y-4 rounded-2xl border border-ink/5 bg-white/70 backdrop-blur-sm p-6"> <div className="space-y-4 rounded-2xl border border-ink/5 bg-white/70 backdrop-blur-sm p-6">
<div className="grid grid-cols-2 gap-4"> <div className="grid grid-cols-2 gap-4">
<div> <div>
<label className="block text-sm text-ink-muted mb-1"> ()</label> <label className="block text-sm text-ink-muted mb-1"> ()</label>
<input <input
type="number" type="number"
name="premiumAmount" name="premiumAmount"
placeholder="120000000" placeholder="12000"
defaultValue={state.fieldValues?.premiumAmount} defaultValue={state.fieldValues?.premiumAmount}
className="w-full rounded-xl border border-ink/10 bg-white/70 px-4 py-3 text-sm text-ink focus:border-warm-500 focus:ring-2 focus:ring-warm-500/20 focus:outline-none" className="w-full rounded-xl border border-ink/10 bg-white/70 px-4 py-3 text-sm text-ink focus:border-warm-500 focus:ring-2 focus:ring-warm-500/20 focus:outline-none"
/> />
</div> </div>
<div> <div>
<label className="block text-sm text-ink-muted mb-1"> ()</label> <label className="block text-sm text-ink-muted mb-1"> ()</label>
<input <input
type="number" type="number"
name="startupCostAmount" name="startupCostAmount"
placeholder="150000000" placeholder="15000"
defaultValue={state.fieldValues?.startupCostAmount} defaultValue={state.fieldValues?.startupCostAmount}
className="w-full rounded-xl border border-ink/10 bg-white/70 px-4 py-3 text-sm text-ink focus:border-warm-500 focus:ring-2 focus:ring-warm-500/20 focus:outline-none" className="w-full rounded-xl border border-ink/10 bg-white/70 px-4 py-3 text-sm text-ink focus:border-warm-500 focus:ring-2 focus:ring-warm-500/20 focus:outline-none"
/> />
@@ -146,21 +146,21 @@ export default function NewStorePage() {
</div> </div>
<div className="grid grid-cols-2 gap-4"> <div className="grid grid-cols-2 gap-4">
<div> <div>
<label className="block text-sm text-ink-muted mb-1"> ()</label> <label className="block text-sm text-ink-muted mb-1"> ()</label>
<input <input
type="number" type="number"
name="monthlySalesAmount" name="monthlySalesAmount"
placeholder="85000000" placeholder="8500"
defaultValue={state.fieldValues?.monthlySalesAmount} defaultValue={state.fieldValues?.monthlySalesAmount}
className="w-full rounded-xl border border-ink/10 bg-white/70 px-4 py-3 text-sm text-ink focus:border-warm-500 focus:ring-2 focus:ring-warm-500/20 focus:outline-none" className="w-full rounded-xl border border-ink/10 bg-white/70 px-4 py-3 text-sm text-ink focus:border-warm-500 focus:ring-2 focus:ring-warm-500/20 focus:outline-none"
/> />
</div> </div>
<div> <div>
<label className="block text-sm text-ink-muted mb-1"> ()</label> <label className="block text-sm text-ink-muted mb-1"> ()</label>
<input <input
type="number" type="number"
name="monthlyProfitAmount" name="monthlyProfitAmount"
placeholder="9900000" placeholder="990"
defaultValue={state.fieldValues?.monthlyProfitAmount} defaultValue={state.fieldValues?.monthlyProfitAmount}
className="w-full rounded-xl border border-ink/10 bg-white/70 px-4 py-3 text-sm text-ink focus:border-warm-500 focus:ring-2 focus:ring-warm-500/20 focus:outline-none" className="w-full rounded-xl border border-ink/10 bg-white/70 px-4 py-3 text-sm text-ink focus:border-warm-500 focus:ring-2 focus:ring-warm-500/20 focus:outline-none"
/> />
@@ -205,21 +205,21 @@ export default function NewStorePage() {
<div className="space-y-4 rounded-2xl border border-ink/5 bg-white/70 backdrop-blur-sm p-6"> <div className="space-y-4 rounded-2xl border border-ink/5 bg-white/70 backdrop-blur-sm p-6">
<div className="grid grid-cols-2 gap-4"> <div className="grid grid-cols-2 gap-4">
<div> <div>
<label className="block text-sm text-ink-muted mb-1"> ()</label> <label className="block text-sm text-ink-muted mb-1"> ()</label>
<input <input
type="number" type="number"
name="depositAmount" name="depositAmount"
placeholder="50000000" placeholder="5000"
defaultValue={state.fieldValues?.depositAmount} defaultValue={state.fieldValues?.depositAmount}
className="w-full rounded-xl border border-ink/10 bg-white/70 px-4 py-3 text-sm text-ink focus:border-warm-500 focus:ring-2 focus:ring-warm-500/20 focus:outline-none" className="w-full rounded-xl border border-ink/10 bg-white/70 px-4 py-3 text-sm text-ink focus:border-warm-500 focus:ring-2 focus:ring-warm-500/20 focus:outline-none"
/> />
</div> </div>
<div> <div>
<label className="block text-sm text-ink-muted mb-1"> ()</label> <label className="block text-sm text-ink-muted mb-1"> ()</label>
<input <input
type="number" type="number"
name="monthlyRentAmount" name="monthlyRentAmount"
placeholder="3000000" placeholder="300"
defaultValue={state.fieldValues?.monthlyRentAmount} defaultValue={state.fieldValues?.monthlyRentAmount}
className="w-full rounded-xl border border-ink/10 bg-white/70 px-4 py-3 text-sm text-ink focus:border-warm-500 focus:ring-2 focus:ring-warm-500/20 focus:outline-none" className="w-full rounded-xl border border-ink/10 bg-white/70 px-4 py-3 text-sm text-ink focus:border-warm-500 focus:ring-2 focus:ring-warm-500/20 focus:outline-none"
/> />
+2 -2
View File
@@ -10,11 +10,11 @@ function formatKRWShort(value: number | null | undefined): string {
const v = Number(value); const v = Number(value);
if (v >= 100_000_000) { if (v >= 100_000_000) {
const eok = v / 100_000_000; const eok = v / 100_000_000;
return `${Number.isInteger(eok) ? eok : eok.toFixed(1)}`; return `${Number.isInteger(eok) ? eok : eok.toFixed(1)}`;
} }
if (v >= 10_000) { if (v >= 10_000) {
const man = Math.round(v / 10_000); const man = Math.round(v / 10_000);
return `${man.toLocaleString('ko-KR')}`; return `${man.toLocaleString('ko-KR')}`;
} }
return `${v.toLocaleString('ko-KR')}`; return `${v.toLocaleString('ko-KR')}`;
} }