Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| fe538fc88b | |||
| 4355185203 |
13
HANDOFF.md
13
HANDOFF.md
@@ -4,7 +4,7 @@
|
||||
|
||||
- 프로젝트명: 10 Minute Planner 웹 UI
|
||||
- 기술 스택: Vue 3 + Vite + TailwindCSS + JavaScript
|
||||
- 현재 기준 버전: `v0.1.16`
|
||||
- 현재 기준 버전: `v0.1.18`
|
||||
- Git 원격 저장소: `https://git.sori.studio/zenn/planner.sori.studio.git`
|
||||
|
||||
## 기준 디자인
|
||||
@@ -31,6 +31,7 @@
|
||||
- 백엔드 엔트리 포인트: `backend/src/server.js`
|
||||
- 백엔드 DB 스키마: `backend/src/db/schema.js`
|
||||
- 백엔드 인증 라우트: `backend/src/routes/auth.js`
|
||||
- 백엔드 목표 라우트: `backend/src/routes/goals.js`
|
||||
- 백엔드 비밀번호/세션 유틸: `backend/src/lib/password.js`
|
||||
- Tailwind 설정은 완료되어 있으며, 이 프로젝트의 스타일링 기준으로 유지한다.
|
||||
- 현재 선택 날짜는 시스템 날짜 기준으로 시작한다.
|
||||
@@ -52,7 +53,9 @@
|
||||
- 프론트는 헤더에서 `LOGIN` / `SIGN UP` 모달을 열 수 있고, 로그인 상태면 닉네임과 `LOGOUT` 버튼을 표시한다.
|
||||
- 인증 토큰과 현재 사용자 정보는 프론트 로컬 저장소에 따로 유지하고, 앱 시작 시 `/api/auth/me`로 세션 복원을 시도한다.
|
||||
- 프론트 플래너 API 클라이언트는 `src/lib/plannerApi.js`에 추가되었다.
|
||||
- 프론트 목표 API 클라이언트는 `src/lib/goalsApi.js`에 추가되었다.
|
||||
- 루트에서 `npm run dev:backend`, `npm run db:generate`, `npm run db:migrate`로 백엔드 명령을 호출할 수 있다.
|
||||
- 화면 탭은 `PLANNER / STATS / GOALS / SETTINGS` 기준으로 확장되었다.
|
||||
- 상단 전환 버튼으로 `PLANNER / STATS` 화면을 오갈 수 있다.
|
||||
- 통계 화면에서는 전체 집중 시간, 평균 완료율, 기록 일수, 최근 7일 흐름, 최근 기록, 베스트 데이를 보여준다.
|
||||
- 통계 화면은 시작일/종료일을 직접 선택해 그 기간 기준으로 지표를 다시 계산할 수 있다.
|
||||
@@ -125,8 +128,12 @@
|
||||
- 현재는 로그인 전 플래너 진입을 막고, 인증 후에만 실제 플래너/통계 화면을 사용하도록 변경했다.
|
||||
- 클라우드 저장 상태는 헤더가 아니라 오른쪽 하단의 작은 토스트 형태로 표시되도록 변경했다.
|
||||
- 저장 완료 토스트는 한 줄짜리의 작은 상태 문구로 줄여서 존재감을 낮췄다.
|
||||
- D-DAY는 본문 직접 입력보다 별도 목표 목록에서 선택한 대표 목표를 보여주는 방식이 적합하다는 방향으로 정리했다.
|
||||
- 목표가 없을 때는 본문 D-DAY를 숨기고, 오른쪽 패널의 `D-DAY 사용` 메뉴에서 목표를 검색/선택하게 하는 UX가 현재 추천안이다.
|
||||
- D-DAY는 플래너 안에서 목표를 고르는 구조가 아니라, GOALS 화면에서 목표와 표시 기간을 먼저 설정하는 구조로 정리했다.
|
||||
- 플래너 화면 오른쪽 패널에서는 현재 날짜에 적용된 목표가 있을 때만 D-DAY 토글을 켤 수 있고, 목표 검색 UI는 제거했다.
|
||||
- 목표는 `active_from`, `active_until` 기간을 가질 수 있고, 현재 날짜가 그 범위에 들어올 때만 플래너 본문 D-DAY 후보가 된다.
|
||||
- TASK LABELS도 별도 버튼 2개 대신 동일한 토글 UI로 단순화했다. ON이면 01~15를 채우고 OFF이면 비운다.
|
||||
- SETTINGS 화면이 추가되어 닉네임, 이메일, 비밀번호 변경을 분리해서 관리할 수 있다.
|
||||
- 백엔드에는 `/api/auth/profile`, `/api/auth/password`, `/api/goals/:goalId` 수정 API가 추가되었다.
|
||||
- 이미지 저장 기능은 추후 `print-only` 또는 별도 export 전용 레이아웃을 기준으로 구현하면 화면/인쇄/공유 결과를 맞추기 쉽다.
|
||||
- Docker Compose는 프론트엔드와 백엔드를 함께 올리는 기준으로 설계하되, NAS 환경에 맞는 볼륨과 재시작 정책도 함께 고려한다.
|
||||
|
||||
|
||||
21
TODO.md
21
TODO.md
@@ -7,7 +7,7 @@
|
||||
- 기본 레이아웃은 `1페이지 + 우측 정보 패널`을 유지한다.
|
||||
- `2페이지 펼침 보기`는 비교용 보조 모드로 유지한다.
|
||||
- 스타일은 Vue + TailwindCSS 기준으로 구현한다.
|
||||
- D-DAY는 목표 관리 패널과 연결되는 기능으로 추후 구현한다.
|
||||
- D-DAY는 목표 관리 패널과 연결하는 구조로 전환했고, 세부 확장은 계속 진행한다.
|
||||
|
||||
## 1단계: 플래너 핵심 상호작용
|
||||
|
||||
@@ -36,12 +36,17 @@
|
||||
|
||||
## 3단계: 목표와 회고 기능
|
||||
|
||||
- [ ] 목표 관리 패널을 설계한다.
|
||||
- [ ] 선택한 목표 기준으로 `D-DAY`가 자동 계산되게 한다.
|
||||
- [x] 목표 관리 패널 기본 구조를 설계한다.
|
||||
- [x] 선택한 목표 기준으로 `D-DAY`가 자동 계산되게 한다.
|
||||
- [ ] 우측 요약 패널의 `PREV SNAPSHOT`, `READ NEXT`를 실제 데이터 기반으로 연결한다.
|
||||
- [ ] 다음날 할 일 자동 제안 규칙을 정리한다.
|
||||
- [ ] 오른쪽 패널에 `D-DAY 사용` 토글과 목표 검색/선택 UI를 추가한다.
|
||||
- [ ] 목표를 여러 개 생성하고 날짜별 대표 목표를 선택할 수 있게 한다.
|
||||
- [x] 오른쪽 패널에 `D-DAY 사용` 토글과 목표 검색/선택 UI를 추가한다.
|
||||
- [x] 목표를 여러 개 생성하고 날짜별 대표 목표를 선택할 수 있게 한다.
|
||||
- [x] 목표 관리 화면을 별도로 분리하고, 플래너에서는 D-DAY 표시 ON/OFF만 제어한다.
|
||||
- [x] 목표별로 D-DAY 표시 시작일과 종료일을 설정할 수 있게 한다.
|
||||
- [ ] 목표 완료 처리와 보관 상태를 구분한다.
|
||||
- [ ] 목표 편집/삭제 UI를 추가한다.
|
||||
- [ ] 목표 목록 정렬 규칙과 검색 UX를 다듬는다.
|
||||
|
||||
## 4단계: 데이터 구조와 저장
|
||||
|
||||
@@ -73,6 +78,7 @@
|
||||
|
||||
- [ ] 회원 가입 / 로그인 방식 후보를 정리한다.
|
||||
- [x] 회원 가입 / 로그인 방식 후보를 정리한다.
|
||||
- [x] 사용자 설정 화면에서 닉네임 / 이메일 / 비밀번호 수정 흐름을 분리한다.
|
||||
- [ ] 사용자별 문서 분리 저장 구조를 설계한다.
|
||||
- [ ] 공유가 아닌 개인 보관용 서비스 흐름으로 요구사항을 정리한다.
|
||||
- [x] 향후 출력 기능을 위한 인쇄 레이아웃 요구사항을 정리한다.
|
||||
@@ -98,7 +104,12 @@
|
||||
- 현재 백엔드는 `backend/` 폴더에 `Fastify + Drizzle + SQLite` 기준 초안이 추가되었다.
|
||||
- 현재 백엔드는 회원가입, 로그인, 현재 사용자 확인용 기본 인증 API까지 포함한다.
|
||||
- 현재 백엔드는 사용자별 플래너 단건 저장/조회와 범위 조회 API까지 포함한다.
|
||||
- 현재 백엔드는 사용자별 목표 목록 조회와 목표 생성 API까지 포함한다.
|
||||
- 프론트에는 로그인/회원가입 모달과 현재 사용자 상태 표시가 추가되었다.
|
||||
- 로그인 상태일 때는 서버 저장을 우선 사용하는 흐름으로 전환 중이다.
|
||||
- 로그인 전에는 플래너 본문을 사용하지 못하도록 막고, 인증 후 사용 흐름으로 정리했다.
|
||||
- 현재는 각 날짜 플래너가 대표 목표 하나를 선택해 `D-DAY`에 연결하는 구조다.
|
||||
- 목표는 별도 GOALS 화면에서 검색/생성/기간 설정을 관리하고, 플래너에서는 표시 ON/OFF만 다룬다.
|
||||
- 목표가 현재 날짜에 적용되지 않았거나 `D-DAY 사용`이 꺼져 있으면 본문 `D-DAY` 영역은 숨긴다.
|
||||
- TASK LABELS는 버튼 묶음 대신 동일한 토글 패턴으로 단순화했다.
|
||||
- 구현할 때마다 완료된 항목은 체크하고, 큰 결정사항은 `HANDOFF.md`에도 함께 반영한다.
|
||||
|
||||
@@ -1,5 +1,14 @@
|
||||
import { sqlite } from './client.js'
|
||||
|
||||
function ensureColumn(tableName, columnName, definition) {
|
||||
const columns = sqlite.prepare(`PRAGMA table_info(${tableName})`).all()
|
||||
const hasColumn = columns.some((column) => column.name === columnName)
|
||||
|
||||
if (!hasColumn) {
|
||||
sqlite.exec(`ALTER TABLE ${tableName} ADD COLUMN ${columnName} ${definition}`)
|
||||
}
|
||||
}
|
||||
|
||||
export function ensureDatabaseSchema() {
|
||||
sqlite.exec(`
|
||||
CREATE TABLE IF NOT EXISTS users (
|
||||
@@ -32,5 +41,23 @@ export function ensureDatabaseSchema() {
|
||||
|
||||
CREATE UNIQUE INDEX IF NOT EXISTS planner_entries_user_date_unique
|
||||
ON planner_entries (user_id, entry_date);
|
||||
|
||||
CREATE TABLE IF NOT EXISTS goals (
|
||||
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
||||
user_id INTEGER NOT NULL,
|
||||
title TEXT NOT NULL,
|
||||
target_date TEXT NOT NULL,
|
||||
active_from TEXT,
|
||||
active_until TEXT,
|
||||
status TEXT NOT NULL DEFAULT 'active',
|
||||
color TEXT NOT NULL DEFAULT '#1c1917',
|
||||
created_at INTEGER NOT NULL,
|
||||
updated_at INTEGER NOT NULL,
|
||||
completed_at INTEGER,
|
||||
FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE
|
||||
);
|
||||
`)
|
||||
|
||||
ensureColumn('goals', 'active_from', 'TEXT')
|
||||
ensureColumn('goals', 'active_until', 'TEXT')
|
||||
}
|
||||
|
||||
@@ -31,3 +31,17 @@ export const plannerEntries = sqliteTable(
|
||||
userDateUnique: uniqueIndex('planner_entries_user_date_unique').on(table.userId, table.entryDate),
|
||||
}),
|
||||
)
|
||||
|
||||
export const goals = sqliteTable('goals', {
|
||||
id: integer('id').primaryKey({ autoIncrement: true }),
|
||||
userId: integer('user_id').notNull().references(() => users.id, { onDelete: 'cascade' }),
|
||||
title: text('title').notNull(),
|
||||
targetDate: text('target_date').notNull(),
|
||||
activeFrom: text('active_from'),
|
||||
activeUntil: text('active_until'),
|
||||
status: text('status').notNull().default('active'),
|
||||
color: text('color').notNull().default('#1c1917'),
|
||||
createdAt: integer('created_at', { mode: 'timestamp_ms' }).notNull(),
|
||||
updatedAt: integer('updated_at', { mode: 'timestamp_ms' }).notNull(),
|
||||
completedAt: integer('completed_at', { mode: 'timestamp_ms' }),
|
||||
})
|
||||
|
||||
@@ -16,6 +16,16 @@ const loginSchema = z.object({
|
||||
password: z.string().min(1).max(72),
|
||||
})
|
||||
|
||||
const profileSchema = z.object({
|
||||
email: z.string().trim().email(),
|
||||
nickname: z.string().trim().min(2).max(30),
|
||||
})
|
||||
|
||||
const passwordSchema = z.object({
|
||||
currentPassword: z.string().min(1).max(72),
|
||||
newPassword: z.string().min(8).max(72),
|
||||
})
|
||||
|
||||
function sanitizeUser(user) {
|
||||
return {
|
||||
id: user.id,
|
||||
@@ -129,4 +139,93 @@ export async function registerAuthRoutes(app) {
|
||||
user: sanitizeUser(user),
|
||||
}
|
||||
})
|
||||
|
||||
app.put('/api/auth/profile', async (request, reply) => {
|
||||
const user = await findAuthenticatedUser(request)
|
||||
|
||||
if (!user) {
|
||||
return reply.code(401).send({
|
||||
message: '인증이 필요합니다.',
|
||||
})
|
||||
}
|
||||
|
||||
const payload = profileSchema.safeParse(request.body)
|
||||
|
||||
if (!payload.success) {
|
||||
return reply.code(400).send({
|
||||
message: '프로필 입력값이 올바르지 않습니다.',
|
||||
issues: payload.error.flatten(),
|
||||
})
|
||||
}
|
||||
|
||||
const normalizedEmail = payload.data.email.toLowerCase()
|
||||
|
||||
const [existingUser] = await db
|
||||
.select()
|
||||
.from(users)
|
||||
.where(eq(users.email, normalizedEmail))
|
||||
.limit(1)
|
||||
|
||||
if (existingUser && existingUser.id !== user.id) {
|
||||
return reply.code(409).send({
|
||||
message: '이미 사용 중인 이메일입니다.',
|
||||
})
|
||||
}
|
||||
|
||||
const [updatedUser] = await db
|
||||
.update(users)
|
||||
.set({
|
||||
email: normalizedEmail,
|
||||
nickname: payload.data.nickname,
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
.where(eq(users.id, user.id))
|
||||
.returning()
|
||||
|
||||
return {
|
||||
message: '프로필이 수정되었습니다.',
|
||||
user: sanitizeUser(updatedUser),
|
||||
}
|
||||
})
|
||||
|
||||
app.put('/api/auth/password', async (request, reply) => {
|
||||
const user = await findAuthenticatedUser(request)
|
||||
|
||||
if (!user) {
|
||||
return reply.code(401).send({
|
||||
message: '인증이 필요합니다.',
|
||||
})
|
||||
}
|
||||
|
||||
const payload = passwordSchema.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: '현재 비밀번호가 올바르지 않습니다.',
|
||||
})
|
||||
}
|
||||
|
||||
const passwordHash = await hashPassword(payload.data.newPassword)
|
||||
|
||||
await db
|
||||
.update(users)
|
||||
.set({
|
||||
passwordHash,
|
||||
updatedAt: new Date(),
|
||||
})
|
||||
.where(eq(users.id, user.id))
|
||||
|
||||
return {
|
||||
message: '비밀번호가 변경되었습니다.',
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
204
backend/src/routes/goals.js
Normal file
204
backend/src/routes/goals.js
Normal file
@@ -0,0 +1,204 @@
|
||||
import { and, asc, desc, eq, like } from 'drizzle-orm'
|
||||
import { z } from 'zod'
|
||||
import { db } from '../db/client.js'
|
||||
import { goals } from '../db/schema.js'
|
||||
import { findAuthenticatedUser } from '../lib/authSession.js'
|
||||
|
||||
const goalSchema = z.object({
|
||||
title: z.string().trim().min(1).max(80),
|
||||
targetDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/),
|
||||
activeFrom: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional().nullable(),
|
||||
activeUntil: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional().nullable(),
|
||||
status: z.enum(['active', 'done', 'archived']).optional(),
|
||||
color: z.string().trim().min(4).max(32).optional(),
|
||||
})
|
||||
|
||||
const goalUpdateSchema = z.object({
|
||||
title: z.string().trim().min(1).max(80).optional(),
|
||||
targetDate: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional(),
|
||||
activeFrom: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional().nullable(),
|
||||
activeUntil: z.string().regex(/^\d{4}-\d{2}-\d{2}$/).optional().nullable(),
|
||||
status: z.enum(['active', 'done', 'archived']).optional(),
|
||||
color: z.string().trim().min(4).max(32).optional(),
|
||||
})
|
||||
|
||||
const goalQuerySchema = z.object({
|
||||
query: z.string().trim().optional(),
|
||||
status: z.enum(['active', 'done', 'archived', 'all']).optional(),
|
||||
})
|
||||
|
||||
async function requireAuthenticatedUser(request, reply) {
|
||||
const user = await findAuthenticatedUser(request)
|
||||
|
||||
if (!user) {
|
||||
reply.code(401).send({
|
||||
message: '인증이 필요합니다.',
|
||||
})
|
||||
return null
|
||||
}
|
||||
|
||||
return user
|
||||
}
|
||||
|
||||
export async function registerGoalRoutes(app) {
|
||||
app.get('/api/goals', async (request, reply) => {
|
||||
const user = await requireAuthenticatedUser(request, reply)
|
||||
|
||||
if (!user) {
|
||||
return
|
||||
}
|
||||
|
||||
const query = goalQuerySchema.safeParse(request.query ?? {})
|
||||
|
||||
if (!query.success) {
|
||||
return reply.code(400).send({
|
||||
message: '목표 조회 조건이 올바르지 않습니다.',
|
||||
issues: query.error.flatten(),
|
||||
})
|
||||
}
|
||||
|
||||
const filters = [eq(goals.userId, user.id)]
|
||||
|
||||
if (query.data.status && query.data.status !== 'all') {
|
||||
filters.push(eq(goals.status, query.data.status))
|
||||
}
|
||||
|
||||
if (query.data.query) {
|
||||
filters.push(like(goals.title, `%${query.data.query}%`))
|
||||
}
|
||||
|
||||
const items = await db
|
||||
.select()
|
||||
.from(goals)
|
||||
.where(and(...filters))
|
||||
.orderBy(desc(goals.updatedAt), asc(goals.targetDate), asc(goals.id))
|
||||
|
||||
return { goals: items }
|
||||
})
|
||||
|
||||
app.post('/api/goals', async (request, reply) => {
|
||||
const user = await requireAuthenticatedUser(request, reply)
|
||||
|
||||
if (!user) {
|
||||
return
|
||||
}
|
||||
|
||||
const payload = goalSchema.safeParse(request.body)
|
||||
|
||||
if (!payload.success) {
|
||||
return reply.code(400).send({
|
||||
message: '목표 입력값이 올바르지 않습니다.',
|
||||
issues: payload.error.flatten(),
|
||||
})
|
||||
}
|
||||
|
||||
const now = new Date()
|
||||
|
||||
const [goal] = await db
|
||||
.insert(goals)
|
||||
.values({
|
||||
userId: user.id,
|
||||
title: payload.data.title,
|
||||
targetDate: payload.data.targetDate,
|
||||
activeFrom: payload.data.activeFrom ?? null,
|
||||
activeUntil: payload.data.activeUntil ?? null,
|
||||
color: payload.data.color ?? '#1c1917',
|
||||
status: payload.data.status ?? 'active',
|
||||
createdAt: now,
|
||||
updatedAt: now,
|
||||
completedAt: payload.data.status === 'done' ? now : null,
|
||||
})
|
||||
.returning()
|
||||
|
||||
return reply.code(201).send({
|
||||
message: '목표가 추가되었습니다.',
|
||||
goal,
|
||||
})
|
||||
})
|
||||
|
||||
app.patch('/api/goals/:goalId', async (request, reply) => {
|
||||
const user = await requireAuthenticatedUser(request, reply)
|
||||
|
||||
if (!user) {
|
||||
return
|
||||
}
|
||||
|
||||
const params = z.object({
|
||||
goalId: z.coerce.number().int().positive(),
|
||||
}).safeParse(request.params)
|
||||
|
||||
if (!params.success) {
|
||||
return reply.code(400).send({
|
||||
message: '목표 식별자가 올바르지 않습니다.',
|
||||
})
|
||||
}
|
||||
|
||||
const payload = goalUpdateSchema.safeParse(request.body)
|
||||
|
||||
if (!payload.success) {
|
||||
return reply.code(400).send({
|
||||
message: '목표 수정값이 올바르지 않습니다.',
|
||||
issues: payload.error.flatten(),
|
||||
})
|
||||
}
|
||||
|
||||
const [existingGoal] = await db
|
||||
.select()
|
||||
.from(goals)
|
||||
.where(and(eq(goals.id, params.data.goalId), eq(goals.userId, user.id)))
|
||||
.limit(1)
|
||||
|
||||
if (!existingGoal) {
|
||||
return reply.code(404).send({
|
||||
message: '목표를 찾을 수 없습니다.',
|
||||
})
|
||||
}
|
||||
|
||||
const nextValues = {
|
||||
updatedAt: new Date(),
|
||||
}
|
||||
|
||||
if (payload.data.title !== undefined) {
|
||||
nextValues.title = payload.data.title
|
||||
}
|
||||
|
||||
if (payload.data.targetDate !== undefined) {
|
||||
nextValues.targetDate = payload.data.targetDate
|
||||
}
|
||||
|
||||
if (payload.data.activeFrom !== undefined) {
|
||||
nextValues.activeFrom = payload.data.activeFrom
|
||||
}
|
||||
|
||||
if (payload.data.activeUntil !== undefined) {
|
||||
nextValues.activeUntil = payload.data.activeUntil
|
||||
}
|
||||
|
||||
if (payload.data.status !== undefined) {
|
||||
nextValues.status = payload.data.status
|
||||
}
|
||||
|
||||
if (payload.data.color !== undefined) {
|
||||
nextValues.color = payload.data.color
|
||||
}
|
||||
|
||||
if (payload.data.status === 'done' && !existingGoal.completedAt) {
|
||||
nextValues.completedAt = new Date()
|
||||
}
|
||||
|
||||
if (payload.data.status && payload.data.status !== 'done') {
|
||||
nextValues.completedAt = null
|
||||
}
|
||||
|
||||
const [goal] = await db
|
||||
.update(goals)
|
||||
.set(nextValues)
|
||||
.where(and(eq(goals.id, params.data.goalId), eq(goals.userId, user.id)))
|
||||
.returning()
|
||||
|
||||
return {
|
||||
message: '목표가 수정되었습니다.',
|
||||
goal,
|
||||
}
|
||||
})
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import { env } from './config.js'
|
||||
import { sqlite } from './db/client.js'
|
||||
import { ensureDatabaseSchema } from './db/init.js'
|
||||
import { registerAuthRoutes } from './routes/auth.js'
|
||||
import { registerGoalRoutes } from './routes/goals.js'
|
||||
import { registerPlannerRoutes } from './routes/planner.js'
|
||||
|
||||
const app = Fastify({
|
||||
@@ -18,6 +19,7 @@ await app.register(cors, {
|
||||
})
|
||||
|
||||
await registerAuthRoutes(app)
|
||||
await registerGoalRoutes(app)
|
||||
await registerPlannerRoutes(app)
|
||||
|
||||
app.get('/health', async () => {
|
||||
@@ -39,6 +41,7 @@ app.get('/api/meta', async () => ({
|
||||
orm: 'drizzle',
|
||||
notes: [
|
||||
'회원가입, 로그인, 현재 사용자 확인 API가 준비되어 있습니다.',
|
||||
'사용자별 목표 목록과 생성 API가 준비되어 있습니다.',
|
||||
'사용자별 플래너 저장 및 조회 API가 준비되어 있습니다.',
|
||||
],
|
||||
}))
|
||||
|
||||
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
||||
{
|
||||
"name": "ten-minute-planner",
|
||||
"version": "0.1.16",
|
||||
"version": "0.1.18",
|
||||
"lockfileVersion": 3,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "ten-minute-planner",
|
||||
"version": "0.1.16",
|
||||
"version": "0.1.18",
|
||||
"dependencies": {
|
||||
"vue": "^3.5.13"
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"name": "ten-minute-planner",
|
||||
"private": true,
|
||||
"version": "0.1.16",
|
||||
"version": "0.1.18",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite",
|
||||
|
||||
586
src/App.vue
586
src/App.vue
@@ -1,8 +1,10 @@
|
||||
<script setup>
|
||||
import { computed, onMounted, reactive, ref, watch, nextTick } from 'vue'
|
||||
import AuthDialog from './components/AuthDialog.vue'
|
||||
import GoalsDashboard from './components/GoalsDashboard.vue'
|
||||
import MiniCalendar from './components/MiniCalendar.vue'
|
||||
import PlannerPage from './components/PlannerPage.vue'
|
||||
import SettingsDashboard from './components/SettingsDashboard.vue'
|
||||
import StatsDashboard from './components/StatsDashboard.vue'
|
||||
import {
|
||||
clearAuthState,
|
||||
@@ -11,7 +13,10 @@ import {
|
||||
persistAuthState,
|
||||
readAuthState,
|
||||
signup,
|
||||
updatePassword,
|
||||
updateProfile,
|
||||
} from './lib/authClient'
|
||||
import { createGoal, fetchGoals, updateGoal } from './lib/goalsApi'
|
||||
import { deletePlannerEntry, fetchPlannerEntries, savePlannerEntry } from './lib/plannerApi'
|
||||
import {
|
||||
createInitialPlannerRecords,
|
||||
@@ -29,6 +34,12 @@ const authBusy = ref(false)
|
||||
const authMessage = ref('')
|
||||
const authToken = ref('')
|
||||
const currentUser = ref(null)
|
||||
const goals = ref([])
|
||||
const goalQuery = ref('')
|
||||
const goalStatusFilter = ref('all')
|
||||
const goalBusy = ref(false)
|
||||
const goalMessage = ref('')
|
||||
const editingGoalId = ref(null)
|
||||
const syncStatus = ref('local')
|
||||
const syncMessage = ref('')
|
||||
const syncToastVisible = ref(false)
|
||||
@@ -41,6 +52,26 @@ const authForm = reactive({
|
||||
email: '',
|
||||
password: '',
|
||||
})
|
||||
const goalForm = reactive({
|
||||
title: '',
|
||||
targetDate: '',
|
||||
activeFrom: '',
|
||||
activeUntil: '',
|
||||
status: 'active',
|
||||
})
|
||||
const profileForm = reactive({
|
||||
nickname: '',
|
||||
email: '',
|
||||
})
|
||||
const passwordForm = reactive({
|
||||
currentPassword: '',
|
||||
newPassword: '',
|
||||
confirmPassword: '',
|
||||
})
|
||||
const profileBusy = ref(false)
|
||||
const passwordBusy = ref(false)
|
||||
const profileMessage = ref('')
|
||||
const passwordMessage = ref('')
|
||||
|
||||
const hours = [
|
||||
'6', '7', '8', '9', '10', '11', '12',
|
||||
@@ -178,8 +209,9 @@ function startOfDay(date) {
|
||||
|
||||
function buildFallbackRecord(date) {
|
||||
return {
|
||||
dday: 'D-00 FOCUS',
|
||||
comment: '',
|
||||
goalEnabled: false,
|
||||
selectedGoalId: null,
|
||||
tasks: Array.from({ length: 15 }, (_, index) => ({
|
||||
label: '',
|
||||
title: '',
|
||||
@@ -198,6 +230,8 @@ function buildFallbackRecord(date) {
|
||||
function normalizeRecord(record) {
|
||||
return {
|
||||
...record,
|
||||
goalEnabled: Boolean(record.goalEnabled),
|
||||
selectedGoalId: record.selectedGoalId ?? null,
|
||||
tasks: record.tasks.map((task, index) => ({
|
||||
label: task.label ?? task.id ?? '',
|
||||
title: task.title ?? '',
|
||||
@@ -300,6 +334,54 @@ const markedDateKeys = computed(() =>
|
||||
)
|
||||
|
||||
const isAuthenticated = computed(() => Boolean(authToken.value && currentUser.value))
|
||||
const filteredGoals = computed(() => {
|
||||
const query = goalQuery.value.trim().toLowerCase()
|
||||
return goals.value.filter((goal) => {
|
||||
if (goalStatusFilter.value !== 'all' && goal.status !== goalStatusFilter.value) {
|
||||
return false
|
||||
}
|
||||
|
||||
if (!query) {
|
||||
return true
|
||||
}
|
||||
|
||||
return goal.title.toLowerCase().includes(query)
|
||||
})
|
||||
})
|
||||
const activePlannerGoals = computed(() =>
|
||||
goals.value
|
||||
.filter((goal) => {
|
||||
if (goal.status !== 'active' || !goal.activeFrom || !goal.activeUntil) {
|
||||
return false
|
||||
}
|
||||
|
||||
const selectedKey = toKey(selectedDate.value)
|
||||
return selectedKey >= goal.activeFrom && selectedKey <= goal.activeUntil
|
||||
})
|
||||
.sort((left, right) => {
|
||||
const leftDistance = Math.abs(startOfDay(toDateValue(left.targetDate)).getTime() - startOfDay(selectedDate.value).getTime())
|
||||
const rightDistance = Math.abs(startOfDay(toDateValue(right.targetDate)).getTime() - startOfDay(selectedDate.value).getTime())
|
||||
return leftDistance - rightDistance
|
||||
}),
|
||||
)
|
||||
const plannerGoal = computed(() => activePlannerGoals.value[0] ?? null)
|
||||
const plannerDday = computed(() => {
|
||||
if (!planner.value.goalEnabled || !plannerGoal.value) {
|
||||
return ''
|
||||
}
|
||||
|
||||
const targetDate = startOfDay(toDateValue(plannerGoal.value.targetDate))
|
||||
const currentDate = startOfDay(selectedDate.value)
|
||||
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} ${plannerGoal.value.title}`
|
||||
})
|
||||
const showPlannerDday = computed(() =>
|
||||
planner.value.goalEnabled && Boolean(plannerGoal.value),
|
||||
)
|
||||
const hasActiveGoalForSelectedDate = computed(() => Boolean(plannerGoal.value))
|
||||
|
||||
const filledTasks = computed(() =>
|
||||
planner.value.tasks.filter((task) => task.title.trim()),
|
||||
@@ -368,6 +450,15 @@ function updateComment(record, value) {
|
||||
schedulePlannerSyncForRecord(record)
|
||||
}
|
||||
|
||||
function updateGoalEnabled(record, value) {
|
||||
if (value && !hasActiveGoalForSelectedDate.value) {
|
||||
return
|
||||
}
|
||||
|
||||
record.goalEnabled = value
|
||||
schedulePlannerSyncForRecord(record)
|
||||
}
|
||||
|
||||
function updateTaskLabel(record, { index, value }) {
|
||||
record.tasks[index].label = value
|
||||
schedulePlannerSyncForRecord(record)
|
||||
@@ -566,10 +657,21 @@ watch(
|
||||
{ deep: true },
|
||||
)
|
||||
|
||||
watch(
|
||||
[selectedDate, plannerGoal],
|
||||
() => {
|
||||
if (!plannerGoal.value && planner.value.goalEnabled) {
|
||||
planner.value.goalEnabled = false
|
||||
schedulePlannerSyncForRecord(planner.value)
|
||||
}
|
||||
},
|
||||
)
|
||||
|
||||
function fillTaskLabelsWithNumbers(record) {
|
||||
record.tasks.forEach((task, index) => {
|
||||
task.label = createTaskLabel(index)
|
||||
})
|
||||
schedulePlannerSyncForRecord(record)
|
||||
}
|
||||
|
||||
function clearTaskLabels(record) {
|
||||
@@ -579,6 +681,10 @@ function clearTaskLabels(record) {
|
||||
schedulePlannerSyncForRecord(record)
|
||||
}
|
||||
|
||||
function areTaskLabelsNumbered(record) {
|
||||
return record.tasks.every((task, index) => task.label === createTaskLabel(index))
|
||||
}
|
||||
|
||||
function setSyncFeedback(status, message, options = {}) {
|
||||
const {
|
||||
visible = true,
|
||||
@@ -609,6 +715,26 @@ function resetAuthForm() {
|
||||
authForm.password = ''
|
||||
}
|
||||
|
||||
function resetGoalForm() {
|
||||
goalForm.title = ''
|
||||
goalForm.targetDate = ''
|
||||
goalForm.activeFrom = ''
|
||||
goalForm.activeUntil = ''
|
||||
goalForm.status = 'active'
|
||||
editingGoalId.value = null
|
||||
}
|
||||
|
||||
function syncProfileForm() {
|
||||
profileForm.nickname = currentUser.value?.nickname ?? ''
|
||||
profileForm.email = currentUser.value?.email ?? ''
|
||||
}
|
||||
|
||||
function resetPasswordForm() {
|
||||
passwordForm.currentPassword = ''
|
||||
passwordForm.newPassword = ''
|
||||
passwordForm.confirmPassword = ''
|
||||
}
|
||||
|
||||
function openAuthDialog(mode = 'login') {
|
||||
authMode.value = mode
|
||||
authMessage.value = ''
|
||||
@@ -633,7 +759,9 @@ async function applyAuthSuccess(data) {
|
||||
token: data.token,
|
||||
user: data.user,
|
||||
})
|
||||
await loadGoals()
|
||||
await hydratePlannerRecordsFromApi()
|
||||
syncProfileForm()
|
||||
closeAuthDialog()
|
||||
}
|
||||
|
||||
@@ -680,7 +808,9 @@ async function restoreAuthSession() {
|
||||
token: savedAuth.token,
|
||||
user: result.user,
|
||||
})
|
||||
await loadGoals()
|
||||
await hydratePlannerRecordsFromApi()
|
||||
syncProfileForm()
|
||||
} catch (error) {
|
||||
authToken.value = ''
|
||||
currentUser.value = null
|
||||
@@ -695,11 +825,193 @@ function logout() {
|
||||
clearPendingSyncTimers()
|
||||
authToken.value = ''
|
||||
currentUser.value = null
|
||||
goals.value = []
|
||||
goalQuery.value = ''
|
||||
goalMessage.value = ''
|
||||
goalStatusFilter.value = 'all'
|
||||
setSyncFeedback('local', '로그인 후 클라우드 저장을 사용할 수 있습니다.', {
|
||||
visible: false,
|
||||
})
|
||||
clearAuthState()
|
||||
restoreLocalPlannerRecords()
|
||||
resetGoalForm()
|
||||
resetPasswordForm()
|
||||
}
|
||||
|
||||
async function loadGoals() {
|
||||
if (!authToken.value) {
|
||||
return
|
||||
}
|
||||
|
||||
goalBusy.value = true
|
||||
|
||||
try {
|
||||
const result = await fetchGoals(authToken.value, {
|
||||
status: 'all',
|
||||
})
|
||||
|
||||
goals.value = result.goals
|
||||
goalMessage.value = ''
|
||||
} catch (error) {
|
||||
goalMessage.value = error.message || '목표를 불러오지 못했습니다.'
|
||||
} finally {
|
||||
goalBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function submitGoal() {
|
||||
if (!goalForm.title.trim() || !goalForm.targetDate) {
|
||||
goalMessage.value = '목표 이름과 목표일을 입력해 주세요.'
|
||||
return
|
||||
}
|
||||
|
||||
if ((goalForm.activeFrom && !goalForm.activeUntil) || (!goalForm.activeFrom && goalForm.activeUntil)) {
|
||||
goalMessage.value = '표시 시작일과 종료일은 함께 입력해 주세요.'
|
||||
return
|
||||
}
|
||||
|
||||
if (goalForm.activeFrom && goalForm.activeUntil && goalForm.activeFrom > goalForm.activeUntil) {
|
||||
goalMessage.value = '표시 종료일은 시작일보다 빠를 수 없습니다.'
|
||||
return
|
||||
}
|
||||
|
||||
goalBusy.value = true
|
||||
goalMessage.value = ''
|
||||
|
||||
try {
|
||||
const result = await createGoal(authToken.value, {
|
||||
title: goalForm.title.trim(),
|
||||
targetDate: goalForm.targetDate,
|
||||
activeFrom: goalForm.activeFrom || null,
|
||||
activeUntil: goalForm.activeUntil || null,
|
||||
status: goalForm.status,
|
||||
})
|
||||
|
||||
await loadGoals()
|
||||
resetGoalForm()
|
||||
goalQuery.value = ''
|
||||
goalMessage.value = result.message || '목표가 추가되었습니다.'
|
||||
} catch (error) {
|
||||
goalMessage.value = error.message || '목표를 추가하지 못했습니다.'
|
||||
} finally {
|
||||
goalBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function updateGoalFormField({ field, value }) {
|
||||
goalForm[field] = value
|
||||
}
|
||||
|
||||
function startGoalEdit(goal) {
|
||||
editingGoalId.value = goal.id
|
||||
goalForm.title = goal.title ?? ''
|
||||
goalForm.targetDate = goal.targetDate ?? ''
|
||||
goalForm.activeFrom = goal.activeFrom ?? ''
|
||||
goalForm.activeUntil = goal.activeUntil ?? ''
|
||||
goalForm.status = goal.status ?? 'active'
|
||||
goalMessage.value = ''
|
||||
}
|
||||
|
||||
async function saveGoalEdit() {
|
||||
if (!editingGoalId.value) {
|
||||
return
|
||||
}
|
||||
|
||||
if (!goalForm.title.trim() || !goalForm.targetDate) {
|
||||
goalMessage.value = '목표 이름과 목표일을 입력해 주세요.'
|
||||
return
|
||||
}
|
||||
|
||||
if ((goalForm.activeFrom && !goalForm.activeUntil) || (!goalForm.activeFrom && goalForm.activeUntil)) {
|
||||
goalMessage.value = '표시 시작일과 종료일은 함께 입력해 주세요.'
|
||||
return
|
||||
}
|
||||
|
||||
if (goalForm.activeFrom && goalForm.activeUntil && goalForm.activeFrom > goalForm.activeUntil) {
|
||||
goalMessage.value = '표시 종료일은 시작일보다 빠를 수 없습니다.'
|
||||
return
|
||||
}
|
||||
|
||||
goalBusy.value = true
|
||||
goalMessage.value = ''
|
||||
|
||||
try {
|
||||
const result = await updateGoal(authToken.value, editingGoalId.value, {
|
||||
title: goalForm.title.trim(),
|
||||
targetDate: goalForm.targetDate,
|
||||
activeFrom: goalForm.activeFrom || null,
|
||||
activeUntil: goalForm.activeUntil || null,
|
||||
status: goalForm.status,
|
||||
})
|
||||
|
||||
await loadGoals()
|
||||
resetGoalForm()
|
||||
goalMessage.value = result.message || '목표가 수정되었습니다.'
|
||||
} catch (error) {
|
||||
goalMessage.value = error.message || '목표를 수정하지 못했습니다.'
|
||||
} finally {
|
||||
goalBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function updateProfileField({ field, value }) {
|
||||
profileForm[field] = value
|
||||
}
|
||||
|
||||
function updatePasswordField({ field, value }) {
|
||||
passwordForm[field] = value
|
||||
}
|
||||
|
||||
async function submitProfileForm() {
|
||||
profileBusy.value = true
|
||||
profileMessage.value = ''
|
||||
|
||||
try {
|
||||
const result = await updateProfile(authToken.value, {
|
||||
nickname: profileForm.nickname,
|
||||
email: profileForm.email,
|
||||
})
|
||||
|
||||
currentUser.value = result.user
|
||||
persistAuthState({
|
||||
token: authToken.value,
|
||||
user: result.user,
|
||||
})
|
||||
syncProfileForm()
|
||||
profileMessage.value = '프로필이 저장되었습니다.'
|
||||
} catch (error) {
|
||||
profileMessage.value = error.message || '프로필을 저장하지 못했습니다.'
|
||||
} finally {
|
||||
profileBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function submitPasswordForm() {
|
||||
if (!passwordForm.currentPassword || !passwordForm.newPassword || !passwordForm.confirmPassword) {
|
||||
passwordMessage.value = '모든 비밀번호 항목을 입력해 주세요.'
|
||||
return
|
||||
}
|
||||
|
||||
if (passwordForm.newPassword !== passwordForm.confirmPassword) {
|
||||
passwordMessage.value = '새 비밀번호 확인이 일치하지 않습니다.'
|
||||
return
|
||||
}
|
||||
|
||||
passwordBusy.value = true
|
||||
passwordMessage.value = ''
|
||||
|
||||
try {
|
||||
await updatePassword(authToken.value, {
|
||||
currentPassword: passwordForm.currentPassword,
|
||||
newPassword: passwordForm.newPassword,
|
||||
})
|
||||
resetPasswordForm()
|
||||
passwordMessage.value = '비밀번호가 변경되었습니다.'
|
||||
} catch (error) {
|
||||
passwordMessage.value = error.message || '비밀번호를 변경하지 못했습니다.'
|
||||
} finally {
|
||||
passwordBusy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
function replacePlannerRecords(nextRecords) {
|
||||
@@ -869,136 +1181,159 @@ onMounted(() => {
|
||||
|
||||
<template>
|
||||
<main class="min-h-screen px-4 py-6 text-ink sm:px-6 lg:px-10">
|
||||
<div class="print-root mx-auto flex max-w-[1680px] flex-col gap-6">
|
||||
<header class="print-hidden flex flex-col gap-4 rounded-[28px] border border-white/60 bg-white/70 p-5 backdrop-blur sm:p-6">
|
||||
<div class="flex flex-col gap-3 lg:flex-row lg:items-end lg:justify-between">
|
||||
<div class="print-root mx-auto flex max-w-[1760px] flex-col gap-6 xl:grid xl:grid-cols-[280px_minmax(0,1fr)] xl:items-start">
|
||||
<aside class="print-hidden rounded-[28px] border border-white/60 bg-white/70 p-5 backdrop-blur sm:p-6 xl:sticky xl:top-6">
|
||||
<div class="space-y-6">
|
||||
<div class="space-y-2">
|
||||
<p class="text-[11px] font-bold uppercase tracking-[0.28em] text-stone-500">10 Minute Planner</p>
|
||||
<h1 class="text-2xl font-semibold tracking-[-0.04em] text-stone-900 sm:text-4xl">
|
||||
다이어리처럼 보이되, 앱답게 빠르게 이동하는 플래너
|
||||
<h1 class="text-2xl font-semibold tracking-[-0.04em] text-stone-900">
|
||||
다이어리처럼 보이되,<br>앱답게 빠르게 이동하는 플래너
|
||||
</h1>
|
||||
<p class="max-w-3xl text-sm font-medium leading-6 text-stone-600">
|
||||
기본 모드는 Figma의 1페이지 + 보조 정보 패널 구성을 따르고, 비교용으로 2페이지 펼침 보기도 함께 제공합니다.
|
||||
<p class="text-sm font-medium leading-6 text-stone-600">
|
||||
A5 본문을 최대한 넓게 쓰기 위해 상단 헤더 대신 왼쪽 사이드 내비게이션 구조로 정리했습니다.
|
||||
</p>
|
||||
</div>
|
||||
<div class="flex flex-wrap items-center gap-3">
|
||||
<div class="inline-flex items-center gap-2 rounded-full border border-stone-200 bg-white px-2 py-2">
|
||||
<template v-if="isAuthenticated">
|
||||
<div class="px-2">
|
||||
<p class="text-[10px] font-bold tracking-[0.16em] text-stone-500">SIGNED IN</p>
|
||||
<p class="text-sm font-semibold tracking-[0.02em] text-stone-900">
|
||||
{{ currentUser.nickname }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<section class="rounded-[24px] border border-stone-200 bg-white/80 p-4">
|
||||
<template v-if="isAuthenticated">
|
||||
<p class="text-[10px] font-bold tracking-[0.16em] text-stone-500">SIGNED IN</p>
|
||||
<p class="mt-2 text-lg font-semibold tracking-[-0.03em] text-stone-900">{{ currentUser.nickname }}</p>
|
||||
<p class="mt-1 text-sm font-semibold text-stone-500">{{ currentUser.email }}</p>
|
||||
<button
|
||||
type="button"
|
||||
class="mt-4 w-full rounded-full border border-stone-200 px-4 py-3 text-xs font-bold tracking-[0.16em] text-stone-600 transition hover:border-stone-400 hover:text-ink"
|
||||
@click="logout"
|
||||
>
|
||||
LOGOUT
|
||||
</button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<p class="text-[10px] font-bold tracking-[0.16em] text-stone-500">ACCOUNT</p>
|
||||
<p class="mt-2 text-sm font-semibold leading-6 text-stone-700">
|
||||
로그인 후 문서, 통계, 목표 관리가 모두 계정 기준으로 연결됩니다.
|
||||
</p>
|
||||
<div class="mt-4 grid gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full border border-stone-200 px-3 py-2 text-xs font-bold tracking-[0.14em] text-stone-600 transition hover:border-stone-400 hover:text-ink"
|
||||
@click="logout"
|
||||
>
|
||||
LOGOUT
|
||||
</button>
|
||||
</template>
|
||||
<template v-else>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full border border-stone-200 px-3 py-2 text-xs font-bold tracking-[0.14em] text-stone-600 transition hover:border-stone-400 hover:text-ink"
|
||||
class="w-full rounded-full border border-stone-200 px-4 py-3 text-xs font-bold tracking-[0.16em] text-stone-600 transition hover:border-stone-400 hover:text-ink"
|
||||
@click="openAuthDialog('login')"
|
||||
>
|
||||
LOGIN
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full border border-stone-900 bg-stone-900 px-3 py-2 text-xs font-bold tracking-[0.14em] text-white transition hover:bg-stone-700"
|
||||
class="w-full rounded-full border border-stone-900 bg-stone-900 px-4 py-3 text-xs font-bold tracking-[0.16em] text-white transition hover:bg-stone-700"
|
||||
@click="openAuthDialog('signup')"
|
||||
>
|
||||
SIGN UP
|
||||
</button>
|
||||
</template>
|
||||
</div>
|
||||
<div
|
||||
v-if="isAuthenticated"
|
||||
class="inline-flex rounded-full border border-stone-200 bg-stone-100 p-1"
|
||||
>
|
||||
</div>
|
||||
</template>
|
||||
</section>
|
||||
|
||||
<section v-if="isAuthenticated" class="rounded-[24px] border border-stone-200 bg-white/80 p-4">
|
||||
<p class="text-[10px] font-bold tracking-[0.16em] text-stone-500">NAVIGATION</p>
|
||||
<div class="mt-4 grid grid-cols-2 gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full px-4 py-2 text-xs font-bold tracking-[0.14em] transition"
|
||||
:class="screenMode === 'planner' ? 'bg-white text-ink shadow-sm' : 'text-stone-500'"
|
||||
class="rounded-2xl px-3 py-3 text-xs font-bold tracking-[0.14em] transition"
|
||||
:class="screenMode === 'planner' ? 'bg-stone-900 text-white' : 'bg-stone-100 text-stone-500'"
|
||||
@click="screenMode = 'planner'"
|
||||
>
|
||||
PLANNER
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full px-4 py-2 text-xs font-bold tracking-[0.14em] transition"
|
||||
:class="screenMode === 'stats' ? 'bg-white text-ink shadow-sm' : 'text-stone-500'"
|
||||
class="rounded-2xl px-3 py-3 text-xs font-bold tracking-[0.14em] transition"
|
||||
:class="screenMode === 'stats' ? 'bg-stone-900 text-white' : 'bg-stone-100 text-stone-500'"
|
||||
@click="screenMode = 'stats'"
|
||||
>
|
||||
STATS
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="isAuthenticated"
|
||||
class="inline-flex rounded-full border border-stone-200 bg-stone-100 p-1"
|
||||
>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full px-4 py-2 text-xs font-bold tracking-[0.14em] transition"
|
||||
:class="viewMode === 'focus' ? 'bg-white text-ink shadow-sm' : 'text-stone-500'"
|
||||
class="rounded-2xl px-3 py-3 text-xs font-bold tracking-[0.14em] transition"
|
||||
:class="screenMode === 'goals' ? 'bg-stone-900 text-white' : 'bg-stone-100 text-stone-500'"
|
||||
@click="screenMode = 'goals'"
|
||||
>
|
||||
GOALS
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-2xl px-3 py-3 text-xs font-bold tracking-[0.14em] transition"
|
||||
:class="screenMode === 'settings' ? 'bg-stone-900 text-white' : 'bg-stone-100 text-stone-500'"
|
||||
@click="screenMode = 'settings'"
|
||||
>
|
||||
SETTINGS
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-if="isAuthenticated && screenMode === 'planner'" class="rounded-[24px] border border-stone-200 bg-white/80 p-4">
|
||||
<p class="text-[10px] font-bold tracking-[0.16em] text-stone-500">VIEW</p>
|
||||
<div class="mt-4 grid gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-2xl px-4 py-3 text-xs font-bold tracking-[0.14em] transition"
|
||||
:class="viewMode === 'focus' ? 'bg-stone-900 text-white' : 'bg-stone-100 text-stone-500'"
|
||||
@click="viewMode = 'focus'"
|
||||
>
|
||||
1 PAGE + INFO
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full px-4 py-2 text-xs font-bold tracking-[0.14em] transition"
|
||||
:class="viewMode === 'spread' ? 'bg-white text-ink shadow-sm' : 'text-stone-500'"
|
||||
class="rounded-2xl px-4 py-3 text-xs font-bold tracking-[0.14em] transition"
|
||||
:class="viewMode === 'spread' ? 'bg-stone-900 text-white' : 'bg-stone-100 text-stone-500'"
|
||||
@click="viewMode = 'spread'"
|
||||
>
|
||||
2 PAGE SPREAD
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="isAuthenticated"
|
||||
class="inline-flex items-center gap-2 rounded-full border border-stone-200 bg-white px-2 py-2"
|
||||
>
|
||||
</section>
|
||||
|
||||
<section v-if="isAuthenticated && screenMode === 'planner'" class="rounded-[24px] border border-stone-200 bg-white/80 p-4">
|
||||
<p class="text-[10px] font-bold tracking-[0.16em] text-stone-500">DAY MOVE</p>
|
||||
<div class="mt-4 grid gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full border border-stone-200 px-3 py-2 text-xs font-bold tracking-[0.14em] text-stone-600 transition hover:border-stone-400 hover:text-ink"
|
||||
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="shiftDate(-1)"
|
||||
>
|
||||
PREV DAY
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full border border-stone-200 px-3 py-2 text-xs font-bold tracking-[0.14em] text-stone-600 transition hover:border-stone-400 hover:text-ink"
|
||||
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="shiftDate(1)"
|
||||
>
|
||||
NEXT DAY
|
||||
</button>
|
||||
</div>
|
||||
<div
|
||||
v-if="isAuthenticated && screenMode === 'planner'"
|
||||
class="inline-flex items-center gap-2 rounded-full border border-stone-200 bg-white px-2 py-2"
|
||||
>
|
||||
</section>
|
||||
|
||||
<section v-if="isAuthenticated && screenMode === 'planner'" class="rounded-[24px] border border-stone-200 bg-white/80 p-4">
|
||||
<p class="text-[10px] font-bold tracking-[0.16em] text-stone-500">PRINT</p>
|
||||
<div class="mt-4 grid gap-2">
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full border border-stone-200 px-3 py-2 text-xs font-bold tracking-[0.14em] text-stone-600 transition hover:border-stone-400 hover:text-ink"
|
||||
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')"
|
||||
>
|
||||
PRINT 1-UP
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full border border-stone-200 px-3 py-2 text-xs font-bold tracking-[0.14em] text-stone-600 transition hover:border-stone-400 hover:text-ink"
|
||||
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')"
|
||||
>
|
||||
PRINT 2-UP
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</header>
|
||||
</aside>
|
||||
|
||||
<div class="min-w-0 space-y-6">
|
||||
<section
|
||||
v-if="!isAuthenticated"
|
||||
class="print-hidden rounded-[32px] border border-white/60 bg-white/65 p-6 shadow-[0_24px_80px_rgba(28,25,23,0.08)] sm:p-8"
|
||||
@@ -1065,7 +1400,8 @@ onMounted(() => {
|
||||
:date-main="selectedDateDisplay.main"
|
||||
:date-weekday="selectedDateDisplay.weekday"
|
||||
:date-weekday-tone="selectedDateDisplay.weekdayTone"
|
||||
:dday="planner.dday"
|
||||
:dday="plannerDday"
|
||||
:show-dday="showPlannerDday"
|
||||
:comment="planner.comment"
|
||||
:total-time="formatTotalTime(planner)"
|
||||
:tasks="planner.tasks"
|
||||
@@ -1097,24 +1433,23 @@ onMounted(() => {
|
||||
</section>
|
||||
|
||||
<section class="border border-stone-200 bg-white/80 p-5">
|
||||
<p class="mb-3 text-[11px] font-bold tracking-[0.22em] text-ink">TASK LABELS</p>
|
||||
<p class="text-[11px] font-semibold leading-5 tracking-[0.06em] text-stone-600">
|
||||
왼쪽 라벨은 직접 입력할 수 있고, 필요하면 아래 버튼으로 순번을 한 번에 채울 수 있습니다.
|
||||
</p>
|
||||
<div class="mt-4 flex flex-wrap gap-2">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<p class="text-[11px] font-bold tracking-[0.22em] text-ink">TASK LABELS</p>
|
||||
<p class="mt-2 text-[11px] font-semibold leading-5 tracking-[0.06em] text-stone-600">
|
||||
ON이면 왼쪽 라벨을 01, 02 형태로 채우고 OFF이면 비워 둡니다.
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full border border-stone-200 px-3 py-2 text-[10px] font-bold tracking-[0.14em] text-stone-600 transition hover:border-stone-400 hover:text-ink"
|
||||
@click="fillTaskLabelsWithNumbers(planner)"
|
||||
class="relative h-8 w-16 shrink-0 rounded-full transition"
|
||||
:class="areTaskLabelsNumbered(planner) ? 'bg-stone-900' : 'bg-stone-300'"
|
||||
@click="areTaskLabelsNumbered(planner) ? clearTaskLabels(planner) : fillTaskLabelsWithNumbers(planner)"
|
||||
>
|
||||
번호 채우기
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full border border-stone-200 px-3 py-2 text-[10px] font-bold tracking-[0.14em] text-stone-600 transition hover:border-stone-400 hover:text-ink"
|
||||
@click="clearTaskLabels(planner)"
|
||||
>
|
||||
라벨 비우기
|
||||
<span
|
||||
class="absolute top-1 h-6 w-6 rounded-full bg-white shadow-sm transition"
|
||||
:class="areTaskLabelsNumbered(planner) ? 'left-9' : 'left-1'"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
</section>
|
||||
@@ -1132,6 +1467,51 @@ onMounted(() => {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section class="border border-stone-200 bg-white/80 p-5">
|
||||
<div class="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<p class="text-[11px] font-bold tracking-[0.22em] text-ink">D-DAY 사용</p>
|
||||
<p class="mt-2 text-[11px] font-semibold leading-5 tracking-[0.06em] text-stone-600">
|
||||
목표 검색과 기간 설정은 GOALS 화면에서 관리하고, 여기서는 현재 날짜에 D-DAY를 보여줄지 여부만 제어합니다.
|
||||
</p>
|
||||
</div>
|
||||
<button
|
||||
type="button"
|
||||
class="relative h-8 w-16 shrink-0 rounded-full transition disabled:cursor-not-allowed disabled:opacity-50"
|
||||
:class="planner.goalEnabled ? 'bg-stone-900' : 'bg-stone-300'"
|
||||
:disabled="!hasActiveGoalForSelectedDate"
|
||||
@click="updateGoalEnabled(planner, !planner.goalEnabled)"
|
||||
>
|
||||
<span
|
||||
class="absolute top-1 h-6 w-6 rounded-full bg-white shadow-sm transition"
|
||||
:class="planner.goalEnabled ? 'left-9' : 'left-1'"
|
||||
/>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div class="mt-4 space-y-3">
|
||||
<div v-if="plannerGoal" class="rounded-2xl border border-stone-200 bg-white px-4 py-3">
|
||||
<p class="text-[10px] font-bold tracking-[0.16em] text-stone-500">현재 목표</p>
|
||||
<p class="mt-2 text-sm font-semibold tracking-[0.02em] text-stone-900">{{ plannerGoal.title }}</p>
|
||||
<p class="mt-1 text-[11px] font-semibold tracking-[0.06em] text-stone-500">
|
||||
목표일 {{ plannerGoal.targetDate }} / 적용 {{ plannerGoal.activeFrom }} ~ {{ plannerGoal.activeUntil }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div v-if="plannerGoal" class="rounded-2xl border border-stone-200 bg-[#fbf7f0] px-4 py-4">
|
||||
<p class="text-[11px] font-semibold leading-5 tracking-[0.06em] text-stone-600">
|
||||
이 날짜에는 이미 적용된 목표가 있으므로 토글만으로 표시 여부를 빠르게 조절할 수 있습니다.
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div v-else class="rounded-2xl border border-dashed border-stone-300 bg-white/70 px-4 py-4">
|
||||
<p class="text-[11px] font-semibold leading-5 tracking-[0.06em] text-stone-500">
|
||||
현재 날짜에 적용된 목표가 없습니다. GOALS 화면에서 표시 기간을 지정하면 여기 토글이 자동으로 활성화됩니다.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<MiniCalendar
|
||||
:month-label="monthLabel"
|
||||
:year-label="yearLabel"
|
||||
@@ -1185,7 +1565,8 @@ onMounted(() => {
|
||||
:date-main="selectedDateDisplay.main"
|
||||
:date-weekday="selectedDateDisplay.weekday"
|
||||
:date-weekday-tone="selectedDateDisplay.weekdayTone"
|
||||
:dday="planner.dday"
|
||||
:dday="plannerDday"
|
||||
:show-dday="showPlannerDday"
|
||||
:comment="planner.comment"
|
||||
:total-time="formatTotalTime(planner)"
|
||||
:tasks="planner.tasks"
|
||||
@@ -1206,7 +1587,8 @@ onMounted(() => {
|
||||
:date-main="secondaryDateDisplay.main"
|
||||
:date-weekday="secondaryDateDisplay.weekday"
|
||||
:date-weekday-tone="secondaryDateDisplay.weekdayTone"
|
||||
:dday="secondaryPlanner.dday"
|
||||
:dday="''"
|
||||
:show-dday="false"
|
||||
:comment="secondaryPlanner.comment"
|
||||
:total-time="formatTotalTime(secondaryPlanner)"
|
||||
:tasks="secondaryPlanner.tasks"
|
||||
@@ -1225,6 +1607,42 @@ onMounted(() => {
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<GoalsDashboard
|
||||
v-else-if="screenMode === 'goals'"
|
||||
class="print-hidden"
|
||||
:goals="filteredGoals"
|
||||
:query="goalQuery"
|
||||
:status="goalStatusFilter"
|
||||
:form="goalForm"
|
||||
:editing-goal-id="editingGoalId"
|
||||
:busy="goalBusy"
|
||||
:message="goalMessage"
|
||||
:selected-date-key="toKey(selectedDate)"
|
||||
@update:query="goalQuery = $event"
|
||||
@update:status="goalStatusFilter = $event"
|
||||
@update:form-field="updateGoalFormField"
|
||||
@submit:create="submitGoal"
|
||||
@start-edit="startGoalEdit"
|
||||
@cancel-edit="resetGoalForm(); goalMessage = ''"
|
||||
@submit:update="saveGoalEdit"
|
||||
/>
|
||||
|
||||
<SettingsDashboard
|
||||
v-else-if="screenMode === 'settings'"
|
||||
class="print-hidden"
|
||||
:user="currentUser"
|
||||
:profile-form="profileForm"
|
||||
:password-form="passwordForm"
|
||||
:profile-busy="profileBusy"
|
||||
:password-busy="passwordBusy"
|
||||
:profile-message="profileMessage"
|
||||
:password-message="passwordMessage"
|
||||
@update:profile-field="updateProfileField"
|
||||
@update:password-field="updatePasswordField"
|
||||
@submit:profile="submitProfileForm"
|
||||
@submit:password="submitPasswordForm"
|
||||
/>
|
||||
|
||||
<StatsDashboard
|
||||
v-else
|
||||
class="print-hidden"
|
||||
@@ -1246,7 +1664,8 @@ onMounted(() => {
|
||||
:date-main="selectedDateDisplay.main"
|
||||
:date-weekday="selectedDateDisplay.weekday"
|
||||
:date-weekday-tone="selectedDateDisplay.weekdayTone"
|
||||
:dday="planner.dday"
|
||||
:dday="plannerDday"
|
||||
:show-dday="showPlannerDday"
|
||||
:comment="planner.comment"
|
||||
:total-time="formatTotalTime(planner)"
|
||||
:tasks="planner.tasks"
|
||||
@@ -1270,7 +1689,8 @@ onMounted(() => {
|
||||
:date-main="selectedDateDisplay.main"
|
||||
:date-weekday="selectedDateDisplay.weekday"
|
||||
:date-weekday-tone="selectedDateDisplay.weekdayTone"
|
||||
:dday="planner.dday"
|
||||
:dday="plannerDday"
|
||||
:show-dday="showPlannerDday"
|
||||
:comment="planner.comment"
|
||||
:total-time="formatTotalTime(planner)"
|
||||
:tasks="planner.tasks"
|
||||
@@ -1291,7 +1711,8 @@ onMounted(() => {
|
||||
:date-main="secondaryDateDisplay.main"
|
||||
:date-weekday="secondaryDateDisplay.weekday"
|
||||
:date-weekday-tone="secondaryDateDisplay.weekdayTone"
|
||||
:dday="secondaryPlanner.dday"
|
||||
:dday="''"
|
||||
:show-dday="false"
|
||||
:comment="secondaryPlanner.comment"
|
||||
:total-time="formatTotalTime(secondaryPlanner)"
|
||||
:tasks="secondaryPlanner.tasks"
|
||||
@@ -1309,6 +1730,7 @@ onMounted(() => {
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<AuthDialog
|
||||
|
||||
233
src/components/GoalsDashboard.vue
Normal file
233
src/components/GoalsDashboard.vue
Normal file
@@ -0,0 +1,233 @@
|
||||
<script setup>
|
||||
const props = defineProps({
|
||||
goals: {
|
||||
type: Array,
|
||||
default: () => [],
|
||||
},
|
||||
query: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
status: {
|
||||
type: String,
|
||||
default: 'all',
|
||||
},
|
||||
form: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
editingGoalId: {
|
||||
type: Number,
|
||||
default: null,
|
||||
},
|
||||
busy: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
message: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
selectedDateKey: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits([
|
||||
'update:query',
|
||||
'update:status',
|
||||
'update:form-field',
|
||||
'submit:create',
|
||||
'start-edit',
|
||||
'cancel-edit',
|
||||
'submit:update',
|
||||
])
|
||||
|
||||
function updateField(field, event) {
|
||||
emit('update:form-field', {
|
||||
field,
|
||||
value: event.target.value,
|
||||
})
|
||||
}
|
||||
|
||||
function isActiveOnSelectedDate(goal) {
|
||||
if (!goal.activeFrom || !goal.activeUntil || !props.selectedDateKey) {
|
||||
return false
|
||||
}
|
||||
|
||||
return props.selectedDateKey >= goal.activeFrom && props.selectedDateKey <= goal.activeUntil
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="grid gap-6 xl:grid-cols-[380px_minmax(0,1fr)]">
|
||||
<form class="rounded-[28px] border border-white/60 bg-white/75 p-6" @submit.prevent="emit(editingGoalId ? 'submit:update' : 'submit:create')">
|
||||
<p class="text-[11px] font-bold uppercase tracking-[0.24em] text-stone-500">
|
||||
{{ editingGoalId ? 'Edit Goal' : 'Create Goal' }}
|
||||
</p>
|
||||
<div class="mt-5 space-y-4">
|
||||
<div class="space-y-2">
|
||||
<label class="text-[11px] font-bold tracking-[0.16em] text-stone-600">목표 이름</label>
|
||||
<input
|
||||
:value="form.title"
|
||||
type="text"
|
||||
class="w-full rounded-2xl border border-stone-300 bg-white px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-stone-500"
|
||||
placeholder="예: 자격증 시험 / 프로젝트 런칭 / 운동 루틴"
|
||||
@input="updateField('title', $event)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<label class="text-[11px] font-bold tracking-[0.16em] text-stone-600">목표일</label>
|
||||
<input
|
||||
:value="form.targetDate"
|
||||
type="date"
|
||||
class="w-full rounded-2xl border border-stone-300 bg-white px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-stone-500"
|
||||
@input="updateField('targetDate', $event)"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div class="grid gap-4 sm:grid-cols-2">
|
||||
<div class="space-y-2">
|
||||
<label class="text-[11px] font-bold tracking-[0.16em] text-stone-600">표시 시작일</label>
|
||||
<input
|
||||
:value="form.activeFrom"
|
||||
type="date"
|
||||
class="w-full rounded-2xl border border-stone-300 bg-white px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-stone-500"
|
||||
@input="updateField('activeFrom', $event)"
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<label class="text-[11px] font-bold tracking-[0.16em] text-stone-600">표시 종료일</label>
|
||||
<input
|
||||
:value="form.activeUntil"
|
||||
type="date"
|
||||
class="w-full rounded-2xl border border-stone-300 bg-white px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-stone-500"
|
||||
@input="updateField('activeUntil', $event)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="space-y-2">
|
||||
<label class="text-[11px] font-bold tracking-[0.16em] text-stone-600">상태</label>
|
||||
<select
|
||||
:value="form.status"
|
||||
class="w-full rounded-2xl border border-stone-300 bg-white px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-stone-500"
|
||||
@change="updateField('status', $event)"
|
||||
>
|
||||
<option value="active">진행 중</option>
|
||||
<option value="done">완료</option>
|
||||
<option value="archived">보관</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<p class="rounded-2xl border border-stone-200 bg-[#fbf7f0] px-4 py-3 text-[11px] font-semibold leading-5 tracking-[0.06em] text-stone-600">
|
||||
여기서 목표와 표시 기간을 설정해 두면, 플래너 작성 화면에서는 해당 날짜에 보여줄지 여부만 간단히 ON/OFF 할 수 있습니다.
|
||||
</p>
|
||||
|
||||
<p
|
||||
v-if="message"
|
||||
class="rounded-2xl border border-stone-300 bg-white/80 px-4 py-3 text-sm font-semibold leading-6 text-stone-700"
|
||||
>
|
||||
{{ message }}
|
||||
</p>
|
||||
|
||||
<div class="flex flex-wrap gap-2">
|
||||
<button
|
||||
type="submit"
|
||||
class="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 ? '저장 중...' : editingGoalId ? '목표 수정' : '목표 추가' }}
|
||||
</button>
|
||||
<button
|
||||
v-if="editingGoalId"
|
||||
type="button"
|
||||
class="rounded-full border border-stone-300 px-5 py-3 text-xs font-bold tracking-[0.18em] text-stone-600 transition hover:border-stone-500 hover:text-stone-900"
|
||||
@click="emit('cancel-edit')"
|
||||
>
|
||||
취소
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<section class="rounded-[28px] border border-white/60 bg-white/75 p-6">
|
||||
<div class="flex flex-col gap-4 md:flex-row md:items-end md:justify-between">
|
||||
<div>
|
||||
<p class="text-[11px] font-bold uppercase tracking-[0.24em] text-stone-500">Goal Library</p>
|
||||
<p class="mt-2 text-sm font-semibold leading-6 text-stone-600">
|
||||
목표가 많아져도 플래너 작성 화면이 길어지지 않도록, 전체 관리는 이 화면에서 처리합니다.
|
||||
</p>
|
||||
</div>
|
||||
<div class="grid gap-2 sm:grid-cols-[220px_140px]">
|
||||
<input
|
||||
:value="query"
|
||||
type="text"
|
||||
class="rounded-2xl border border-stone-300 bg-white px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-stone-500"
|
||||
placeholder="목표 검색"
|
||||
@input="emit('update:query', $event.target.value)"
|
||||
/>
|
||||
<select
|
||||
:value="status"
|
||||
class="rounded-2xl border border-stone-300 bg-white px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-stone-500"
|
||||
@change="emit('update:status', $event.target.value)"
|
||||
>
|
||||
<option value="all">전체</option>
|
||||
<option value="active">진행 중</option>
|
||||
<option value="done">완료</option>
|
||||
<option value="archived">보관</option>
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="mt-5 grid gap-4">
|
||||
<article
|
||||
v-for="goal in goals"
|
||||
:key="goal.id"
|
||||
class="rounded-[24px] border border-stone-200 bg-white px-5 py-5"
|
||||
>
|
||||
<div class="flex flex-col gap-3 md:flex-row md:items-start md:justify-between">
|
||||
<div class="space-y-2">
|
||||
<div class="flex flex-wrap items-center gap-2">
|
||||
<p class="text-lg font-semibold tracking-[-0.03em] text-stone-900">{{ goal.title }}</p>
|
||||
<span
|
||||
class="rounded-full px-3 py-1 text-[10px] font-bold tracking-[0.16em]"
|
||||
:class="goal.status === 'done' ? 'bg-emerald-100 text-emerald-700' : goal.status === 'archived' ? 'bg-stone-200 text-stone-600' : 'bg-stone-900 text-white'"
|
||||
>
|
||||
{{ goal.status === 'done' ? '완료' : goal.status === 'archived' ? '보관' : '진행 중' }}
|
||||
</span>
|
||||
<span
|
||||
v-if="isActiveOnSelectedDate(goal)"
|
||||
class="rounded-full bg-amber-100 px-3 py-1 text-[10px] font-bold tracking-[0.16em] text-amber-700"
|
||||
>
|
||||
현재 날짜에 표시 중
|
||||
</span>
|
||||
</div>
|
||||
<p class="text-sm font-semibold text-stone-600">목표일 {{ goal.targetDate }}</p>
|
||||
<p class="text-[11px] font-semibold tracking-[0.06em] text-stone-500">
|
||||
{{ goal.activeFrom && goal.activeUntil ? `표시 기간 ${goal.activeFrom} ~ ${goal.activeUntil}` : '표시 기간 미설정' }}
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<button
|
||||
type="button"
|
||||
class="rounded-full border border-stone-300 px-4 py-2 text-[11px] font-bold tracking-[0.16em] text-stone-600 transition hover:border-stone-500 hover:text-stone-900"
|
||||
@click="emit('start-edit', goal)"
|
||||
>
|
||||
수정
|
||||
</button>
|
||||
</div>
|
||||
</article>
|
||||
|
||||
<div
|
||||
v-if="goals.length === 0"
|
||||
class="rounded-[24px] border border-dashed border-stone-300 bg-white px-5 py-8 text-center"
|
||||
>
|
||||
<p class="text-sm font-semibold text-stone-600">조건에 맞는 목표가 없습니다.</p>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</section>
|
||||
</template>
|
||||
@@ -16,7 +16,11 @@ const props = defineProps({
|
||||
},
|
||||
dday: {
|
||||
type: String,
|
||||
required: true,
|
||||
default: '',
|
||||
},
|
||||
showDday: {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
comment: {
|
||||
type: String,
|
||||
@@ -119,14 +123,14 @@ onBeforeUnmount(() => {
|
||||
>
|
||||
<div class="flex flex-col gap-4 py-[18px]">
|
||||
<div class="flex gap-4">
|
||||
<div class="relative h-[90px] w-[394px] flex-1 border-t border-ink px-[10px] pt-[10px]">
|
||||
<div class="relative h-[90px] border-t border-ink px-[10px] pt-[10px]" :class="props.showDday ? 'w-[394px] flex-1' : 'w-full flex-1'">
|
||||
<span class="absolute -top-2 left-0 bg-paper px-[2px] text-muted">YEAR / MONTH / DAY</span>
|
||||
<p class="pt-6 text-xs tracking-[0.24em] text-ink sm:text-sm">
|
||||
<span>{{ dateMain }}</span>
|
||||
<span class="ml-1" :class="dateWeekdayTone">{{ dateWeekday }}</span>
|
||||
</p>
|
||||
</div>
|
||||
<div class="relative h-[90px] w-[210px] border-t border-ink px-[10px] pt-[10px]">
|
||||
<div v-if="props.showDday" class="relative h-[90px] w-[210px] border-t border-ink px-[10px] pt-[10px]">
|
||||
<span class="absolute -top-2 left-0 bg-paper px-[2px] text-muted">D-DAY</span>
|
||||
<p class="pt-6 text-xs tracking-[0.24em] text-ink sm:text-sm">{{ dday }}</p>
|
||||
</div>
|
||||
|
||||
171
src/components/SettingsDashboard.vue
Normal file
171
src/components/SettingsDashboard.vue
Normal file
@@ -0,0 +1,171 @@
|
||||
<script setup>
|
||||
import { computed } from 'vue'
|
||||
|
||||
const props = defineProps({
|
||||
user: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
profileForm: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
passwordForm: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
profileBusy: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
passwordBusy: {
|
||||
type: Boolean,
|
||||
default: false,
|
||||
},
|
||||
profileMessage: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
passwordMessage: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
})
|
||||
|
||||
const emit = defineEmits([
|
||||
'update:profile-field',
|
||||
'update:password-field',
|
||||
'submit:profile',
|
||||
'submit:password',
|
||||
])
|
||||
|
||||
const initials = computed(() =>
|
||||
`${props.user.nickname?.slice(0, 1) ?? ''}${props.user.email?.slice(0, 1) ?? ''}`.toUpperCase(),
|
||||
)
|
||||
|
||||
function updateProfileField(field, event) {
|
||||
emit('update:profile-field', {
|
||||
field,
|
||||
value: event.target.value,
|
||||
})
|
||||
}
|
||||
|
||||
function updatePasswordField(field, event) {
|
||||
emit('update:password-field', {
|
||||
field,
|
||||
value: event.target.value,
|
||||
})
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section class="grid gap-6 xl:grid-cols-[360px_minmax(0,1fr)]">
|
||||
<aside class="rounded-[28px] border border-white/60 bg-white/70 p-6">
|
||||
<p class="text-[11px] font-bold uppercase tracking-[0.28em] text-stone-500">Settings</p>
|
||||
<div class="mt-6 flex items-center gap-4">
|
||||
<div class="flex h-20 w-20 items-center justify-center rounded-full bg-stone-900 text-2xl font-bold tracking-[0.04em] text-white">
|
||||
{{ initials || 'U' }}
|
||||
</div>
|
||||
<div>
|
||||
<p class="text-xl font-semibold tracking-[-0.04em] text-stone-900">{{ user.nickname }}</p>
|
||||
<p class="mt-1 text-sm font-semibold text-stone-500">{{ user.email }}</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="mt-6 space-y-3 rounded-[24px] border border-stone-200 bg-[#fbf7f0] p-4">
|
||||
<p class="text-[10px] font-bold tracking-[0.18em] text-stone-500">PROFILE NOTE</p>
|
||||
<p class="text-sm font-semibold leading-6 text-stone-700">
|
||||
썸네일 이미지는 다음 단계에서 붙이는 편이 자연스럽습니다. 이번 단계에서는 계정 정보 수정과 비밀번호 변경 흐름을 먼저 안정화합니다.
|
||||
</p>
|
||||
</div>
|
||||
</aside>
|
||||
|
||||
<div class="grid gap-6">
|
||||
<form class="rounded-[28px] border border-white/60 bg-white/75 p-6" @submit.prevent="emit('submit:profile')">
|
||||
<p class="text-[11px] font-bold uppercase tracking-[0.24em] text-stone-500">Account Profile</p>
|
||||
<div class="mt-5 grid gap-4 md:grid-cols-2">
|
||||
<div class="space-y-2">
|
||||
<label class="text-[11px] font-bold tracking-[0.16em] text-stone-600">닉네임</label>
|
||||
<input
|
||||
:value="profileForm.nickname"
|
||||
type="text"
|
||||
class="w-full rounded-2xl border border-stone-300 bg-white px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-stone-500"
|
||||
@input="updateProfileField('nickname', $event)"
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<label class="text-[11px] font-bold tracking-[0.16em] text-stone-600">이메일</label>
|
||||
<input
|
||||
:value="profileForm.email"
|
||||
type="email"
|
||||
class="w-full rounded-2xl border border-stone-300 bg-white px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-stone-500"
|
||||
@input="updateProfileField('email', $event)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p
|
||||
v-if="profileMessage"
|
||||
class="mt-4 rounded-2xl border border-stone-300 bg-white/80 px-4 py-3 text-sm font-semibold leading-6 text-stone-700"
|
||||
>
|
||||
{{ profileMessage }}
|
||||
</p>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
class="mt-5 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="profileBusy"
|
||||
>
|
||||
{{ profileBusy ? '저장 중...' : '프로필 저장' }}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<form class="rounded-[28px] border border-white/60 bg-white/75 p-6" @submit.prevent="emit('submit:password')">
|
||||
<p class="text-[11px] font-bold uppercase tracking-[0.24em] text-stone-500">Password</p>
|
||||
<div class="mt-5 grid gap-4 md:grid-cols-2">
|
||||
<div class="space-y-2 md:col-span-2">
|
||||
<label class="text-[11px] font-bold tracking-[0.16em] text-stone-600">현재 비밀번호</label>
|
||||
<input
|
||||
:value="passwordForm.currentPassword"
|
||||
type="password"
|
||||
class="w-full rounded-2xl border border-stone-300 bg-white px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-stone-500"
|
||||
@input="updatePasswordField('currentPassword', $event)"
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<label class="text-[11px] font-bold tracking-[0.16em] text-stone-600">새 비밀번호</label>
|
||||
<input
|
||||
:value="passwordForm.newPassword"
|
||||
type="password"
|
||||
class="w-full rounded-2xl border border-stone-300 bg-white px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-stone-500"
|
||||
@input="updatePasswordField('newPassword', $event)"
|
||||
/>
|
||||
</div>
|
||||
<div class="space-y-2">
|
||||
<label class="text-[11px] font-bold tracking-[0.16em] text-stone-600">새 비밀번호 확인</label>
|
||||
<input
|
||||
:value="passwordForm.confirmPassword"
|
||||
type="password"
|
||||
class="w-full rounded-2xl border border-stone-300 bg-white px-4 py-3 text-sm font-semibold text-stone-800 outline-none transition focus:border-stone-500"
|
||||
@input="updatePasswordField('confirmPassword', $event)"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p
|
||||
v-if="passwordMessage"
|
||||
class="mt-4 rounded-2xl border border-stone-300 bg-white/80 px-4 py-3 text-sm font-semibold leading-6 text-stone-700"
|
||||
>
|
||||
{{ passwordMessage }}
|
||||
</p>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
class="mt-5 rounded-full border border-stone-900 px-5 py-3 text-xs font-bold tracking-[0.18em] text-stone-900 transition hover:bg-stone-900 hover:text-white disabled:cursor-not-allowed disabled:border-stone-300 disabled:text-stone-400"
|
||||
:disabled="passwordBusy"
|
||||
>
|
||||
{{ passwordBusy ? '변경 중...' : '비밀번호 변경' }}
|
||||
</button>
|
||||
</form>
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
@@ -79,3 +79,19 @@ export async function fetchCurrentUser(token) {
|
||||
token,
|
||||
})
|
||||
}
|
||||
|
||||
export async function updateProfile(token, { email, nickname }) {
|
||||
return request('/api/auth/profile', {
|
||||
method: 'PUT',
|
||||
token,
|
||||
body: { email, nickname },
|
||||
})
|
||||
}
|
||||
|
||||
export async function updatePassword(token, { currentPassword, newPassword }) {
|
||||
return request('/api/auth/password', {
|
||||
method: 'PUT',
|
||||
token,
|
||||
body: { currentPassword, newPassword },
|
||||
})
|
||||
}
|
||||
|
||||
57
src/lib/goalsApi.js
Normal file
57
src/lib/goalsApi.js
Normal file
@@ -0,0 +1,57 @@
|
||||
const API_BASE_URL = import.meta.env.VITE_API_BASE_URL ?? 'http://localhost:3001'
|
||||
|
||||
function buildHeaders(token) {
|
||||
return {
|
||||
'Content-Type': 'application/json',
|
||||
Authorization: `Bearer ${token}`,
|
||||
}
|
||||
}
|
||||
|
||||
async function request(path, { method = 'GET', token, body } = {}) {
|
||||
const response = await fetch(`${API_BASE_URL}${path}`, {
|
||||
method,
|
||||
headers: buildHeaders(token),
|
||||
body: body ? JSON.stringify(body) : undefined,
|
||||
})
|
||||
|
||||
const data = await response.json().catch(() => ({}))
|
||||
|
||||
if (!response.ok) {
|
||||
throw new Error(data.message || '목표 데이터를 처리하지 못했습니다.')
|
||||
}
|
||||
|
||||
return data
|
||||
}
|
||||
|
||||
export async function fetchGoals(token, { query = '', status = 'active' } = {}) {
|
||||
const searchParams = new URLSearchParams()
|
||||
|
||||
if (query) {
|
||||
searchParams.set('query', query)
|
||||
}
|
||||
|
||||
if (status) {
|
||||
searchParams.set('status', status)
|
||||
}
|
||||
|
||||
const queryString = searchParams.toString()
|
||||
return request(`/api/goals${queryString ? `?${queryString}` : ''}`, {
|
||||
token,
|
||||
})
|
||||
}
|
||||
|
||||
export async function createGoal(token, payload) {
|
||||
return request('/api/goals', {
|
||||
method: 'POST',
|
||||
token,
|
||||
body: payload,
|
||||
})
|
||||
}
|
||||
|
||||
export async function updateGoal(token, goalId, payload) {
|
||||
return request(`/api/goals/${goalId}`, {
|
||||
method: 'PATCH',
|
||||
token,
|
||||
body: payload,
|
||||
})
|
||||
}
|
||||
Reference in New Issue
Block a user