-
Notifications
You must be signed in to change notification settings - Fork 0
fix: address PR 793 review comments #796
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,19 +1,46 @@ | ||
| import i18n from "@/i18n"; | ||
|
|
||
| /** | ||
| * ISO 8601 形式の日付文字列を日本語ロケールの日付形式に変換する。 | ||
| * Converts an ISO 8601 date string to Japanese locale date format. | ||
| * 現在の i18n 言語に対応する BCP 47 ロケールタグを返す。 | ||
| * 日本語以外は `en-US` にフォールバックする(将来言語追加時の保守性のため)。 | ||
| * | ||
| * Returns a BCP 47 locale tag matching the current i18n language. | ||
| * Falls back to `en-US` for any non-`ja` language so adding new locales later | ||
| * does not silently render Japanese. | ||
| */ | ||
| export function getActiveLocale(): "ja-JP" | "en-US" { | ||
| const lang = i18n.language?.split("-")[0]; | ||
| if (lang === "ja") return "ja-JP"; | ||
| return "en-US"; | ||
| } | ||
|
|
||
| /** | ||
| * ISO 8601 形式の日付文字列を、現在の i18n ロケールに合わせた日付形式に変換する。 | ||
| * Converts an ISO 8601 date string to a date format matching the active i18n locale. | ||
| * | ||
| * @param iso - ISO 8601 形式の日付文字列 / ISO 8601 date string | ||
| * @returns 日本語形式(YYYY/MM/DD)の日付文字列。不正な入力の場合はそのまま返す。 | ||
| * Date string in Japanese format (YYYY/MM/DD). Returns input as-is for invalid input. | ||
| * @returns ロケール依存の日付文字列。不正な入力の場合はそのまま返す。 | ||
| * Locale-formatted date string. Returns input as-is for invalid input. | ||
| */ | ||
| export function formatDate(iso: string): string { | ||
| const date = new Date(iso); | ||
| if (Number.isNaN(date.getTime())) { | ||
| return iso; | ||
| } | ||
| return date.toLocaleDateString("ja-JP", { | ||
| return date.toLocaleDateString(getActiveLocale(), { | ||
| year: "numeric", | ||
| month: "2-digit", | ||
| day: "2-digit", | ||
| }); | ||
| } | ||
|
|
||
| /** | ||
| * 数値を現在の i18n ロケールの慣習で整形する(桁区切りなど)。 | ||
| * Formats a number using the active i18n locale (thousand separators, etc.). | ||
| * | ||
| * @param value - 数値 / numeric value | ||
| * @returns ロケール依存の数値文字列 / locale-formatted number string | ||
| */ | ||
| export function formatNumber(value: number): string { | ||
| return value.toLocaleString(getActiveLocale()); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,7 +17,7 @@ | |
| TableRow, | ||
| } from "@zedi/ui"; | ||
| import type { UserAdmin, UserRole, UserStatus } from "@/api/admin"; | ||
| import { formatDate } from "@/lib/dateUtils"; | ||
| import { formatDate, formatNumber, getActiveLocale } from "@/lib/dateUtils"; | ||
| import { ConfirmActionDialog } from "@/components/ConfirmActionDialog"; | ||
| import { UserCard } from "./UserCard"; | ||
| import { SuspendDialog } from "./SuspendDialog"; | ||
|
|
@@ -70,7 +70,7 @@ | |
| * @param props - Users, pagination, search, and action handlers | ||
| * @returns User management UI | ||
| */ | ||
| export function UsersContent({ | ||
|
Check warning on line 73 in admin/src/pages/users/UsersContent.tsx
|
||
| users, | ||
| total, | ||
| page, | ||
|
|
@@ -196,7 +196,7 @@ | |
| </Select> | ||
| </TableCell> | ||
| <TableCell className="text-muted-foreground px-3 py-2 tabular-nums"> | ||
| {u.pageCount.toLocaleString("ja-JP")} | ||
| {formatNumber(u.pageCount)} | ||
| </TableCell> | ||
| <TableCell className="text-muted-foreground px-3 py-2"> | ||
| {formatDate(u.createdAt)} | ||
|
|
@@ -386,7 +386,7 @@ | |
| <li> | ||
| {t("users.impact.lastAiUsage", { | ||
| date: new Date(confirm.deleteTarget.impact.lastAiUsageAt).toLocaleDateString( | ||
| "ja-JP", | ||
| getActiveLocale(), | ||
| ), | ||
|
Comment on lines
388
to
390
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
| })} | ||
| </li> | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
getActiveLocaleはformatDate内部で使用されており、コンポーネント側で直接呼び出す必要がなくなるため、インポートから削除できます。