-
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
Showing
7 changed files
with
89 additions
and
15 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
apps/web/src/app/dashboards/blogs/[blogId]/settings/page.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,23 @@ | ||
import { Stack, Typography } from '@mui/material'; | ||
import { notFound } from 'next/navigation'; | ||
import { getBlog } from '~/actions/blog'; | ||
import { getCurrentUser } from '~/actions/user'; | ||
import { generateWisblogMetadata } from '~/libs/generateWisblogMetadata'; | ||
|
||
export const metadata = generateWisblogMetadata({ title: '記事一覧' }); | ||
|
||
export default async function Page({ params }: { params: { blogId: string } }) { | ||
const { currentUser } = await getCurrentUser(); | ||
if (!currentUser) return null; | ||
|
||
const blog = await getBlog({ id: params.blogId }); | ||
|
||
if (!blog) return notFound(); | ||
|
||
return ( | ||
<Stack maxWidth={900} mx='auto' pt={2} pb={4} gap={3} px={2}> | ||
<Typography variant='h5'>ブログ設定</Typography> | ||
{/* */} | ||
</Stack> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { Stack, Typography } from '@mui/material'; | ||
import { CreateBlogForm } from '~/components/models/blog/CreateBlogForm'; | ||
import { EditBlogForm } from '~/components/models/blog/EditBlogForm'; | ||
|
||
export default function Page() { | ||
return ( | ||
<Stack maxWidth={600} mx='auto' pt={4} gap={3} px={2}> | ||
<Typography variant='h5'>新規作成</Typography> | ||
<CreateBlogForm /> | ||
<EditBlogForm /> | ||
</Stack> | ||
); | ||
} |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { EditBlogForm } from './EditBlogForm'; |
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,24 @@ | ||
import type { PrismaClient } from '@prisma/client'; | ||
import { BadRequest, type Blog } from '@repo/types'; | ||
|
||
export class CreateBlogUseCase { | ||
constructor(private readonly prismaClient: PrismaClient) {} | ||
|
||
async execute(args: Pick<Blog, 'name' | 'subDomain' | 'ownerId'>): Promise<{ createdBlog: Blog }> { | ||
const sameSubDomainBlog = await this.prismaClient.blog.findFirst({ | ||
where: { | ||
subDomain: args.subDomain, | ||
}, | ||
}); | ||
|
||
if (sameSubDomainBlog) { | ||
throw new BadRequest('同一のサブドメインのブログが存在します'); | ||
} | ||
|
||
const createdBlog = await this.prismaClient.blog.create({ | ||
data: args, | ||
}); | ||
|
||
return { createdBlog }; | ||
} | ||
} |