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

ドキュメント一覧ページを作成する #38

Open
wants to merge 16 commits into
base: main
Choose a base branch
from

Conversation

kazuma-naka
Copy link
Contributor

@kazuma-naka kazuma-naka commented Dec 12, 2024

Issue

1回目の提出

概要

  • docs テーブルの migration ファイルの作成
  • seed.sql に docs テーブルにデータを挿入するSQL構文の追加
  • Docs ページを作成
  • Docs ページにリストとページャーを設置

変更確認方法

  1. ブランチfeature/create-docs-listをローカルに取り込む
  2. npm run devでローカル環境を立ち上げる

変更前

agent_before_modify

変更後

top page

top_page

docs

docs_page

概要

  • docs テーブルの migration ファイルの作成
  • seed.sql に docs テーブルにデータを挿入するSQL構文の追加
  • Docs ページを作成
  • Docs ページにリストとページャーを設置
  • ページャー, ドキュメントリストはコンポネントとして作成
  • useDocs hook の作成

itemsPerPage で表示するドキュメント数を設定できるようにする

 <DocList itemsPerPage={2} />

変更確認方法

  1. ブランチfeature/create-docs-listをローカルに取り込む
  2. npm run devでローカル環境を立ち上げる

変更前

agent_before_modify

変更後

top page

top_page

docs

after_docs

@kazuma-naka kazuma-naka self-assigned this Dec 12, 2024
Copy link

vercel bot commented Dec 12, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
agent ❌ Failed (Inspect) Jan 8, 2025 0:38am

@kazuma-naka kazuma-naka requested a review from komagata December 12, 2024 17:31
import { useState, useEffect } from "react";
import supabase from "../../lib/supabase";

interface Doc {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DBにあるテーブルの型はsupabaseの機能で生成したものを使ってください。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

型を supabase の機能で生成したものに変更しました🖊

const [totalPages, setTotalPages] = useState(0);
const [loading, setLoading] = useState(true);

const fetchDocs = async (page: number) => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

テストしやすいようにページにはコンポーネントを置くだけの感じでお願いします〜。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

docs/page.tsx にコンポネントを置くだけに変更しました🖊

@@ -0,0 +1,9 @@
import SingleLayout from "@/components/layouts/SingleLayout";

export default function DashboardLayout({
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export default function DashboardLayout({
export default function DocsLayout({

の方がいいかも?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DocsLayout に修正しました🖊

<li>
<Link href="/dashboard">ダッシュボード</Link>
</li>
{links.map((link, index) => (
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

import supabase from "../lib/supabase";
import Pagination from "./Pagination";

interface Doc {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

これって自分で手書き定義しているからsupabaseの機能で生成した型を使っていることにならないかな〜と思います。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

type Doc = Tables<"docs">;

に変更しました🖊

https://supabase.com/docs/guides/api/rest/generating-types#type-shorthands

updated_at TIMESTAMP DEFAULT NOW(),
user_id INT NOT NULL,
last_updated_user_id INT NOT NULL
);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

最終行に改行を挿入しました🖊
またエディタの設定で最後に改行されるようにしました⚙

@kazuma-naka
Copy link
Contributor Author

@komagata さん、
こちらも修正が終わりましたので確認よろしくおねがいします。

@komagata
Copy link
Member

komagata commented Jan 8, 2025

これに対するcomponent test, e2e testの作成をお願いします。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants