-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5753a14
commit 86dec46
Showing
9 changed files
with
146 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 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,28 @@ | ||
'use client'; | ||
|
||
import React from 'react'; | ||
import { ClipLoader } from 'react-spinners'; | ||
|
||
const LoadingSpinner = () => { | ||
// スピナーのサイズや色をカスタマイズできます | ||
const size = 50; | ||
const color = '#123abc'; | ||
|
||
return ( | ||
<div className='spinner-container flex items-center justify-center min-h-screen'> | ||
<ClipLoader size={size} color={color} /> | ||
|
||
{/* スタイル */} | ||
<style jsx>{` | ||
.spinner-container { | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
height: 100vh; | ||
} | ||
`}</style> | ||
</div> | ||
); | ||
}; | ||
|
||
export default LoadingSpinner; |
This file contains 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 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,51 @@ | ||
import Image from 'next/image'; | ||
import { getServerSession } from 'next-auth'; | ||
|
||
import PurchasesDetailBook from '@/components/layouts/PurchasesDetailBook/PurchasesDetailBook'; | ||
import { getDetailBook } from '@/lib/microcms/client'; | ||
import { nextAuthOptions } from '@/lib/next-auth/option'; | ||
import type { BookType, Purchase, User } from '@/types/types'; | ||
|
||
export default async function ProfilePage() { | ||
const session = await getServerSession(nextAuthOptions); | ||
const user = session?.user as User; | ||
let purchasesDetailBooks: BookType[] = []; | ||
if (user) { | ||
const response = await fetch( | ||
`${process.env.NEXT_PUBLIC_API_URL}/purchases/${user.id}` | ||
); | ||
const purchasesData = await response.json(); | ||
purchasesDetailBooks = await Promise.all(purchasesData.map(async (purchase: Purchase) => { | ||
return await getDetailBook(purchase.bookId); | ||
})); | ||
} | ||
return ( | ||
<div className='container mx-auto p-4'> | ||
<h1 className='text-xl font-bold mb-4'>プロフィール</h1> | ||
|
||
<div className='bg-white shadow-md rounded p-4'> | ||
<div className='flex items-center'> | ||
<Image | ||
priority | ||
src={user.image || '/default_icon.png'} | ||
alt='' | ||
width={60} | ||
height={60} | ||
className='rounded-t-md' | ||
/> | ||
<h2 className='text-lg ml-4 font-semibold'>お名前:{user.name}</h2> | ||
</div> | ||
</div> | ||
|
||
<span className='font-medium text-lg mb-4 mt-4 block'>購入した記事</span> | ||
<div className='flex items-center gap-6'> | ||
{purchasesDetailBooks.map((purchasesDetailBook: BookType) => ( | ||
<PurchasesDetailBook | ||
key={purchasesDetailBook.id} | ||
PurchasesDetailBook={purchasesDetailBook} | ||
/> | ||
))} | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains 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
34 changes: 34 additions & 0 deletions
34
src/components/layouts/PurchasesDetailBook/PurchasesDetailBook.tsx
This file contains 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,34 @@ | ||
import Image from 'next/image'; | ||
import Link from 'next/link'; | ||
import React from 'react'; | ||
|
||
import type { BookType } from '@/types/types'; | ||
|
||
type PurchasesDetailBookprops = { | ||
PurchasesDetailBook: BookType; | ||
} | ||
|
||
const PurchasesDetailBook = ({ PurchasesDetailBook }: PurchasesDetailBookprops) => { | ||
return ( | ||
<Link | ||
href={`/book/${PurchasesDetailBook.id}`} | ||
className='cursor-pointer shadow-2xl duration-300 hover:translate-y-1 hover:shadow-none' | ||
> | ||
<Image | ||
priority | ||
src={PurchasesDetailBook.thumbnail.url} | ||
alt={PurchasesDetailBook.title} | ||
width={450} | ||
height={350} | ||
className='rounded-t-md' | ||
/> | ||
<div className='px-4 py-4 bg-slate-100 rounded-b-md'> | ||
<h2 className='text-lg font-semibold'></h2> | ||
{/* <p className="mt-2 text-lg text-slate-600">この本は○○...</p> */} | ||
<p className='mt-2 text-md text-slate-700'>値段:{PurchasesDetailBook.price}円</p> | ||
</div> | ||
</Link> | ||
); | ||
}; | ||
|
||
export default PurchasesDetailBook; |