-
Notifications
You must be signed in to change notification settings - Fork 0
関数にコメントを追加 #13
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
関数にコメントを追加 #13
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -3,6 +3,10 @@ import type { EventData, EventsResponse, Exclusion, HarvestQuest } from "../type | |||||||||||
|
|
||||||||||||
| const API_URL = import.meta.env.VITE_API_URL as string; | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * Cognito の idToken を Bearer トークンとして含む認証ヘッダーを生成する。 | ||||||||||||
| * すべての API リクエストの前処理として request() から呼び出される。 | ||||||||||||
| */ | ||||||||||||
| async function authHeaders(): Promise<Record<string, string>> { | ||||||||||||
| const session = await fetchAuthSession(); | ||||||||||||
| const token = session.tokens?.idToken?.toString() ?? ""; | ||||||||||||
|
|
@@ -12,6 +16,12 @@ async function authHeaders(): Promise<Record<string, string>> { | |||||||||||
| }; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * 認証ヘッダーを付けて管理 API へリクエストを送る汎用関数。 | ||||||||||||
| * レスポンスが ok でない場合はレスポンスボディを含むエラーをスローする。 | ||||||||||||
| * @param path API パス(VITE_API_URL からの相対パス) | ||||||||||||
| * @param init fetch の追加オプション(method, body など) | ||||||||||||
| */ | ||||||||||||
| async function request<T>(path: string, init?: RequestInit): Promise<T> { | ||||||||||||
| const headers = await authHeaders(); | ||||||||||||
| const res = await fetch(`${API_URL}${path}`, { | ||||||||||||
|
|
@@ -25,41 +35,60 @@ async function request<T>(path: string, init?: RequestInit): Promise<T> { | |||||||||||
| return res.json() as Promise<T>; | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** イベント一覧を取得する。 */ | ||||||||||||
| export function getEvents() { | ||||||||||||
| return request<EventsResponse>("/events"); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** イベントを新規作成する。作成されたイベント(eventId 付き)を返す。 */ | ||||||||||||
| export function createEvent(data: Omit<EventData, "eventId">) { | ||||||||||||
| return request<EventData>("/events", { | ||||||||||||
| method: "POST", | ||||||||||||
| body: JSON.stringify(data), | ||||||||||||
| }); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** | ||||||||||||
| * 指定イベントを更新する。更新後のイベントデータを返す。 | ||||||||||||
| * @param eventId 更新対象のイベント ID | ||||||||||||
| * @param data イベントデータ(eventId を除く) | ||||||||||||
| */ | ||||||||||||
| export function updateEvent(eventId: string, data: Omit<EventData, "eventId">) { | ||||||||||||
| return request<EventData>(`/events/${eventId}`, { | ||||||||||||
| method: "PUT", | ||||||||||||
| body: JSON.stringify(data), | ||||||||||||
| }); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** 指定イベントを削除する。 */ | ||||||||||||
|
||||||||||||
| /** 指定イベントを削除する。 */ | |
| /** | |
| * 指定イベントを削除する。 | |
| * @param eventId 削除対象のイベント ID | |
| */ |
Copilot
AI
Feb 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この関数は questId パラメータを持っていますが、@param タグがありません。一貫性のために @param questId クエスト ID を追加することを推奨します。
| /** 指定クエストの除外リストを取得する。 */ | |
| /** | |
| * 指定クエストの除外リストを取得する。 | |
| * @param questId クエスト ID | |
| */ |
Copilot
AI
Feb 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この関数は questId と exclusions のパラメータを持っていますが、@param タグがありません。一貫性のために @param questId クエスト ID と @param exclusions 除外リスト を追加することを推奨します。
| * 更新後の除外リストを返す。 | |
| * 更新後の除外リストを返す。 | |
| * @param questId クエスト ID | |
| * @param exclusions 除外リスト |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,10 +11,16 @@ interface AuthContextValue { | |||||||
|
|
||||||||
| const AuthContext = createContext<AuthContextValue>(null!); | ||||||||
|
|
||||||||
| /** 認証コンテキスト(isAuthenticated, username, login, logout など)を取得するカスタムフック。 */ | ||||||||
| export function useAuth() { | ||||||||
| return useContext(AuthContext); | ||||||||
| } | ||||||||
|
|
||||||||
| /** | ||||||||
| * AWS Amplify を使った認証状態を管理し、子コンポーネントに提供するプロバイダー。 | ||||||||
| * マウント時に getCurrentUser() で既存セッションを確認し、認証状態を初期化する。 | ||||||||
| * login / logout を AuthContext 経由で子コンポーネントに公開する。 | ||||||||
|
||||||||
| * login / logout を AuthContext 経由で子コンポーネントに公開する。 | |
| * login / logout を AuthContext 経由で子コンポーネントに公開する。 | |
| * @param children プロバイダー内でレンダリングする子要素 |
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -365,6 +365,11 @@ export function EventFormPage() { | |||||||||
|
|
||||||||||
| const SUFFIX_ORDER = ["", "+", "++", "+++", "\u2605", "\u2605\u2605", "\u2605\u2605\u2605"]; | ||||||||||
|
|
||||||||||
| /** | ||||||||||
| * クエストレベル文字列を比較用の [数値部分, サフィックス順序] タプルに変換する。 | ||||||||||
| * サフィックスは SUFFIX_ORDER の定義順("", "+", "++", ... , "★★★")で数値化する。 | ||||||||||
| * パターンにマッチしない場合は [0, 0] を返す。 | ||||||||||
|
||||||||||
| * パターンにマッチしない場合は [0, 0] を返す。 | |
| * パターンにマッチしない場合は [0, 0] を返す。 | |
| * @param level クエストレベル文字列 |
Copilot
AI
Feb 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この関数は a と b のパラメータを持っていますが、@param タグがありません。一貫性のために @param a 比較対象のクエスト(左辺) と @param b 比較対象のクエスト(右辺) を追加することを推奨します。
| * 数値が同じ場合はサフィックス("+" < "++" < "★" など)の定義順で比較する。 | |
| * 数値が同じ場合はサフィックス("+" < "++" < "★" など)の定義順で比較する。 | |
| * @param a 比較対象のクエスト(左辺) | |
| * @param b 比較対象のクエスト(右辺) |
Copilot
AI
Feb 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この関数は iso パラメータを持っていますが、@param タグがありません。一貫性のために @param iso ISO 形式の日時文字列 を追加することを推奨します。
| * API から取得した期間データをフォームに初期表示する際に使用する。 | |
| * API から取得した期間データをフォームに初期表示する際に使用する。 | |
| * @param iso ISO 形式の日時文字列 |
Copilot
AI
Feb 20, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この関数は localInput パラメータを持っていますが、@param タグがありません。一貫性のために @param localInput datetime-local 形式の入力値 を追加することを推奨します。
| * フォームの入力値を API へ送信するペイロードに変換する際に使用する。 | |
| * フォームの入力値を API へ送信するペイロードに変換する際に使用する。 | |
| * @param localInput datetime-local 形式の入力値 |
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -103,6 +103,7 @@ export function EventListPage() { | |||||||||||
| ); | ||||||||||||
| } | ||||||||||||
|
|
||||||||||||
| /** ISO 形式の日時文字列を日本時間のロケール文字列に変換する。 */ | ||||||||||||
|
||||||||||||
| /** ISO 形式の日時文字列を日本時間のロケール文字列に変換する。 */ | |
| /** | |
| * ISO 形式の日時文字列を日本時間のロケール文字列に変換する。 | |
| * @param iso ISO 形式の日時文字列 | |
| */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
この関数は
dataパラメータを持っていますが、@paramタグがありません。一貫性のために@param data イベントデータ(eventId を除く)を追加することを推奨します。