- /stores/new 폼: 권리금/창업비용/월매출/월수익/보증금/월세 라벨을 "(원)" → "(만원)"으로 변경, placeholder도 만원 단위로 (예: 12000) - actions.ts: 입력값을 × 10000 변환 후 DB 저장 (DB는 원 단위 유지) - /stores/[id] 상세: formatKRW에서 원→억/만원 표시 (예: 1억 9500만원) - /stores 리스트: "만"/"억" 표기에 "원" 접미 추가 (예: 9900만원, 1.2억원)
This commit is contained in:
@@ -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 {
|
||||||
|
|||||||
@@ -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,
|
||||||
|
|||||||
@@ -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"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -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')}원`;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user