diff --git a/frontend/src/components/common/TabControl.tsx b/frontend/src/components/common/TabControl.tsx
deleted file mode 100644
index f805bd2..0000000
--- a/frontend/src/components/common/TabControl.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import React, { useEffect, useState } from 'react'
-
-type Props = { tabs: { [key: string]: React.ReactNode }
- init?: string }
-
-
-export default ({ tabs, init }: Props) => {
- const [current, setCurrent] = useState
(init
- ?? Object.keys (tabs)?.[0]
- ?? '')
-
- return (
- )
-}
diff --git a/frontend/src/components/common/TabGroup.tsx b/frontend/src/components/common/TabGroup.tsx
new file mode 100644
index 0000000..c4cab35
--- /dev/null
+++ b/frontend/src/components/common/TabGroup.tsx
@@ -0,0 +1,38 @@
+import React, { useState } from 'react'
+
+type TabProps = { name: string
+ init?: boolean
+ children: React.ReactNode }
+
+type Props = { children: React.ReactElement<{ name: string }>[] }
+
+export const Tab = ({ children }: TabProps) => children
+
+
+export default ({ children }: Props) => {
+ const tabs = React.Children.toArray (children)
+
+ const [current, setCurrent] = useState (() => {
+ const i = tabs.findIndex (tab => tab.props.init)
+ return i >= 0 ? i : 0
+ })
+
+ return (
+
+
+
+ {tabs[current]}
+
+
)
+}
diff --git a/frontend/src/pages/PostDetailPage.tsx b/frontend/src/pages/PostDetailPage.tsx
index 22d9d49..df20663 100644
--- a/frontend/src/pages/PostDetailPage.tsx
+++ b/frontend/src/pages/PostDetailPage.tsx
@@ -10,7 +10,7 @@ import { cn } from '@/lib/utils'
import MainArea from '@/components/layout/MainArea'
import TagDetailSidebar from '@/components/TagDetailSidebar'
import PostEditForm from '@/components/PostEditForm'
-import TabControl from '@/components/common/TabControl'
+import TabGroup, { Tab } from '@/components/common/TabGroup'
import type { Post, Tag, User } from '@/types'
@@ -95,14 +95,16 @@ export default ({ user }: Props) => {
post.viewed ? 'bg-blue-600 hover:bg-blue-700' : 'bg-gray-500 hover:bg-gray-600')}>
{post.viewed ? '閲覧済' : '未閲覧'}
- {(['admin', 'member'].includes (user.role) && editing) &&
- {
- setPost (newPost)
- toast ({ description: '更新しました.' })
- }} />) }} />}
+
+ {['admin', 'member'].some (r => r === user.role) && editing &&
+
+ {
+ setPost (newPost)
+ toast ({ description: '更新しました.' })
+ }} />
+ }
+