Skip to content

Commit

Permalink
chore: move shared components
Browse files Browse the repository at this point in the history
  • Loading branch information
gaboesquivel committed Apr 8, 2024
1 parent 090356b commit 02a2464
Show file tree
Hide file tree
Showing 10 changed files with 28 additions and 30 deletions.
10 changes: 5 additions & 5 deletions apps/masterbots.ai/app/(browse)/[category]/[threadId]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { getCategories, getMessagePairs, getThread } from '@/services/hasura'

import type { ChatPageProps } from '@/app/c/[chatbot]/[threadId]/page'
import Shortlink from '@/components/routes/browse/shortlink-button'
import Shortlink from '@/components/shared/shortlink-button'
import { ThreadAccordion } from '@/components/shared/thread-accordion'
import { BrowseCategoryTabs } from '@/components/routes/browse/browse-category-tabs'
import { BrowseSearchInput } from '@/components/routes/browse/browse-search-input'
import { CategoryTabs } from '@/components/shared/category-tabs/category-tabs'
import { BrowseInput } from '@/components/shared/browse-input'

export default async function ThreadLandingPage({ params }: ChatPageProps) {
const categories = await getCategories()
Expand All @@ -15,8 +15,8 @@ export default async function ThreadLandingPage({ params }: ChatPageProps) {

return (
<div className="container">
<BrowseCategoryTabs categories={categories} />
<BrowseSearchInput />
<CategoryTabs categories={categories} />
<BrowseInput />
<Shortlink />
<ThreadAccordion
thread={thread}
Expand Down
11 changes: 4 additions & 7 deletions apps/masterbots.ai/app/(browse)/[category]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ThreadList from '@/components/shared/thread-list'
import { BrowseCategoryTabs } from '@/components/routes/browse/browse-category-tabs'
import { BrowseSearchInput } from '@/components/routes/browse/browse-search-input'
import { CategoryTabs } from '@/components/shared/category-tabs/category-tabs'
import { BrowseInput } from '@/components/shared/browse-input'
import { getBrowseThreads, getCategories } from '@/services/hasura'

export const revalidate = 3600 // revalidate the data at most every hour
Expand All @@ -25,11 +25,8 @@ export default async function BrowseCategoryPage({

return (
<div className="container">
<BrowseCategoryTabs
categories={categories}
initialCategory={params.category}
/>
<BrowseSearchInput />
<CategoryTabs categories={categories} initialCategory={params.category} />
<BrowseInput />
<ThreadList initialThreads={threads} filter={{ categoryId }} />
</div>
)
Expand Down
8 changes: 4 additions & 4 deletions apps/masterbots.ai/app/(browse)/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import ThreadList from '@/components/shared/thread-list'
import { BrowseCategoryTabs } from '@/components/routes/browse/browse-category-tabs'
import { BrowseSearchInput } from '@/components/routes/browse/browse-search-input'
import { CategoryTabs } from '@/components/shared/category-tabs/category-tabs'
import { BrowseInput } from '@/components/shared/browse-input'
import { getBrowseThreads, getCategories } from '@/services/hasura'

export default async function BrowsePage() {
Expand All @@ -10,8 +10,8 @@ export default async function BrowsePage() {
})
return (
<div className="container">
<BrowseCategoryTabs categories={categories} />
<BrowseSearchInput />
<CategoryTabs categories={categories} />
<BrowseInput />
<ThreadList initialThreads={threads} filter={{}} />
</div>
)
Expand Down
8 changes: 4 additions & 4 deletions apps/masterbots.ai/app/b/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import { getChatbot, getBrowseThreads, getCategories } from '@/services/hasura'
import { botNames } from '@/lib/bots-names'
import ThreadList from '@/components/shared/thread-list'
import AccountDetails from '@/components/shared/account-details'
import { BrowseCategoryTabs } from '@/components/routes/browse/browse-category-tabs'
import { BrowseSearchInput } from '@/components/routes/browse/browse-search-input'
import { CategoryTabs } from '@/components/shared/category-tabs/category-tabs'
import { BrowseInput } from '@/components/shared/browse-input'

export default async function BotThreadsPage({
params
Expand All @@ -27,8 +27,8 @@ export default async function BotThreadsPage({

return (
<div className=" container">
<BrowseCategoryTabs categories={categories} />
<BrowseSearchInput />
<CategoryTabs categories={categories} />
<BrowseInput />
<AccountDetails
href={`/b/${chatbot.name.toLowerCase()}`}
alt={chatbot.name}
Expand Down
8 changes: 4 additions & 4 deletions apps/masterbots.ai/app/u/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
} from '@/services/hasura'
import ThreadList from '@/components/shared/thread-list'
import AccountDetails from '@/components/shared/account-details'
import { BrowseCategoryTabs } from '@/components/routes/browse/browse-category-tabs'
import { BrowseSearchInput } from '@/components/routes/browse/browse-search-input'
import { CategoryTabs } from '@/components/shared/category-tabs/category-tabs'
import { BrowseInput } from '@/components/shared/browse-input'

export default async function BotThreadsPage({
params
Expand All @@ -22,8 +22,8 @@ export default async function BotThreadsPage({
})
return (
<div className="container">
<BrowseCategoryTabs categories={categories} />
<BrowseSearchInput />
<CategoryTabs categories={categories} />
<BrowseInput />
<AccountDetails
href={`/u/${params.slug}`}
alt={user.username}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { IconClose } from '@/components/ui/icons'
import { Input } from '@/components/ui/input'
import { useBrowse } from '@/hooks/use-browse'

export function BrowseSearchInput() {
export function BrowseInput() {
const { keyword, changeKeyword } = useBrowse()
return (
<div className="flex flex-col items-center justify-center w-full pt-10 pb-4 dark:bg-[#09090B] bg-[#F4F4F5] rounded-lg gap-4 px-4">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { motion } from 'framer-motion'
import type { Category } from '@repo/mb-genql'
import Link from 'next/link'

export function BrowseCategoryLink({
export function CategoryLink({
category,
activeTab,
onClick,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
import type { Category } from '@repo/mb-genql'
import { useEffect } from 'react'
import { useBrowse } from '@/hooks/use-browse'
import { BrowseCategoryLink } from './browse-category-link'
import { CategoryLink } from './category-link'

export function BrowseCategoryTabs({
export function CategoryTabs({
categories,
initialCategory = 'all'
}: {
Expand Down Expand Up @@ -46,7 +46,7 @@ export function BrowseCategoryTabs({

return (
<div className="w-full py-[10px] my-3 !overflow-x-auto overflow-y-hidden whitespace-nowrap scrollbar small-thumb justify-between flex">
<BrowseCategoryLink
<CategoryLink
activeTab={activeTab}
category="all"
id="browse-category-tab__null"
Expand All @@ -55,7 +55,7 @@ export function BrowseCategoryTabs({
}}
/>
{categories.map((category, key) => (
<BrowseCategoryLink
<CategoryLink
activeTab={activeTab}
category={category}
id={`browse-category-tab__${category.categoryId}`}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './category-tabs'

0 comments on commit 02a2464

Please sign in to comment.