Compare commits

...

11 Commits

16 changed files with 1058 additions and 187 deletions

View File

@@ -6,3 +6,8 @@ ADMIN_ACCOUNT_ID=replace-with-private-admin-id
ADMIN_ACCOUNT_PASSWORD=replace-with-private-admin-password
ADMIN_ACCOUNT_EMAIL=admin@example.com
ADMIN_ACCOUNT_NICKNAME=Planner Admin
APP_BASE_URL=https://planner.sori.studio
RESEND_API_KEY=replace-with-private-resend-api-key
MAIL_FROM_EMAIL=planner@sori.studio
MAIL_FROM_NAME=10 Minute Planner
AUTH_PREVIEW_LINKS=false

View File

@@ -4,7 +4,7 @@
- 프로젝트명: 10 Minute Planner 웹 UI
- 기술 스택: Vue 3 + Vite + TailwindCSS + JavaScript
- 현재 기준 버전: `v0.1.42` 준비 중
- 현재 기준 버전: `v0.1.43` 준비 중
- Git 원격 저장소: `https://git.sori.studio/zenn/planner.sori.studio.git`
## 기준 디자인
@@ -218,6 +218,16 @@
- READ NEXT는 내일 첫 작업과 오늘 미처리 할 일 개수만 보여주도록 줄였고, 오늘 코멘트 반복 노출은 제거했다.
- 플래너 본문 시간 라벨은 `총 시간`에서 `FOCUSED TIME`으로 바꿨다. 인쇄 CSS에서 COMMENT/FOCUSED TIME 라벨이 잘리지 않도록 부모 overflow를 열고, COMMENT는 남는 폭을 채우며 FOCUSED TIME은 오른쪽 210px 칸에 붙도록 조정했다.
- Docker 배포용 루트 `.env`와 개발용 `.env.dev`를 분리했다. `docker-compose.yml`은 운영 `.env`, `docker-compose.dev.yml`은 기존 dev Postgres 볼륨과 맞는 `.env.dev`를 읽는다.
- STATS의 `RANGE FLOW`는 항목 수에 따라 막대 폭과 간격을 조정한다. 1주일 내외는 넓은 막대로 카드 폭을 채우고, 1달 내외는 좁은 막대와 요약 라벨로 한 화면에서 흐름을 보며, 세부 날짜와 집중 시간은 막대 hover 팝업으로 확인한다.
- 왼쪽 사이드바의 인쇄 영역은 `PRINT` 버튼 하나로 줄이고, 클릭 시 모달에서 시작일/종료일과 `1페이지씩` 또는 `2페이지씩` 출력 방식을 선택한다. 인쇄 전용 렌더링은 선택 기간의 날짜를 순서대로 여러 장 생성하며, 2페이지씩 출력에서 홀수 날짜가 남으면 오른쪽은 빈 페이지 프레임으로 둔다.
- 회원가입과 프로필 수정 시 이메일뿐 아니라 닉네임 중복도 서버에서 409로 막는다. 비밀번호 재설정 API는 로그인 모달의 `비밀번호 찾기` 흐름과 연결되어 있고, `/reset-password?token=...` URL로 들어오면 새 비밀번호 설정 모드가 열린다. 실제 메일 발송 전까지는 백엔드 응답의 `resetPreviewUrl`을 개발용 링크로 표시한다.
- Resend 메일러가 추가되었다. `RESEND_API_KEY`, `MAIL_FROM_EMAIL`, `MAIL_FROM_NAME`, `APP_BASE_URL` 환경변수를 설정하면 이메일 인증과 비밀번호 재설정 메일을 실제로 발송한다. API 키는 저장소에 커밋하지 말고 루트 `.env`/`.env.dev`에만 넣는다.
- 인증/비밀번호 재설정 개발용 링크는 `AUTH_PREVIEW_LINKS=true`일 때만 API 응답에 포함된다. 운영 `.env`는 반드시 `AUTH_PREVIEW_LINKS=false`로 두어야 하며, 현재 예시 파일도 false가 기본값이다.
- 회원가입은 이제 자동 로그인되지 않는다. 인증 메일 발송 후 `이메일 인증 후 로그인` 안내만 보여주고, 일반 사용자는 이메일 인증 전까지 로그인할 수 없다.
- 기존에 발급된 세션이라도 일반 사용자 이메일 인증이 안 되어 있으면 `/api/auth/me` 단계에서 세션을 즉시 폐기한다. 운영 중 인증 정책을 켠 뒤에도 미인증 세션이 남지 않게 하기 위한 장치다.
- 비밀번호 재설정/이메일 인증용 개발 링크는 `AUTH_PREVIEW_LINKS=true`여도 `APP_BASE_URL``localhost` 또는 `127.0.0.1`일 때만 응답에 포함한다. 상용 서버에서 링크가 그대로 보이면 이 조건부터 확인한다.
- 프론트는 `/verify-email?token=...` 진입 시 인증을 바로 확정하고 로그인 모달에 결과 메시지를 띄운다. `/reset-password?token=...`은 기존처럼 비밀번호 재설정 모달을 연다.
- SETTINGS 화면에 일반 사용자 전용 `회원 탈퇴` 카드가 추가되었다. 현재 비밀번호 확인 후 계정, 플래너 기록, 목표, 세션, 인증 토큰이 함께 삭제된다. 기본 관리자 계정은 이 경로에서 삭제하지 못하게 막는다.
- `5173` 포트가 직접 `npm run dev` 없이 열려 있으면 대부분 `ten-minute-frontend-dev` 컨테이너가 떠 있는 상태다. 개발용 Docker를 끄려면 `docker compose -f docker-compose.dev.yml down`을 사용한다.
- 현재 환경에서는 Docker 데몬이 꺼져 있어서 `docker compose build` 실검증은 하지 못했고, 데몬 시작 후 다시 확인이 필요하다.
- 이미지 저장 기능은 추후 `print-only` 또는 별도 export 전용 레이아웃을 기준으로 구현하면 화면/인쇄/공유 결과를 맞추기 쉽다.

View File

@@ -61,7 +61,8 @@ docker compose up -d --build
관리자 계정은 백엔드 시작 시 `.env``ADMIN_ACCOUNT_*` 값으로 자동 생성된다.
관리자 아이디와 비밀번호는 저장소 문서에 적지 말고, 운영자만 접근 가능한 비공개 환경변수 파일에서 관리한다.
일반 사용자는 기존처럼 회원가입 후 이메일로 로그인하면 된다.
일반 사용자는 회원가입 후 이메일 인증을 완료해야 로그인할 수 있다.
운영 서버에서는 비밀번호 재설정/이메일 인증용 미리보기 링크가 API 응답에 노출되지 않도록 유지한다.
현재 `docker-compose.yml` 기준 내부 구성:

View File

@@ -14,6 +14,10 @@ const envSchema = z.object({
CORS_ORIGIN: z.string().default('http://localhost:5173'),
SESSION_TTL_DAYS: z.coerce.number().default(30),
APP_BASE_URL: z.string().default('http://localhost:5173'),
RESEND_API_KEY: z.string().optional(),
MAIL_FROM_EMAIL: z.string().email().default('planner@sori.studio'),
MAIL_FROM_NAME: z.string().default('10 Minute Planner'),
AUTH_PREVIEW_LINKS: z.coerce.boolean().default(false),
ADMIN_ACCOUNT_ID: z.string().min(1),
ADMIN_ACCOUNT_PASSWORD: z.string().min(12),
ADMIN_ACCOUNT_EMAIL: z.string().email(),

View File

@@ -61,5 +61,10 @@ export async function findAuthenticatedUser(request) {
.where(eq(users.id, session.userId))
.limit(1)
if (user && user.role !== 'admin' && !user.emailVerifiedAt) {
await db.delete(authSessions).where(eq(authSessions.id, session.id))
return null
}
return user ?? null
}

89
backend/src/lib/mailer.js Normal file
View File

@@ -0,0 +1,89 @@
import { env } from '../config.js'
const RESEND_API_URL = 'https://api.resend.com/emails'
function getFromAddress() {
return `${env.MAIL_FROM_NAME} <${env.MAIL_FROM_EMAIL}>`
}
async function sendWithResend({ to, subject, html, text }) {
if (!env.RESEND_API_KEY) {
return {
skipped: true,
reason: 'RESEND_API_KEY is not configured.',
}
}
const response = await fetch(RESEND_API_URL, {
method: 'POST',
headers: {
Authorization: `Bearer ${env.RESEND_API_KEY}`,
'Content-Type': 'application/json',
'User-Agent': 'ten-minute-planner/1.0',
},
body: JSON.stringify({
from: getFromAddress(),
to,
subject,
html,
text,
}),
})
const data = await response.json().catch(() => ({}))
if (!response.ok) {
throw new Error(data.message || data.error?.message || 'Resend 메일 발송에 실패했습니다.')
}
return {
skipped: false,
id: data.id,
}
}
function buildLinkHtml({ title, description, linkUrl, buttonLabel }) {
return `
<div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif; color: #1c1917; line-height: 1.6;">
<p style="font-size: 12px; letter-spacing: 0.18em; text-transform: uppercase; color: #78716c;">10 Minute Planner</p>
<h1 style="font-size: 24px; margin: 12px 0;">${title}</h1>
<p style="font-size: 15px; color: #57534e;">${description}</p>
<p style="margin: 24px 0;">
<a href="${linkUrl}" style="display: inline-block; border-radius: 999px; background: #1c1917; color: #ffffff; padding: 12px 18px; font-size: 13px; font-weight: 700; text-decoration: none;">
${buttonLabel}
</a>
</p>
<p style="font-size: 12px; color: #78716c;">버튼이 열리지 않으면 아래 링크를 복사해서 브라우저에 붙여넣어 주세요.</p>
<p style="font-size: 12px; word-break: break-all; color: #57534e;">${linkUrl}</p>
<p style="font-size: 12px; color: #a8a29e;">이 링크는 30분 동안 사용할 수 있습니다.</p>
</div>
`
}
export function sendVerificationEmail({ to, linkUrl }) {
return sendWithResend({
to,
subject: '[10 Minute Planner] 이메일 인증',
html: buildLinkHtml({
title: '이메일 인증을 완료해 주세요.',
description: '아래 버튼을 눌러 10 Minute Planner 계정의 이메일 인증을 완료할 수 있습니다.',
linkUrl,
buttonLabel: '이메일 인증하기',
}),
text: `10 Minute Planner 이메일 인증 링크입니다.\n${linkUrl}\n이 링크는 30분 동안 사용할 수 있습니다.`,
})
}
export function sendPasswordResetEmail({ to, linkUrl }) {
return sendWithResend({
to,
subject: '[10 Minute Planner] 비밀번호 재설정',
html: buildLinkHtml({
title: '비밀번호를 재설정해 주세요.',
description: '아래 버튼을 눌러 새 비밀번호를 설정할 수 있습니다. 요청하지 않았다면 이 메일은 무시해 주세요.',
linkUrl,
buttonLabel: '비밀번호 재설정',
}),
text: `10 Minute Planner 비밀번호 재설정 링크입니다.\n${linkUrl}\n요청하지 않았다면 이 메일은 무시해 주세요.`,
})
}

View File

@@ -4,6 +4,7 @@ import { db } from '../db/client.js'
import { authSessions, emailVerificationTokens, passwordResetTokens, users } from '../db/schema.js'
import { createSessionToken, hashSessionToken, hashPassword, verifyPassword } from '../lib/password.js'
import { createSession, findAuthenticatedUser } from '../lib/authSession.js'
import { sendPasswordResetEmail, sendVerificationEmail } from '../lib/mailer.js'
import { env } from '../config.js'
const signupSchema = z.object({
@@ -27,6 +28,10 @@ const passwordSchema = z.object({
newPassword: z.string().min(8).max(72),
})
const deleteAccountSchema = z.object({
currentPassword: z.string().min(1).max(72),
})
const verificationRequestSchema = z.object({
email: z.string().trim().email().optional(),
})
@@ -108,6 +113,31 @@ function sanitizeUser(user) {
}
}
function withPreviewUrl(payload, key, previewUrl) {
const allowPreviewLinks =
env.AUTH_PREVIEW_LINKS &&
/localhost|127\.0\.0\.1/i.test(env.APP_BASE_URL)
if (!allowPreviewLinks) {
return payload
}
return {
...payload,
[key]: previewUrl,
}
}
async function findUserByNickname(nickname) {
const [user] = await db
.select()
.from(users)
.where(eq(users.nickname, nickname))
.limit(1)
return user ?? null
}
export async function registerAuthRoutes(app) {
app.post('/api/auth/signup', async (request, reply) => {
const payload = signupSchema.safeParse(request.body)
@@ -134,6 +164,14 @@ export async function registerAuthRoutes(app) {
})
}
const existingNicknameUser = await findUserByNickname(nickname)
if (existingNicknameUser) {
return reply.code(409).send({
message: '이미 사용 중인 닉네임입니다.',
})
}
const now = new Date()
const passwordHash = await hashPassword(password)
const [user] = await db
@@ -145,21 +183,22 @@ export async function registerAuthRoutes(app) {
nickname,
role: 'user',
emailVerifiedAt: null,
lastLoginAt: now,
lastLoginAt: null,
createdAt: now,
updatedAt: now,
})
.returning()
const { token } = await createSession(user.id)
const verification = await createEmailVerificationToken(user.id)
return reply.code(201).send({
message: '회원가입이 완료되었습니다.',
token,
user: sanitizeUser(user),
verificationPreviewUrl: verification.previewUrl,
await sendVerificationEmail({
to: user.email,
linkUrl: verification.previewUrl,
})
return reply.code(201).send(withPreviewUrl({
message: '회원가입이 완료되었습니다. 이메일 인증 후 로그인해 주세요.',
requiresEmailVerification: true,
}, 'verificationPreviewUrl', verification.previewUrl))
})
app.post('/api/auth/login', async (request, reply) => {
@@ -200,6 +239,12 @@ export async function registerAuthRoutes(app) {
})
}
if (user.role !== 'admin' && !user.emailVerifiedAt) {
return reply.code(403).send({
message: '이메일 인증을 완료한 뒤 로그인해 주세요.',
})
}
const now = new Date()
const [updatedUser] = await db
@@ -266,6 +311,14 @@ export async function registerAuthRoutes(app) {
})
}
const existingNicknameUser = await findUserByNickname(payload.data.nickname)
if (existingNicknameUser && existingNicknameUser.id !== user.id) {
return reply.code(409).send({
message: '이미 사용 중인 닉네임입니다.',
})
}
const [updatedUser] = await db
.update(users)
.set({
@@ -323,6 +376,46 @@ export async function registerAuthRoutes(app) {
}
})
app.delete('/api/auth/account', async (request, reply) => {
const user = await findAuthenticatedUser(request)
if (!user) {
return reply.code(401).send({
message: '인증이 필요합니다.',
})
}
if (user.role === 'admin') {
return reply.code(403).send({
message: '기본 관리자 계정은 여기서 삭제할 수 없습니다.',
})
}
const payload = deleteAccountSchema.safeParse(request.body)
if (!payload.success) {
return reply.code(400).send({
message: '회원 탈퇴 확인 비밀번호를 입력해 주세요.',
issues: payload.error.flatten(),
})
}
const passwordMatches = await verifyPassword(payload.data.currentPassword, user.passwordHash)
if (!passwordMatches) {
return reply.code(401).send({
message: '현재 비밀번호가 올바르지 않습니다.',
})
}
await db.delete(authSessions).where(eq(authSessions.userId, user.id))
await db.delete(users).where(eq(users.id, user.id))
return {
message: '회원 탈퇴가 완료되었습니다.',
}
})
app.post('/api/auth/verification/request', async (request, reply) => {
const authenticatedUser = await findAuthenticatedUser(request)
const payload = verificationRequestSchema.safeParse(request.body ?? {})
@@ -361,11 +454,14 @@ export async function registerAuthRoutes(app) {
}
const verification = await createEmailVerificationToken(user.id)
await sendVerificationEmail({
to: user.email,
linkUrl: verification.previewUrl,
})
return {
return withPreviewUrl({
message: '이메일 인증 링크를 준비했습니다.',
verificationPreviewUrl: verification.previewUrl,
}
}, 'verificationPreviewUrl', verification.previewUrl)
})
app.post('/api/auth/verification/confirm', async (request, reply) => {
@@ -445,11 +541,14 @@ export async function registerAuthRoutes(app) {
}
const reset = await createPasswordResetToken(user.id)
await sendPasswordResetEmail({
to: user.email,
linkUrl: reset.previewUrl,
})
return {
return withPreviewUrl({
message: '비밀번호 재설정 링크를 준비했습니다.',
resetPreviewUrl: reset.previewUrl,
}
}, 'resetPreviewUrl', reset.previewUrl)
})
app.post('/api/auth/password-reset/confirm', async (request, reply) => {

4
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{
"name": "ten-minute-planner",
"version": "0.1.42",
"version": "0.1.43",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "ten-minute-planner",
"version": "0.1.42",
"version": "0.1.43",
"dependencies": {
"vue": "^3.5.13"
},

View File

@@ -1,7 +1,7 @@
{
"name": "ten-minute-planner",
"private": true,
"version": "0.1.42",
"version": "0.1.43",
"type": "module",
"scripts": {
"dev": "vite",

View File

@@ -11,10 +11,14 @@ import StatsDashboard from './components/StatsDashboard.vue'
import { fetchAdminOverview } from './lib/adminApi'
import {
clearAuthState,
confirmVerification,
deleteAccount,
fetchCurrentUser,
confirmPasswordReset,
login,
persistAuthState,
readAuthState,
requestPasswordReset,
signup,
updatePassword,
updateProfile,
@@ -36,6 +40,7 @@ const CARRYOVER_CHECK_POLICIES = ['ask', 'all', 'current']
const screenMode = ref('planner')
const viewMode = ref('focus')
const printLayout = ref('single')
const printDialogOpen = ref(false)
const demoMode = ref(false)
const demoDayOffset = ref(0)
const authDialogOpen = ref(false)
@@ -59,10 +64,15 @@ const leftPanelOpen = ref(false)
const rightPanelOpen = ref(false)
const statsRangeStart = ref(toKey(new Date(new Date().setDate(new Date().getDate() - 6))))
const statsRangeEnd = ref(toKey(new Date()))
const printRangeStart = ref(toKey(new Date()))
const printRangeEnd = ref(toKey(new Date()))
const printRangeLayout = ref('single')
const authForm = reactive({
nickname: '',
email: '',
password: '',
resetToken: '',
newPassword: '',
rememberSession: false,
})
const goalForm = reactive({
@@ -80,10 +90,15 @@ const passwordForm = reactive({
newPassword: '',
confirmPassword: '',
})
const accountDeleteForm = reactive({
currentPassword: '',
})
const profileBusy = ref(false)
const passwordBusy = ref(false)
const profileMessage = ref('')
const passwordMessage = ref('')
const accountDeleteBusy = ref(false)
const accountDeleteMessage = ref('')
const carryoverMessage = ref('')
const carryoverCheckPolicy = ref(readCarryoverCheckPolicy())
const carryoverCheckPrompt = ref(null)
@@ -550,6 +565,56 @@ const calendarDays = computed(() => {
})
})
const normalizedPrintRange = computed(() => {
const startKey = printRangeStart.value || toKey(selectedDate.value)
const endKey = printRangeEnd.value || startKey
if (startKey <= endKey) {
return { startKey, endKey }
}
return { startKey: endKey, endKey: startKey }
})
const printDateKeys = computed(() => {
const dateKeys = []
const currentDate = startOfDay(toDateValue(normalizedPrintRange.value.startKey))
const endDate = startOfDay(toDateValue(normalizedPrintRange.value.endKey))
while (currentDate <= endDate) {
dateKeys.push(toKey(currentDate))
currentDate.setDate(currentDate.getDate() + 1)
}
return dateKeys
})
const printPages = computed(() =>
printDateKeys.value.map((dateKey) => createPrintPage(dateKey)),
)
const printPapers = computed(() => {
if (printLayout.value === 'single') {
return printPages.value.map((page) => [page])
}
const papers = []
for (let index = 0; index < printPages.value.length; index += 2) {
papers.push(printPages.value.slice(index, index + 2))
}
return papers
})
const printPageCountLabel = computed(() => {
const dayCount = printDateKeys.value.length
const paperCount = printRangeLayout.value === 'double' ? Math.ceil(dayCount / 2) : dayCount
const layoutLabel = printRangeLayout.value === 'double' ? '2페이지씩' : '1페이지씩'
return `${dayCount}일치 / ${paperCount}장 (${layoutLabel})`
})
const markedDateKeys = computed(() =>
Object.entries(plannerRecords)
.filter(([, record]) => hasPlannerContent(record))
@@ -801,6 +866,12 @@ function closeCarryoverCheckPrompt() {
}
function handleGlobalKeydown(event) {
if (event.key === 'Escape' && printDialogOpen.value) {
event.preventDefault()
closePrintDialog()
return
}
if (event.key === 'Escape' && carryoverCheckPrompt.value) {
event.preventDefault()
closeCarryoverCheckPrompt()
@@ -971,11 +1042,63 @@ function createDateLabel(dateKey) {
return `${display.main} ${display.weekday}`
}
function findPlannerGoalForDate(dateKey) {
const activeGoals = goals.value
.filter((goal) => {
if (!goal.activeFrom || !goal.activeUntil) {
return false
}
return dateKey >= goal.activeFrom && dateKey <= goal.activeUntil
})
.sort((left, right) => {
const currentDate = startOfDay(toDateValue(dateKey))
const leftDistance = Math.abs(startOfDay(toDateValue(left.targetDate)).getTime() - currentDate.getTime())
const rightDistance = Math.abs(startOfDay(toDateValue(right.targetDate)).getTime() - currentDate.getTime())
return leftDistance - rightDistance
})
return activeGoals[0] ?? null
}
function createPlannerDdayForDate(dateKey) {
if (isDdayDisabledForDate(dateKey)) {
return ''
}
const goal = findPlannerGoalForDate(dateKey)
if (!goal) {
return ''
}
const targetDate = startOfDay(toDateValue(goal.targetDate))
const currentDate = startOfDay(toDateValue(dateKey))
const diffDays = Math.round((targetDate.getTime() - currentDate.getTime()) / (24 * 60 * 60 * 1000))
const badge =
diffDays === 0 ? 'D-DAY' : diffDays > 0 ? `D-${diffDays}` : `D+${Math.abs(diffDays)}`
return `${badge} ${goal.title}`
}
function createPrintPage(dateKey) {
const date = toDateValue(dateKey)
return {
key: dateKey,
display: getDateDisplay(date),
record: getPlannerRecord(date),
dday: createPlannerDdayForDate(dateKey),
}
}
const weeklyRecords = computed(() => {
const entries = rangeEntries.value.map(([key, record]) => {
const date = toDateValue(key)
const weekdayShort = ['일', '월', '화', '수', '목', '금', '토'][date.getDay()]
const focusedMinutes = getFocusedMinutes(record)
const activeTasks = record.tasks.filter((task) => task.title.trim())
const doneTasks = activeTasks.filter((task) => task.checked)
return {
key,
@@ -983,6 +1106,8 @@ const weeklyRecords = computed(() => {
dateLabel: `${`${date.getMonth() + 1}`.padStart(2, '0')}.${`${date.getDate()}`.padStart(2, '0')}`,
focusedMinutes,
focusedTime: formatMinutesKorean(focusedMinutes),
completedTasks: doneTasks.length,
totalTasks: activeTasks.length,
}
})
@@ -1207,6 +1332,19 @@ function closeRightPanel() {
rightPanelOpen.value = false
}
function openPrintDialog() {
const selectedKey = toKey(selectedDate.value)
printRangeStart.value = selectedKey
printRangeEnd.value = selectedKey
printRangeLayout.value = viewMode.value === 'spread' ? 'double' : 'single'
printDialogOpen.value = true
closeLeftPanel()
}
function closePrintDialog() {
printDialogOpen.value = false
}
function applyStatsQuickRange(days) {
const endDate = new Date()
const startDate = new Date(endDate)
@@ -1288,6 +1426,8 @@ function resetAuthForm() {
authForm.nickname = ''
authForm.email = ''
authForm.password = ''
authForm.resetToken = ''
authForm.newPassword = ''
authForm.rememberSession = false
}
@@ -1310,12 +1450,76 @@ function resetPasswordForm() {
passwordForm.confirmPassword = ''
}
function resetAccountDeleteForm() {
accountDeleteForm.currentPassword = ''
}
function openAuthDialog(mode = 'login') {
authMode.value = mode
authMessage.value = ''
authDialogOpen.value = true
}
function openPasswordResetFromUrl() {
if (typeof window === 'undefined') {
return
}
const url = new URL(window.location.href)
if (!url.pathname.includes('reset-password')) {
return
}
const token = url.searchParams.get('token') ?? ''
if (!token) {
return
}
authForm.resetToken = token
authMode.value = 'reset-confirm'
authMessage.value = ''
authDialogOpen.value = true
}
async function openVerificationFromUrl() {
if (typeof window === 'undefined') {
return
}
const url = new URL(window.location.href)
if (!url.pathname.includes('verify-email')) {
return
}
const token = url.searchParams.get('token') ?? ''
if (!token) {
authMode.value = 'login'
authMessage.value = '이메일 인증 링크가 올바르지 않습니다.'
authDialogOpen.value = true
return
}
authBusy.value = true
authMode.value = 'login'
authDialogOpen.value = true
try {
const result = await confirmVerification({ token })
authMessage.value = result.message || '이메일 인증이 완료되었습니다. 이제 로그인할 수 있습니다.'
url.pathname = '/'
url.search = ''
window.history.replaceState({}, '', url.toString())
} catch (error) {
authMessage.value = toUserFacingApiError(error, '이메일 인증 링크를 처리하지 못했습니다.')
} finally {
authBusy.value = false
}
}
function closeAuthDialog() {
authDialogOpen.value = false
authMessage.value = ''
@@ -1347,19 +1551,48 @@ async function submitAuthForm() {
authMessage.value = ''
try {
const result =
authMode.value === 'login'
? await login({
email: authForm.email,
password: authForm.password,
})
: await signup({
nickname: authForm.nickname,
email: authForm.email,
password: authForm.password,
})
if (authMode.value === 'reset-request') {
const result = await requestPasswordReset({
email: authForm.email,
})
authMessage.value = result.resetPreviewUrl
? `${result.message} 개발용 링크: ${result.resetPreviewUrl}`
: result.message
return
}
await applyAuthSuccess(result, authMode.value === 'login' && authForm.rememberSession)
if (authMode.value === 'reset-confirm') {
const result = await confirmPasswordReset({
token: authForm.resetToken,
newPassword: authForm.newPassword,
})
authMode.value = 'login'
authForm.password = ''
authForm.newPassword = ''
authForm.resetToken = ''
authMessage.value = result.message
return
}
const result = authMode.value === 'login'
? await login({
email: authForm.email,
password: authForm.password,
})
: await signup({
nickname: authForm.nickname,
email: authForm.email,
password: authForm.password,
})
if (authMode.value === 'signup') {
authMode.value = 'login'
authForm.password = ''
authMessage.value = result.message
return
}
await applyAuthSuccess(result, authForm.rememberSession)
} catch (error) {
authMessage.value = toUserFacingApiError(error, '인증 처리 중 문제가 발생했습니다.')
} finally {
@@ -1410,6 +1643,7 @@ function logout() {
adminMessage.value = ''
adminUsers.value = []
adminRecentLogins.value = []
accountDeleteMessage.value = ''
adminOverview.value = {
totalUsers: 0,
totalAdmins: 0,
@@ -1429,6 +1663,7 @@ function logout() {
restoreLocalPlannerRecords()
resetGoalForm()
resetPasswordForm()
resetAccountDeleteForm()
}
async function loadAdminDashboard() {
@@ -1628,6 +1863,10 @@ function updatePasswordField({ field, value }) {
passwordForm[field] = value
}
function updateAccountDeleteField({ field, value }) {
accountDeleteForm[field] = value
}
async function submitProfileForm() {
profileBusy.value = true
profileMessage.value = ''
@@ -1684,6 +1923,36 @@ async function submitPasswordForm() {
}
}
async function submitDeleteAccount() {
if (!accountDeleteForm.currentPassword) {
accountDeleteMessage.value = '회원 탈퇴를 위해 현재 비밀번호를 입력해 주세요.'
return
}
const confirmed = window.confirm('정말로 회원 탈퇴하시겠습니까? 작성한 플래너와 목표 데이터도 함께 삭제됩니다.')
if (!confirmed) {
return
}
accountDeleteBusy.value = true
accountDeleteMessage.value = ''
try {
const result = await deleteAccount(authToken.value, {
currentPassword: accountDeleteForm.currentPassword,
})
resetAccountDeleteForm()
logout()
authMessage.value = ''
window.alert(result.message || '회원 탈퇴가 완료되었습니다.')
} catch (error) {
accountDeleteMessage.value = error.message || '회원 탈퇴를 처리하지 못했습니다.'
} finally {
accountDeleteBusy.value = false
}
}
function replacePlannerRecords(nextRecords) {
Object.keys(plannerRecords).forEach((key) => {
delete plannerRecords[key]
@@ -1841,6 +2110,19 @@ async function printSelectedPlanner(layout = 'single') {
window.print()
}
async function printPlannerRange() {
printLayout.value = printRangeLayout.value
applyPrintPageStyle(printRangeLayout.value)
await nextTick()
window.print()
}
async function initializeAppSession() {
await openVerificationFromUrl()
openPasswordResetFromUrl()
await restoreAuthSession()
}
onMounted(() => {
resetGoalForm()
setSyncFeedback('local', '로그인 후 클라우드 저장을 사용할 수 있습니다.', {
@@ -1849,7 +2131,7 @@ onMounted(() => {
updateWindowWidth()
window.addEventListener('resize', updateWindowWidth)
window.addEventListener('keydown', handleGlobalKeydown)
restoreAuthSession()
initializeAppSession()
})
onBeforeUnmount(() => {
@@ -2054,16 +2336,9 @@ onBeforeUnmount(() => {
<button
type="button"
class="rounded-2xl border border-stone-200 px-4 py-3 text-xs font-bold tracking-[0.14em] text-stone-600 transition hover:border-stone-400 hover:text-ink"
@click="printSelectedPlanner('single')"
@click="openPrintDialog"
>
1 인쇄
</button>
<button
type="button"
class="rounded-2xl border border-stone-200 px-4 py-3 text-xs font-bold tracking-[0.14em] text-stone-600 transition hover:border-stone-400 hover:text-ink"
@click="printSelectedPlanner('double')"
>
2 인쇄
PRINT
</button>
</div>
</section>
@@ -2093,9 +2368,6 @@ onBeforeUnmount(() => {
<div class="overflow-hidden rounded-[28px] border border-stone-200 bg-[linear-gradient(145deg,rgba(255,255,255,0.96),rgba(246,238,228,0.92))] p-5 shadow-[0_18px_40px_rgba(28,25,23,0.06)]">
<div class="flex items-center justify-between gap-3">
<p class="text-[11px] font-bold uppercase tracking-[0.28em] text-stone-500">10 Minute Planner</p>
<span class="rounded-full border border-stone-200 bg-white/80 px-3 py-1 text-[10px] font-bold tracking-[0.18em] text-stone-500">
DAILY FLOW
</span>
</div>
<div class="mt-6 space-y-3">
<h1 class="text-[28px] font-semibold leading-[1.1] tracking-[-0.06em] text-stone-900">
@@ -2222,16 +2494,9 @@ onBeforeUnmount(() => {
<button
type="button"
class="rounded-2xl border border-stone-200 px-4 py-3 text-xs font-bold tracking-[0.14em] text-stone-600 transition hover:border-stone-400 hover:text-ink"
@click="printSelectedPlanner('single')"
@click="openPrintDialog"
>
1 인쇄
</button>
<button
type="button"
class="rounded-2xl border border-stone-200 px-4 py-3 text-xs font-bold tracking-[0.14em] text-stone-600 transition hover:border-stone-400 hover:text-ink"
@click="printSelectedPlanner('double')"
>
2 인쇄
PRINT
</button>
</div>
</section>
@@ -2251,7 +2516,7 @@ onBeforeUnmount(() => {
10 MINITES PLANNER
</h2>
<p class="mx-auto mt-3 max-w-xl text-sm leading-7 text-stone-600 sm:text-base">
장기 목표, , 집중 시간, 짧은 코멘트를 장의 다이어리로 남기고 내일의 작업까지 이어가세요.
장기 목표, , 집중 시간, 짧은 코멘트를 장의 다이어리로 남기고<br />내일의 작업까지 이어가세요.
</p>
</div>
@@ -2792,13 +3057,18 @@ onBeforeUnmount(() => {
:password-busy="passwordBusy"
:profile-message="profileMessage"
:password-message="passwordMessage"
:account-delete-form="accountDeleteForm"
:account-delete-busy="accountDeleteBusy"
:account-delete-message="accountDeleteMessage"
:guide-tooltip-reset-message="guideTooltipResetMessage"
:carryover-check-policy="carryoverCheckPolicy"
@update:profile-field="updateProfileField"
@update:password-field="updatePasswordField"
@update:account-delete-field="updateAccountDeleteField"
@update:carryover-check-policy="updateCarryoverCheckPolicy"
@submit:profile="submitProfileForm"
@submit:password="submitPasswordForm"
@submit:delete-account="submitDeleteAccount"
@reset-guide-tooltips="resetGuideTooltips"
/>
@@ -2828,79 +3098,35 @@ onBeforeUnmount(() => {
/>
<section v-if="isAuthenticated" class="print-only">
<div v-if="printLayout === 'single'" class="print-paper print-paper--single">
<div class="print-sheet-frame">
<div
v-for="(paper, paperIndex) in printPapers"
:key="`${printLayout}-${paperIndex}`"
class="print-paper"
:class="printLayout === 'single' ? 'print-paper--single' : 'print-paper--double'"
>
<div
v-for="page in paper"
:key="page.key"
class="print-sheet-frame"
>
<PlannerPage
:date-main="selectedDateDisplay.main"
:date-weekday="selectedDateDisplay.weekday"
:date-weekday-tone="selectedDateDisplay.weekdayTone"
:dday="plannerDday"
:show-dday="showPlannerDday"
:comment="planner.comment"
:total-time="formatTotalTimeKorean(planner)"
:tasks="planner.tasks"
:memo="planner.memo"
:date-main="page.display.main"
:date-weekday="page.display.weekday"
:date-weekday-tone="page.display.weekdayTone"
:dday="page.dday"
:show-dday="Boolean(page.dday)"
:comment="page.record.comment"
:total-time="formatTotalTimeKorean(page.record)"
:tasks="page.record.tasks"
:memo="page.record.memo"
:hours="hours"
:timetable="planner.timetable"
@update:comment="updateComment(planner, $event)"
@update:task-label="updateTaskLabel(planner, $event)"
@update:task-title="updateTaskTitle(planner, $event)"
@toggle:task="toggleTask(planner, $event)"
@clear:tasks="clearTasks(planner, $event)"
@update:memo-label="updateMemoLabel(planner, $event)"
@update:memo="updateMemo(planner, $event)"
@update:timetable="updateTimetable(planner, $event)"
/>
</div>
</div>
<div v-else class="print-paper print-paper--double">
<div class="print-sheet-frame">
<PlannerPage
:date-main="selectedDateDisplay.main"
:date-weekday="selectedDateDisplay.weekday"
:date-weekday-tone="selectedDateDisplay.weekdayTone"
:dday="plannerDday"
:show-dday="showPlannerDday"
:comment="planner.comment"
:total-time="formatTotalTimeKorean(planner)"
:tasks="planner.tasks"
:memo="planner.memo"
:hours="hours"
:timetable="planner.timetable"
@update:comment="updateComment(planner, $event)"
@update:task-label="updateTaskLabel(planner, $event)"
@update:task-title="updateTaskTitle(planner, $event)"
@toggle:task="toggleTask(planner, $event)"
@clear:tasks="clearTasks(planner, $event)"
@update:memo-label="updateMemoLabel(planner, $event)"
@update:memo="updateMemo(planner, $event)"
@update:timetable="updateTimetable(planner, $event)"
/>
</div>
<div class="print-sheet-frame">
<PlannerPage
:date-main="secondaryDateDisplay.main"
:date-weekday="secondaryDateDisplay.weekday"
:date-weekday-tone="secondaryDateDisplay.weekdayTone"
:dday="''"
:show-dday="false"
:comment="secondaryPlanner.comment"
:total-time="formatTotalTimeKorean(secondaryPlanner)"
:tasks="secondaryPlanner.tasks"
:memo="secondaryPlanner.memo"
:hours="hours"
:timetable="secondaryPlanner.timetable"
@update:comment="updateComment(secondaryPlanner, $event)"
@update:task-label="updateTaskLabel(secondaryPlanner, $event)"
@update:task-title="updateTaskTitle(secondaryPlanner, $event)"
@toggle:task="toggleTask(secondaryPlanner, $event)"
@clear:tasks="clearTasks(secondaryPlanner, $event)"
@update:memo-label="updateMemoLabel(secondaryPlanner, $event)"
@update:memo="updateMemo(secondaryPlanner, $event)"
@update:timetable="updateTimetable(secondaryPlanner, $event)"
:timetable="page.record.timetable"
/>
</div>
<div
v-if="printLayout === 'double' && paper.length === 1"
class="print-sheet-frame print-sheet-frame--blank"
/>
</div>
</section>
</div>
@@ -2918,6 +3144,93 @@ onBeforeUnmount(() => {
@update:field="updateAuthField"
/>
<div
v-if="printDialogOpen"
class="print-hidden fixed inset-0 z-50 flex items-center justify-center bg-stone-900/45 px-4 py-6 backdrop-blur-sm"
@click.self="closePrintDialog"
>
<section class="w-full max-w-lg rounded-[30px] border border-white/70 bg-[#f7f2ea] p-5 shadow-[0_24px_80px_rgba(28,25,23,0.2)] sm:p-6">
<div class="flex items-start justify-between gap-4">
<div>
<p class="text-[10px] font-bold uppercase tracking-[0.24em] text-stone-500">Print Planner</p>
<h2 class="mt-3 text-2xl font-semibold tracking-[-0.05em] text-stone-900">
출력할 날짜 범위 선택
</h2>
<p class="mt-3 text-sm font-semibold leading-6 text-stone-600">
선택한 기간을 1페이지씩 또는 2페이지씩 묶어서 바로 출력합니다.
</p>
</div>
<button
type="button"
class="rounded-full border border-stone-200 bg-white px-3 py-2 text-[10px] font-bold tracking-[0.14em] text-stone-500 transition hover:border-stone-400 hover:text-stone-900"
@click="closePrintDialog"
>
CLOSE
</button>
</div>
<div class="mt-6 grid gap-4 sm:grid-cols-2">
<label class="flex flex-col gap-2 text-[11px] font-bold tracking-[0.14em] text-stone-500">
시작일
<input
v-model="printRangeStart"
type="date"
class="rounded-2xl border border-stone-200 bg-white px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-stone-400"
/>
</label>
<label class="flex flex-col gap-2 text-[11px] font-bold tracking-[0.14em] text-stone-500">
종료일
<input
v-model="printRangeEnd"
type="date"
class="rounded-2xl border border-stone-200 bg-white px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-stone-400"
/>
</label>
</div>
<div class="mt-5 grid gap-2 sm:grid-cols-2">
<button
type="button"
class="rounded-2xl px-4 py-3 text-xs font-bold tracking-[0.14em] transition"
:class="printRangeLayout === 'single' ? 'bg-stone-900 text-white' : 'border border-stone-200 bg-white text-stone-500'"
@click="printRangeLayout = 'single'"
>
1페이지씩
</button>
<button
type="button"
class="rounded-2xl px-4 py-3 text-xs font-bold tracking-[0.14em] transition"
:class="printRangeLayout === 'double' ? 'bg-stone-900 text-white' : 'border border-stone-200 bg-white text-stone-500'"
@click="printRangeLayout = 'double'"
>
2페이지씩
</button>
</div>
<div class="mt-5 rounded-2xl border border-stone-200 bg-white/78 px-4 py-3">
<p class="text-[11px] font-bold tracking-[0.12em] text-stone-500">출력 예정</p>
<p class="mt-1 text-sm font-semibold text-stone-900">{{ printPageCountLabel }}</p>
</div>
<div class="mt-6 grid gap-2 sm:grid-cols-[1fr_auto]">
<button
type="button"
class="rounded-full border border-stone-900 bg-stone-900 px-5 py-3 text-xs font-bold tracking-[0.16em] text-white transition hover:bg-stone-700"
@click="printPlannerRange"
>
PRINT
</button>
<button
type="button"
class="rounded-full border border-stone-300 bg-white px-5 py-3 text-xs font-bold tracking-[0.16em] text-stone-700 transition hover:border-stone-500 hover:text-stone-900"
@click="closePrintDialog"
>
취소
</button>
</div>
</section>
</div>
<div
v-if="carryoverCheckPrompt"
class="fixed inset-0 z-50 flex items-center justify-center bg-stone-900/45 px-4 py-6 backdrop-blur-sm"

View File

@@ -35,6 +35,58 @@ function updateField(field, event) {
value: event.target.type === 'checkbox' ? event.target.checked : event.target.value,
})
}
function getTitle(mode) {
if (mode === 'signup') {
return '회원가입'
}
if (mode === 'reset-request') {
return '비밀번호 찾기'
}
if (mode === 'reset-confirm') {
return '새 비밀번호 설정'
}
return '로그인'
}
function getDescription(mode) {
if (mode === 'signup') {
return '기록을 저장할 계정을 만들어요.'
}
if (mode === 'reset-request') {
return '가입한 이메일로 재설정 링크를 받을 수 있습니다.'
}
if (mode === 'reset-confirm') {
return '메일로 받은 링크의 토큰과 새 비밀번호를 확인합니다.'
}
return '내 플래너를 이어서 열어요.'
}
function getSubmitLabel(mode, busy) {
if (busy) {
return '처리 중...'
}
if (mode === 'signup') {
return '가입하기'
}
if (mode === 'reset-request') {
return '재설정 링크 받기'
}
if (mode === 'reset-confirm') {
return '비밀번호 재설정'
}
return '로그인하기'
}
</script>
<template>
@@ -47,10 +99,10 @@ function updateField(field, event) {
<div>
<p class="text-[10px] font-bold uppercase tracking-[0.24em] text-stone-500">10 Minute Planner</p>
<h2 class="mt-2 text-2xl font-semibold tracking-[-0.04em] text-stone-900">
{{ mode === 'login' ? '로그인' : '회원가입' }}
{{ getTitle(mode) }}
</h2>
<p class="mt-2 text-sm leading-6 text-stone-600">
{{ mode === 'login' ? '내 플래너를 이어서 열어요.' : '기록을 저장할 계정을 만들어요.' }}
{{ getDescription(mode) }}
</p>
</div>
<button
@@ -74,7 +126,7 @@ function updateField(field, event) {
/>
</div>
<div class="space-y-2">
<div v-if="mode !== 'reset-confirm'" class="space-y-2">
<label class="text-[11px] font-bold tracking-[0.16em] text-stone-600">
{{ mode === 'login' ? '이메일 또는 아이디' : '이메일' }}
</label>
@@ -87,7 +139,18 @@ function updateField(field, event) {
/>
</div>
<div class="space-y-2">
<div v-if="mode === 'reset-confirm'" class="space-y-2">
<label class="text-[11px] font-bold tracking-[0.16em] text-stone-600">재설정 토큰</label>
<input
:value="form.resetToken"
type="text"
class="w-full rounded-2xl border border-stone-300 bg-white/90 px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-stone-500"
placeholder="메일 링크의 토큰"
@input="updateField('resetToken', $event)"
/>
</div>
<div v-if="mode === 'login' || mode === 'signup'" class="space-y-2">
<label class="text-[11px] font-bold tracking-[0.16em] text-stone-600">비밀번호</label>
<input
:value="form.password"
@@ -98,6 +161,17 @@ function updateField(field, event) {
/>
</div>
<div v-if="mode === 'reset-confirm'" class="space-y-2">
<label class="text-[11px] font-bold tracking-[0.16em] text-stone-600"> 비밀번호</label>
<input
:value="form.newPassword"
type="password"
class="w-full rounded-2xl border border-stone-300 bg-white/90 px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-stone-500"
placeholder="8자 이상 입력해 주세요."
@input="updateField('newPassword', $event)"
/>
</div>
<label
v-if="mode === 'login'"
class="-mt-1 flex items-center gap-2 px-1 text-left"
@@ -123,13 +197,22 @@ function updateField(field, event) {
class="w-full rounded-full bg-stone-900 px-5 py-3 text-xs font-bold tracking-[0.18em] text-white transition hover:bg-stone-700 disabled:cursor-not-allowed disabled:bg-stone-400"
:disabled="busy"
>
{{ busy ? '처리 중...' : mode === 'login' ? '로그인하기' : '가입하기' }}
{{ getSubmitLabel(mode, busy) }}
</button>
</form>
<button
v-if="mode === 'login'"
type="button"
class="mt-4 w-full text-center text-xs font-bold tracking-[0.14em] text-stone-500 underline underline-offset-4 transition hover:text-stone-900"
@click="emit('switch-mode', 'reset-request')"
>
비밀번호를 잊으셨나요?
</button>
<div class="mt-5 flex items-center justify-center gap-2 border-t border-stone-300/70 pt-4">
<p class="text-sm font-semibold text-stone-600">
{{ mode === 'login' ? '아직 계정이 나요?' : '이미 계정이 있나요?' }}
{{ mode === 'signup' ? '이미 계정이 나요?' : '계정 화면으로 돌아갈까요?' }}
</p>
<button
type="button"

View File

@@ -304,7 +304,7 @@ onBeforeUnmount(() => {
</div>
<div class="planner-sheet__body flex flex-col gap-5 py-[10px] lg:flex-row lg:gap-4">
<div class="planner-sheet__lists flex w-full flex-1 flex-col gap-[25px] lg:w-[394px]">
<div class="planner-sheet__lists flex w-full flex-1 flex-col gap-[21px] lg:w-[394px]">
<section>
<div class="flex items-center gap-2 text-muted">
<span class="shrink-0">TASKS</span>

View File

@@ -14,6 +14,10 @@ const props = defineProps({
type: Object,
required: true,
},
accountDeleteForm: {
type: Object,
required: true,
},
profileBusy: {
type: Boolean,
default: false,
@@ -30,6 +34,14 @@ const props = defineProps({
type: String,
default: '',
},
accountDeleteBusy: {
type: Boolean,
default: false,
},
accountDeleteMessage: {
type: String,
default: '',
},
guideTooltipResetMessage: {
type: String,
default: '',
@@ -45,6 +57,8 @@ const emit = defineEmits([
'update:password-field',
'submit:profile',
'submit:password',
'update:account-delete-field',
'submit:delete-account',
'reset-guide-tooltips',
'update:carryover-check-policy',
])
@@ -66,6 +80,13 @@ function updatePasswordField(field, event) {
value: event.target.value,
})
}
function updateAccountDeleteField(field, event) {
emit('update:account-delete-field', {
field,
value: event.target.value,
})
}
</script>
<template>
@@ -219,6 +240,42 @@ function updatePasswordField(field, event) {
{{ passwordBusy ? '변경 중...' : '비밀번호 변경' }}
</button>
</form>
<form
v-if="user.role !== 'admin'"
class="rounded-[28px] border border-rose-200 bg-white/75 p-6"
@submit.prevent="emit('submit:delete-account')"
>
<p class="text-[11px] font-bold uppercase tracking-[0.24em] text-rose-500">Delete Account</p>
<p class="mt-4 text-sm font-semibold leading-6 text-stone-700">
회원 탈퇴를 진행하면 플래너 기록, 목표, 계정 정보가 함께 삭제됩니다.
</p>
<div class="mt-5 space-y-2">
<label class="text-[11px] font-bold tracking-[0.16em] text-stone-600">현재 비밀번호 확인</label>
<input
:value="accountDeleteForm.currentPassword"
type="password"
class="w-full rounded-2xl border border-rose-200 bg-white px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-rose-400"
@input="updateAccountDeleteField('currentPassword', $event)"
/>
</div>
<p
v-if="accountDeleteMessage"
class="mt-4 rounded-2xl border border-rose-200 bg-rose-50 px-4 py-3 text-sm font-semibold leading-6 text-rose-700"
>
{{ accountDeleteMessage }}
</p>
<button
type="submit"
class="mt-5 rounded-full border border-rose-500 px-5 py-3 text-xs font-bold tracking-[0.18em] text-rose-600 transition hover:bg-rose-500 hover:text-white disabled:cursor-not-allowed disabled:border-rose-200 disabled:text-rose-300"
:disabled="accountDeleteBusy"
>
{{ accountDeleteBusy ? '처리 중...' : '회원 탈퇴' }}
</button>
</form>
</div>
</section>
</template>

View File

@@ -1,7 +1,8 @@
<script setup>
import { computed, ref } from 'vue'
import GuideTooltip from './GuideTooltip.vue'
defineProps({
const props = defineProps({
overviewCards: {
type: Array,
required: true,
@@ -33,6 +34,133 @@ defineProps({
})
const emit = defineEmits(['update:range-start', 'update:range-end', 'quick-range'])
const flowScrollerRef = ref(null)
const flowDragState = ref(null)
const hoveredFlowRecord = ref(null)
const flowTooltipPosition = ref({ x: 0, y: 0 })
const flowGapClass = computed(() => {
if (props.weeklyRecords.length > 14) {
return 'gap-1'
}
return 'gap-3'
})
const flowItemStyle = computed(() => {
const count = props.weeklyRecords.length
if (count <= 0) {
return {}
}
const gap = count > 14 ? 4 : 12
const minWidth = count <= 7 ? 76 : count <= 14 ? 46 : 18
if (count <= 31) {
return {
flex: '0 0 auto',
width: `max(${minWidth}px, calc((100% - ${(count - 1) * gap}px) / ${count}))`,
}
}
return {
flex: '0 0 auto',
width: '18px',
}
})
const flowBarWidth = computed(() => {
if (props.weeklyRecords.length <= 7) {
return '48px'
}
if (props.weeklyRecords.length <= 14) {
return '30px'
}
return '12px'
})
const shouldShowFlowTime = computed(() => props.weeklyRecords.length <= 14)
function shouldShowFlowLabel(index) {
const count = props.weeklyRecords.length
if (count <= 14) {
return true
}
const interval = Math.ceil(count / 8)
return index === 0 || index === count - 1 || index % interval === 0
}
function updateFlowTooltipPosition(event) {
const tooltipWidth = 176
const tooltipHeight = 86
const margin = 12
const viewportWidth = window.innerWidth || tooltipWidth
const safeX = Math.min(
Math.max(event.clientX, margin + tooltipWidth / 2),
viewportWidth - margin - tooltipWidth / 2,
)
const safeY = Math.max(event.clientY - 18, margin + tooltipHeight)
flowTooltipPosition.value = {
x: safeX,
y: safeY,
}
}
function showFlowTooltip(record, event) {
hoveredFlowRecord.value = record
updateFlowTooltipPosition(event)
}
function moveFlowTooltip(event) {
if (!hoveredFlowRecord.value) {
return
}
updateFlowTooltipPosition(event)
}
function hideFlowTooltip() {
hoveredFlowRecord.value = null
}
function startFlowDrag(event) {
if (!flowScrollerRef.value || event.button !== 0) {
return
}
flowDragState.value = {
pointerId: event.pointerId,
startX: event.clientX,
scrollLeft: flowScrollerRef.value.scrollLeft,
}
flowScrollerRef.value.setPointerCapture?.(event.pointerId)
}
function moveFlowDrag(event) {
if (!flowDragState.value || !flowScrollerRef.value) {
return
}
event.preventDefault()
flowScrollerRef.value.scrollLeft =
flowDragState.value.scrollLeft - (event.clientX - flowDragState.value.startX)
}
function stopFlowDrag(event) {
if (!flowDragState.value) {
return
}
flowScrollerRef.value?.releasePointerCapture?.(event.pointerId)
flowDragState.value = null
}
</script>
<template>
@@ -96,7 +224,7 @@ const emit = defineEmits(['update:range-start', 'update:range-end', 'quick-range
</article>
</div>
<div class="grid gap-6 xl:grid-cols-[minmax(0,1.3fr)_minmax(320px,0.7fr)]">
<div class="grid items-start gap-6 xl:grid-cols-[minmax(0,1.3fr)_minmax(320px,0.7fr)]">
<article class="rounded-[28px] border border-stone-200 bg-white/86 p-6">
<div class="flex items-end justify-between gap-4">
<div>
@@ -113,22 +241,42 @@ const emit = defineEmits(['update:range-start', 'update:range-end', 'quick-range
</p>
</div>
<div class="mt-8 flex min-h-[230px] items-stretch gap-3 overflow-x-auto border-b border-stone-200 pb-4">
<div
ref="flowScrollerRef"
class="mt-8 flex h-[268px] select-none items-stretch overflow-x-auto overscroll-x-contain border-b border-stone-200 pb-4 cursor-grab active:cursor-grabbing"
:class="flowGapClass"
@pointerdown="startFlowDrag"
@pointermove="moveFlowDrag"
@pointerup="stopFlowDrag"
@pointercancel="stopFlowDrag"
@pointerleave="stopFlowDrag"
>
<div
v-for="record in weeklyRecords"
v-for="(record, index) in weeklyRecords"
:key="record.key"
class="flex min-w-[64px] flex-col items-center justify-end gap-3"
class="relative flex flex-col items-center justify-end gap-3"
:style="flowItemStyle"
@mouseenter="showFlowTooltip(record, $event)"
@mousemove="moveFlowTooltip"
@mouseleave="hideFlowTooltip"
>
<div class="flex h-44 items-end">
<div
class="w-11 rounded-t-full bg-stone-900/90 transition-all"
:style="{ height: `${record.barHeight}%` }"
class="rounded-t-full bg-stone-900/90 transition-all"
:style="{ width: flowBarWidth, height: `${record.barHeight}%` }"
/>
</div>
<div class="text-center">
<p class="text-[11px] font-bold tracking-[0.12em] text-stone-500">{{ record.dateLabel }}</p>
<p class="mt-1 text-[10px] font-bold tracking-[0.12em] text-stone-400">{{ record.weekday }}</p>
<p class="mt-1 text-[11px] font-semibold text-stone-800">{{ record.focusedTime }}</p>
<div class="h-14 text-center">
<template v-if="shouldShowFlowLabel(index)">
<p class="select-none text-[11px] font-bold tracking-[0.12em] text-stone-500">{{ record.dateLabel }}</p>
<p class="mt-1 select-none text-[10px] font-bold tracking-[0.12em] text-stone-400">{{ record.weekday }}</p>
</template>
<p
v-if="shouldShowFlowTime"
class="mt-1 select-none text-[11px] font-semibold text-stone-800"
>
{{ record.focusedTime }}
</p>
</div>
</div>
<p
@@ -138,6 +286,21 @@ const emit = defineEmits(['update:range-start', 'update:range-end', 'quick-range
선택 기간에 기록이 없습니다.
</p>
</div>
<div
v-if="hoveredFlowRecord"
class="pointer-events-none fixed z-[80] w-44 -translate-x-1/2 -translate-y-full rounded-2xl border border-stone-200 bg-white px-3 py-2 text-left shadow-[0_16px_40px_rgba(28,25,23,0.14)]"
:style="{ left: `${flowTooltipPosition.x}px`, top: `${flowTooltipPosition.y}px` }"
>
<p class="text-[10px] font-bold tracking-[0.16em] text-stone-500">
{{ hoveredFlowRecord.dateLabel }} {{ hoveredFlowRecord.weekday }}
</p>
<p class="mt-1 text-[11px] font-semibold text-stone-900">
FOCUSED {{ hoveredFlowRecord.focusedTime }}
</p>
<p class="mt-1 text-[10px] font-semibold tracking-[0.04em] text-stone-500">
TASKS {{ hoveredFlowRecord.completedTasks }} / {{ hoveredFlowRecord.totalTasks }}
</p>
</div>
</article>
<div class="grid gap-6">
@@ -162,38 +325,44 @@ const emit = defineEmits(['update:range-start', 'update:range-end', 'quick-range
아직 통계를 보여줄 기록이 충분하지 않습니다.
</p>
</article>
<article class="rounded-[28px] border border-stone-200 bg-white/86 p-6">
<div class="flex items-center gap-2">
<p class="text-[11px] font-bold tracking-[0.22em] text-stone-500">RECENT RECORDS</p>
<GuideTooltip
title="Recent Records"
description="선택 범위 안의 기록을 날짜 내림차순으로 최대 5개까지 보여줍니다."
:dismissible="false"
/>
</div>
<div class="mt-4 space-y-4">
<div
v-for="record in recentRecords"
:key="record.key"
class="rounded-2xl border border-stone-200 bg-stone-50/80 p-4"
>
<div class="flex items-start justify-between gap-4">
<div>
<p class="text-[12px] font-bold tracking-[0.08em] text-stone-900">{{ record.dateLabel }}</p>
<p class="mt-2 text-[11px] font-semibold leading-5 text-stone-600">
{{ record.comment || '코멘트 없음' }}
</p>
</div>
<div class="text-right">
<p class="text-sm font-semibold tracking-[-0.03em] text-stone-900">{{ record.focusedTime }}</p>
<p class="mt-1 text-[11px] font-semibold text-stone-500">{{ record.completionRate }}%</p>
</div>
</div>
</div>
</div>
</article>
</div>
</div>
<article class="rounded-[28px] border border-stone-200 bg-white/86 p-6">
<div class="flex items-center gap-2">
<p class="text-[11px] font-bold tracking-[0.22em] text-stone-500">RECENT RECORDS</p>
<GuideTooltip
title="Recent Records"
description="선택 범위 안의 기록을 날짜 내림차순으로 최대 5개까지 보여줍니다."
:dismissible="false"
/>
</div>
<div class="mt-4 grid gap-4 md:grid-cols-2 xl:grid-cols-5">
<div
v-for="record in recentRecords"
:key="record.key"
class="rounded-2xl border border-stone-200 bg-stone-50/80 p-4"
>
<div class="flex h-full flex-col justify-between gap-4">
<div>
<p class="text-[12px] font-bold tracking-[0.08em] text-stone-900">{{ record.dateLabel }}</p>
<p class="mt-2 text-[11px] font-semibold leading-5 text-stone-600">
{{ record.comment || '코멘트 없음' }}
</p>
</div>
<div>
<p class="text-sm font-semibold tracking-[-0.03em] text-stone-900">{{ record.focusedTime }}</p>
<p class="mt-1 text-[11px] font-semibold text-stone-500">완료율 {{ record.completionRate }}%</p>
</div>
</div>
</div>
<p
v-if="recentRecords.length === 0"
class="rounded-2xl border border-dashed border-stone-300 px-4 py-8 text-sm font-semibold text-stone-500"
>
선택 기간에 최근 기록이 없습니다.
</p>
</div>
</article>
</section>
</template>

View File

@@ -107,3 +107,32 @@ export async function updatePassword(token, { currentPassword, newPassword }) {
body: { currentPassword, newPassword },
})
}
export async function deleteAccount(token, { currentPassword }) {
return request('/api/auth/account', {
method: 'DELETE',
token,
body: { currentPassword },
})
}
export async function requestPasswordReset({ email }) {
return request('/api/auth/password-reset/request', {
method: 'POST',
body: { email },
})
}
export async function confirmPasswordReset({ token, newPassword }) {
return request('/api/auth/password-reset/confirm', {
method: 'POST',
body: { token, newPassword },
})
}
export async function confirmVerification({ token }) {
return request('/api/auth/verification/confirm', {
method: 'POST',
body: { token },
})
}

View File

@@ -31,7 +31,7 @@
background: #ffffff !important;
width: auto !important;
height: auto !important;
overflow: hidden !important;
overflow: visible !important;
}
body {
@@ -50,17 +50,11 @@
}
.print-only {
display: flex !important;
display: block !important;
width: 100% !important;
height: 100% !important;
height: auto !important;
margin: 0 !important;
padding: 0 !important;
align-items: center;
justify-content: center;
break-inside: avoid-page;
page-break-inside: avoid;
break-after: avoid-page;
page-break-after: avoid;
}
.print-root {
@@ -79,15 +73,24 @@
justify-content: center;
background: #ffffff !important;
padding: 0;
margin: 0 auto;
overflow: hidden;
break-after: page;
page-break-after: always;
break-inside: avoid-page;
page-break-inside: avoid;
}
.print-paper:last-child {
break-after: avoid-page;
page-break-after: avoid;
}
body[data-print-layout='single'] .print-paper {
width: 204mm;
height: 291mm;
align-items: flex-start;
width: 210mm;
height: 297mm;
align-items: center;
justify-content: center;
padding-top: 3mm;
}
.print-paper--double {
@@ -99,8 +102,8 @@
}
body[data-print-layout='double'] .print-paper {
width: 285mm;
height: 196mm;
width: 297mm;
height: 210mm;
}
body[data-print-layout='single'] .print-paper--single .print-sheet-frame {
@@ -116,6 +119,10 @@
background: #ffffff !important;
}
.print-sheet-frame--blank {
background: #ffffff !important;
}
body[data-print-layout='double'] .print-paper--double .print-sheet-frame {
width: 139mm;
height: 196mm;