Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release #46

Merged
merged 9 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
"@types/node": "^20",
"@types/react": "^18",
"@types/react-dom": "^18",
"@typescript-eslint/eslint-plugin": "6.11.0",
"@typescript-eslint/eslint-plugin": "6.12.0",
"autoprefixer": "^10",
"eslint": "8.54.0",
"eslint-config-next": "14.0.3",
Expand Down
6 changes: 3 additions & 3 deletions src/app/objectives/[id]/page.tsx → src/app/[slug]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { format } from 'date-fns';
import { getObjective, getObjectiveNippos } from '../../_actions/objectiveActions';
import { getObjectiveBySlug, getObjectiveNippos } from '../_actions/objectiveActions';
import { NippoEditor } from './_components/NippoEditor';
import { NippoPreview } from './_components/NippoPreview/NippoPreview';
import { fetchMe } from '~/app/_actions/userActions';
import { getCurrentDate } from '~/libs/getCurrentDate';

export default async function Page({ params }: { params: { id: string } }) {
const [{ objective }, { currentUser }] = await Promise.all([getObjective(params.id), fetchMe()]);
export default async function Page({ params }: { params: { slug: string } }) {
const [{ objective }, { currentUser }] = await Promise.all([getObjectiveBySlug(params.slug), fetchMe()]);
const { nippos } = await getObjectiveNippos({ objectiveId: objective._id, isMyObjective: currentUser?._id === objective.createdUserId });

const todayNippo = nippos.find((nippo) => nippo.date === format(getCurrentDate(), 'yyyy-MM-dd'));
Expand Down
10 changes: 7 additions & 3 deletions src/app/_actions/objectiveActions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
'use server';

import { redirect } from 'next/navigation';
import { API_OBJECTIVE, API_OBJECTIVE_ID, API_OBJECTIVE_ID_NIPPO, API_OBJECTIVE_ME } from '../_constants/apiUrls';
import { API_OBJECTIVE, API_OBJECTIVE_ID, API_OBJECTIVE_ID_NIPPO, API_OBJECTIVE_ME, API_OBJECTIVE_SLUG } from '../_constants/apiUrls';
import { URLS } from '../_constants/urls';
import { Objective } from '~/domains/Objective';
import { apiGet, apiPost } from '~/libs/apiClient';
Expand All @@ -15,15 +15,19 @@ export const getObjective = async (_id: string) => {
return await apiGet<{ objective: Objective }>(API_OBJECTIVE_ID(_id));
};

export const getObjectiveBySlug = async (slug: string) => {
return await apiGet<{ objective: Objective }>(API_OBJECTIVE_SLUG(slug));
};

export const postObjective = async (name: string) => {
return await apiPost<{ objective: Objective }>(API_OBJECTIVE(), {
body: JSON.stringify({
name,
description: name,
}),
}).then((res) => {
const { _id } = res.objective;
redirect(URLS.OBJECTIVE(_id));
const { slug } = res.objective;
redirect(URLS.SLUG(slug));
});
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export const StartButton: FC<Props> = ({ currentUser, objective }) => {

if (objective) {
return (
<Link href={URLS.OBJECTIVE(objective._id)}>
<Link href={URLS.SLUG(objective.slug)}>
<Button className="w-[200px]" color="primary" variant="bordered">
再開する
</Button>
Expand Down
1 change: 1 addition & 0 deletions src/app/_constants/apiUrls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const API_ME = () => `/api/me`;

export const API_OBJECTIVE = () => `/api/objectives`;
export const API_OBJECTIVE_ID = (_id: string) => `/api/objectives/${_id}`;
export const API_OBJECTIVE_SLUG = (slug: string) => `/api/objectives/slug/${slug}`;
export const API_OBJECTIVE_ME = () => `/api/objectives/me`;

export const API_OBJECTIVE_ID_NIPPO = (_id: string) => `/api/objectives/${_id}/nippos`;
2 changes: 1 addition & 1 deletion src/app/_constants/urls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const serverUrl = process.env.NEXT_PUBLIC_SERVER_URL;
export const URLS = {
TOP: '/',
NOTE_NEW: '/notes/new',
OBJECTIVE: (id: string) => `/objectives/${id}`,
SLUG: (slug: string) => `/${slug}`,
TERM: `${frontUrl}/terms`,
POLICY: `${frontUrl}/policy`,
LOGIN_TO_BACKEND: `${serverUrl}/auth/google`,
Expand Down
1 change: 1 addition & 0 deletions src/domains/Objective/Objective.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export interface Objective {
_id: string;
name: string;
slug: string;
description: string;
createdUserId: string;
status: 'INPROGRESS' | 'DONE';
Expand Down
84 changes: 42 additions & 42 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2404,16 +2404,16 @@
dependencies:
"@types/webidl-conversions" "*"

"@typescript-eslint/eslint-plugin@6.11.0":
version "6.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.11.0.tgz#52aae65174ff526576351f9ccd41cea01001463f"
integrity sha512-uXnpZDc4VRjY4iuypDBKzW1rz9T5YBBK0snMn8MaTSNd2kMlj50LnLBABELjJiOL5YHk7ZD8hbSpI9ubzqYI0w==
"@typescript-eslint/eslint-plugin@6.12.0":
version "6.12.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-6.12.0.tgz#2a647d278bb48bf397fef07ba0507612ff9dd812"
integrity sha512-XOpZ3IyJUIV1b15M7HVOpgQxPPF7lGXgsfcEIu3yDxFPaf/xZKt7s9QO/pbk7vpWQyVulpJbu4E5LwpZiQo4kA==
dependencies:
"@eslint-community/regexpp" "^4.5.1"
"@typescript-eslint/scope-manager" "6.11.0"
"@typescript-eslint/type-utils" "6.11.0"
"@typescript-eslint/utils" "6.11.0"
"@typescript-eslint/visitor-keys" "6.11.0"
"@typescript-eslint/scope-manager" "6.12.0"
"@typescript-eslint/type-utils" "6.12.0"
"@typescript-eslint/utils" "6.12.0"
"@typescript-eslint/visitor-keys" "6.12.0"
debug "^4.3.4"
graphemer "^1.4.0"
ignore "^5.2.4"
Expand All @@ -2432,13 +2432,13 @@
"@typescript-eslint/visitor-keys" "6.9.0"
debug "^4.3.4"

"@typescript-eslint/scope-manager@6.11.0":
version "6.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.11.0.tgz#621f603537c89f4d105733d949aa4d55eee5cea8"
integrity sha512-0A8KoVvIURG4uhxAdjSaxy8RdRE//HztaZdG8KiHLP8WOXSk0vlF7Pvogv+vlJA5Rnjj/wDcFENvDaHb+gKd1A==
"@typescript-eslint/scope-manager@6.12.0":
version "6.12.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/scope-manager/-/scope-manager-6.12.0.tgz#5833a16dbe19cfbad639d4d33bcca5e755c7044b"
integrity sha512-5gUvjg+XdSj8pcetdL9eXJzQNTl3RD7LgUiYTl8Aabdi8hFkaGSYnaS6BLc0BGNaDH+tVzVwmKtWvu0jLgWVbw==
dependencies:
"@typescript-eslint/types" "6.11.0"
"@typescript-eslint/visitor-keys" "6.11.0"
"@typescript-eslint/types" "6.12.0"
"@typescript-eslint/visitor-keys" "6.12.0"

"@typescript-eslint/[email protected]":
version "6.9.0"
Expand All @@ -2448,33 +2448,33 @@
"@typescript-eslint/types" "6.9.0"
"@typescript-eslint/visitor-keys" "6.9.0"

"@typescript-eslint/type-utils@6.11.0":
version "6.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.11.0.tgz#d0b8b1ab6c26b974dbf91de1ebc5b11fea24e0d1"
integrity sha512-nA4IOXwZtqBjIoYrJcYxLRO+F9ri+leVGoJcMW1uqr4r1Hq7vW5cyWrA43lFbpRvQ9XgNrnfLpIkO3i1emDBIA==
"@typescript-eslint/type-utils@6.12.0":
version "6.12.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/type-utils/-/type-utils-6.12.0.tgz#968f7c95162808d69950ab5dff710ad730e58287"
integrity sha512-WWmRXxhm1X8Wlquj+MhsAG4dU/Blvf1xDgGaYCzfvStP2NwPQh6KBvCDbiOEvaE0filhranjIlK/2fSTVwtBng==
dependencies:
"@typescript-eslint/typescript-estree" "6.11.0"
"@typescript-eslint/utils" "6.11.0"
"@typescript-eslint/typescript-estree" "6.12.0"
"@typescript-eslint/utils" "6.12.0"
debug "^4.3.4"
ts-api-utils "^1.0.1"

"@typescript-eslint/types@6.11.0":
version "6.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.11.0.tgz#8ad3aa000cbf4bdc4dcceed96e9b577f15e0bf53"
integrity sha512-ZbEzuD4DwEJxwPqhv3QULlRj8KYTAnNsXxmfuUXFCxZmO6CF2gM/y+ugBSAQhrqaJL3M+oe4owdWunaHM6beqA==
"@typescript-eslint/types@6.12.0":
version "6.12.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.12.0.tgz#ffc5297bcfe77003c8b7b545b51c2505748314ac"
integrity sha512-MA16p/+WxM5JG/F3RTpRIcuOghWO30//VEOvzubM8zuOOBYXsP+IfjoCXXiIfy2Ta8FRh9+IO9QLlaFQUU+10Q==

"@typescript-eslint/[email protected]":
version "6.9.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/types/-/types-6.9.0.tgz#86a0cbe7ac46c0761429f928467ff3d92f841098"
integrity sha512-+KB0lbkpxBkBSiVCuQvduqMJy+I1FyDbdwSpM3IoBS7APl4Bu15lStPjgBIdykdRqQNYqYNMa8Kuidax6phaEw==

"@typescript-eslint/typescript-estree@6.11.0":
version "6.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.11.0.tgz#7b52c12a623bf7f8ec7f8a79901b9f98eb5c7990"
integrity sha512-Aezzv1o2tWJwvZhedzvD5Yv7+Lpu1by/U1LZ5gLc4tCx8jUmuSCMioPFRjliN/6SJIvY6HpTtJIWubKuYYYesQ==
"@typescript-eslint/typescript-estree@6.12.0":
version "6.12.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/typescript-estree/-/typescript-estree-6.12.0.tgz#764ccc32598549e5b48ec99e3b85f89b1385310c"
integrity sha512-vw9E2P9+3UUWzhgjyyVczLWxZ3GuQNT7QpnIY3o5OMeLO/c8oHljGc8ZpryBMIyympiAAaKgw9e5Hl9dCWFOYw==
dependencies:
"@typescript-eslint/types" "6.11.0"
"@typescript-eslint/visitor-keys" "6.11.0"
"@typescript-eslint/types" "6.12.0"
"@typescript-eslint/visitor-keys" "6.12.0"
debug "^4.3.4"
globby "^11.1.0"
is-glob "^4.0.3"
Expand All @@ -2494,25 +2494,25 @@
semver "^7.5.4"
ts-api-utils "^1.0.1"

"@typescript-eslint/utils@6.11.0":
version "6.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.11.0.tgz#11374f59ef4cea50857b1303477c08aafa2ca604"
integrity sha512-p23ibf68fxoZy605dc0dQAEoUsoiNoP3MD9WQGiHLDuTSOuqoTsa4oAy+h3KDkTcxbbfOtUjb9h3Ta0gT4ug2g==
"@typescript-eslint/utils@6.12.0":
version "6.12.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/utils/-/utils-6.12.0.tgz#c6ce8c06fe9b0212620e5674a2036f6f8f611754"
integrity sha512-LywPm8h3tGEbgfyjYnu3dauZ0U7R60m+miXgKcZS8c7QALO9uWJdvNoP+duKTk2XMWc7/Q3d/QiCuLN9X6SWyQ==
dependencies:
"@eslint-community/eslint-utils" "^4.4.0"
"@types/json-schema" "^7.0.12"
"@types/semver" "^7.5.0"
"@typescript-eslint/scope-manager" "6.11.0"
"@typescript-eslint/types" "6.11.0"
"@typescript-eslint/typescript-estree" "6.11.0"
"@typescript-eslint/scope-manager" "6.12.0"
"@typescript-eslint/types" "6.12.0"
"@typescript-eslint/typescript-estree" "6.12.0"
semver "^7.5.4"

"@typescript-eslint/visitor-keys@6.11.0":
version "6.11.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.11.0.tgz#d991538788923f92ec40d44389e7075b359f3458"
integrity sha512-+SUN/W7WjBr05uRxPggJPSzyB8zUpaYo2hByKasWbqr3PM8AXfZt8UHdNpBS1v9SA62qnSSMF3380SwDqqprgQ==
"@typescript-eslint/visitor-keys@6.12.0":
version "6.12.0"
resolved "https://registry.yarnpkg.com/@typescript-eslint/visitor-keys/-/visitor-keys-6.12.0.tgz#5877950de42a0f3344261b7a1eee15417306d7e9"
integrity sha512-rg3BizTZHF1k3ipn8gfrzDXXSFKyOEB5zxYXInQ6z0hUvmQlhaZQzK+YmHmNViMA9HzW5Q9+bPPt90bU6GQwyw==
dependencies:
"@typescript-eslint/types" "6.11.0"
"@typescript-eslint/types" "6.12.0"
eslint-visitor-keys "^3.4.1"

"@typescript-eslint/[email protected]":
Expand Down
Loading