Repository navigation
feat(grammar): 어법 노트 목록을 10개씩 조회하고 목록만 로딩 표시 #182
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
Yelihi
merged 2 commits into
main
from
fs/grammar-home-refresh-20261012/grammar-library
Oct 12, 2026
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
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 |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| import "server-only"; | ||
|
|
||
| export { requireUser } from "./services/requireUser"; | ||
| export { requireUser, requireUserOrRedirect } from "./services/requireUser"; |
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
20 changes: 20 additions & 0 deletions
20
src/views/grammar-library/services/server/getGrammarLibraryPage.ts
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 |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| import "server-only"; | ||
|
|
||
| import { GrammarNoteRepository } from "@/entities/grammar-note"; | ||
| import { requireUserOrRedirect } from "@/features/login/server"; | ||
| import { observeOperation } from "@/shared/lib/logging/observeOperation"; | ||
| import { recordOperationEvent } from "@/shared/lib/logging/pino"; | ||
| import { createSupabaseServerClient } from "@/shared/lib/supabase/server"; | ||
| import type { GrammarLibraryQuery } from "../../models/interface"; | ||
|
|
||
| export async function getGrammarLibraryPage(query: GrammarLibraryQuery) { | ||
| const supabase = await createSupabaseServerClient(); | ||
| await requireUserOrRedirect(supabase); | ||
|
|
||
| return observeOperation({ | ||
| operation: "grammar.list", | ||
| resourceId: "grammar-library", | ||
| recordEvent: recordOperationEvent, | ||
| execute: () => new GrammarNoteRepository(supabase).findMany({ ...query, pageSize: 10 }), | ||
| }).catch(() => null); | ||
| } |
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,31 +1,27 @@ | ||
| import { redirect } from "next/navigation"; | ||
| import { GrammarNoteRepository } from "@/entities/grammar-note"; | ||
| import { createSupabaseServerClient } from "@/shared/lib/supabase/server"; | ||
| import { observeOperation } from "@/shared/lib/logging/observeOperation"; | ||
| import { recordOperationEvent } from "@/shared/lib/logging/pino"; | ||
| import type { GrammarLibraryQuery } from "../models/interface"; | ||
| import { grammarLibraryHref } from "../services/libraryQuery"; | ||
| import { GrammarLibraryView } from "./GrammarLibraryView"; | ||
| import { getGrammarLibraryPage } from "../services/server/getGrammarLibraryPage"; | ||
| import { GrammarNoteList } from "./GrammarNoteList"; | ||
|
|
||
| export async function GrammarLibraryContent({ query }: { query: GrammarLibraryQuery }) { | ||
| const supabase = await createSupabaseServerClient(); | ||
| const { | ||
| data: { user }, | ||
| error, | ||
| } = await supabase.auth.getUser(); | ||
| const notePage = await getGrammarLibraryPage(query); | ||
|
|
||
| if (error || !user) redirect("/login"); | ||
|
|
||
| const data = await observeOperation({ | ||
| operation: "grammar.list", | ||
| resourceId: "grammar-library", | ||
| recordEvent: recordOperationEvent, | ||
|
|
||
| execute: () => new GrammarNoteRepository(supabase).findMany({ ...query, pageSize: 20 }), | ||
| }); | ||
| const page = Math.min(query.page, Math.max(1, Math.ceil(data.total / data.pageSize))); | ||
| if (!notePage) { | ||
| return ( | ||
| <section aria-label="어법 노트 목록" className="mx-auto max-w-4xl space-y-4"> | ||
| <p role="alert" className="text-practice-secondary"> | ||
| 어법 노트를 불러오지 못했습니다. 잠시 후 다시 시도해주세요. | ||
| </p> | ||
| <a href={grammarLibraryHref(query)} className="text-practice-accent underline"> | ||
| 다시 불러오기 | ||
| </a> | ||
| </section> | ||
| ); | ||
| } | ||
| const page = Math.min(query.page, Math.max(1, Math.ceil(notePage.total / notePage.pageSize))); | ||
|
|
||
| if (page !== query.page) redirect(grammarLibraryHref({ ...query, page })); | ||
|
|
||
| return <GrammarLibraryView data={data} query={query.query} />; | ||
| return <GrammarNoteList data={notePage} query={query.query} />; | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.