Skip to content

Commit 14ee814

Browse files
AnoukRImolaAndlerRLcoderabbitai[bot]
authored
Masterbots/fix redirects (#275)
* fix:avatar-redirects * fix:avatar-redirect * fix(masterbots.ai): upt components/ui/button.tsx Coderabbitai suggestion. Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix:URL correction --------- Co-authored-by: Roberto Lucas <andler@bitcash.org> Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
1 parent 469bb0b commit 14ee814

File tree

3 files changed

+45
-30
lines changed

3 files changed

+45
-30
lines changed

apps/masterbots.ai/components/routes/browse/browse-chatbot-details.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@ import Image from 'next/image'
33
import Link from 'next/link'
44
import { Separator } from '@/components/ui/separator'
55
import ShareLink from '@/components/routes/thread/thread-user-actions'
6+
import { toSlug } from 'mb-lib'
67

78
export default function BrowseChatbotDetails({
89
chatbot
910
}: {
1011
chatbot?: Chatbot
1112
}) {
13+
14+
if (!chatbot?.categories?.length) {
15+
return <div>No chatbot data available</div>
16+
}
17+
const primaryCategory = chatbot.categories[0].category
18+
const botUrl = `/c/${toSlug(primaryCategory.name)}/${chatbot.name.toLowerCase()}`
19+
1220
return (
1321
<div className="relative bg-cover py-10 bg-gradient-to-l from-mirage via-[#2B5D91] to-[#388DE2]">
1422
<div className="flex flex-row gap-3 relative mx-auto md:w-[600px]">
@@ -58,7 +66,7 @@ export default function BrowseChatbotDetails({
5866
<Link
5967
style={{ wordSpacing: '4px' }}
6068
className="text-[#388DE2]"
61-
href={`/b/${chatbot?.name.toLowerCase()}`}
69+
href={botUrl}
6270
>
6371
Chat with {chatbot?.name} &gt;
6472
</Link>

apps/masterbots.ai/components/routes/browse/browse-list-item.tsx

Lines changed: 33 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ import React from 'react'
1212
import { BrowseChatMessageList } from '@/components/routes/browse/browse-chat-message-list'
1313
import { ShortMessage } from '@/components/shared/short-message'
1414
import { IconOpenAI, IconUser } from '@/components/ui/icons'
15+
import { Button } from '@/components/ui/button'
16+
import { icons } from 'lucide-react'
17+
1518
let initialUrl: string | null = null
1619

1720
export default function BrowseListItem({
@@ -94,9 +97,16 @@ export default function BrowseListItem({
9497
const goToBotPage = (e: React.MouseEvent) => {
9598
e.preventDefault()
9699
e.stopPropagation()
97-
router.push(`/b/${thread.chatbot.name.trim().toLowerCase()}/${thread.threadId}`)
100+
router.push(`/b/${thread.chatbot.name.trim().toLowerCase()}`)
98101
}
99102

103+
const goToProfile = (e: React.MouseEvent) => {
104+
e.preventDefault()
105+
e.stopPropagation()
106+
if (thread.user?.slug) {
107+
router.push(`/u/${thread.user.slug}/t`)
108+
}
109+
}
100110

101111
return (
102112
<div ref={threadRef}>
@@ -121,12 +131,11 @@ export default function BrowseListItem({
121131
)}
122132
>
123133
{pageType !== 'bot' && thread.chatbot?.avatar ? (
124-
<div
134+
<Button
125135
onClick={goToBotPage}
126136
title={thread.chatbot?.name}
127-
className={cn(
128-
'flex size-8 shrink-0 select-none items-center justify-center rounded-full border shadow cursor-pointer'
129-
)}
137+
variant="icon"
138+
size="icon"
130139
>
131140
<Image
132141
className="transition-opacity duration-300 rounded-full select-none bg-background dark:bg-primary-foreground hover:opacity-80"
@@ -135,19 +144,17 @@ export default function BrowseListItem({
135144
height={32}
136145
width={32}
137146
/>
138-
</div>
147+
</Button>
139148
) : (
140149
pageType !== 'bot' && (
141-
<div
150+
<Button
142151
onClick={goToBotPage}
143152
title={thread.chatbot?.name}
144-
className={cn(
145-
'flex size-8 shrink-0 select-none items-center justify-center rounded-full border shadow cursor-pointer',
146-
'bg-primary text-primary-foreground'
147-
)}
153+
variant="icon"
154+
size="icon"
148155
>
149156
<IconOpenAI />
150-
</div>
157+
</Button>
151158
)
152159
)}
153160
<div className="w-[calc(100%-64px)] m:w-[calc(100%-28px)] flex items-center gap-3 text-left">
@@ -161,13 +168,13 @@ export default function BrowseListItem({
161168
{pageType !== 'user' && (
162169
<span className="opacity-50 text-[0.875rem]">by</span>
163170
)}
171+
<div>
164172
{pageType !== 'user' && thread.user?.profilePicture ? (
165-
<Link
166-
href={`/u/${encodeURIComponent(String(thread.user.slug))}`}
167-
title={thread.user?.username.replace('_', ' ')}
168-
className={cn(
169-
'flex size-8 shrink-0 select-none items-center justify-center rounded-full border shadow'
170-
)}
173+
<Button
174+
onClick={goToProfile}
175+
title={thread.user?.username.replace('_', ' ')}
176+
variant="icon"
177+
size="icon"
171178
>
172179
<Image
173180
className="transition-opacity duration-300 rounded-full select-none hover:opacity-80"
@@ -176,21 +183,20 @@ export default function BrowseListItem({
176183
height={32}
177184
width={32}
178185
/>
179-
</Link>
186+
</Button>
180187
) : (
181188
pageType !== 'user' && (
182-
<Link
183-
href={`/u/${encodeURIComponent(String(thread.user?.slug))}`}
184-
title={thread.user?.username}
185-
className={cn(
186-
'flex size-8 shrink-0 select-none items-center justify-center rounded-full border shadow',
187-
'bg-background'
188-
)}
189+
<Button
190+
onClick={goToProfile}
191+
title={thread.user?.username}
192+
variant="icon"
193+
size="icon"
189194
>
190195
<IconUser />
191-
</Link>
196+
</Button>
192197
)
193198
)}
199+
</div>
194200
</div>
195201
</div>
196202

apps/masterbots.ai/components/ui/button.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,14 @@ const buttonVariants = cva(
1818
secondary:
1919
'bg-secondary text-secondary-foreground hover:bg-secondary/80',
2020
ghost: 'shadow-none hover:bg-accent hover:text-accent-foreground',
21-
link: 'text-primary underline-offset-4 shadow-none hover:underline'
21+
link: 'text-primary underline-offset-4 shadow-none hover:underline',
22+
icon: 'flex size-8 shrink-0 select-none items-center justify-center rounded-full border shadow cursor-pointer'
2223
},
2324
size: {
2425
default: 'h-8 px-4 py-2',
2526
sm: 'h-8 rounded-md px-3',
2627
lg: 'h-11 rounded-md px-8',
27-
icon: 'h-8 w-8 p-0'
28+
icon: 'size-8 p-0'
2829
}
2930
},
3031
defaultVariants: {

0 commit comments

Comments
 (0)