Skip to content

Commit 7c0141c

Browse files
committed
made nav changes
1 parent 78c5906 commit 7c0141c

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

app/classrooms/[classroomId]/chat/MessageBox.tsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
RagFlowMessages,
77
sendMessage,
88
} from "@shared/lib/ragflow/chat/chat-client";
9-
import { toast } from "@shared/hooks/use-toast";
9+
import { toast } from "sonner";
1010

1111
function MessageBox(props: {
1212
chatClient: ChatClientWithSession;
@@ -28,11 +28,10 @@ function MessageBox(props: {
2828
const messageResponse = await sendMessage(props.chatClient, value);
2929

3030
if (!messageResponse.ragflowCallSuccess) {
31-
toast({
32-
title: "Error sending message",
31+
toast.error("Error sending message",
32+
{
3333
description: `Please try refreshing the page`,
3434
duration: 10000,
35-
variant: "destructive",
3635
});
3736
return;
3837
}

app/classrooms/page.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ function ClassroomList({ userContext }: { userContext: UserContextType }) {
7676
const tab = searchParams.get("tab");
7777
if (tab && (tab == "enrolled" || tab == "admin")) {
7878
setCurrentTab(tab);
79+
}else{
80+
setCurrentTab("enrolled");
7981
}
8082
}, [searchParams]);
8183

@@ -285,7 +287,7 @@ function ClassroomList({ userContext }: { userContext: UserContextType }) {
285287
isAdmin: boolean;
286288
}) {
287289
return (
288-
<Card className="w-1/5" animated>
290+
<Card className="w-1/5 min-w-[300px]" animated>
289291
<CardHeader>
290292
<CardTitle animated>{classroom.name}</CardTitle>
291293
<CardDescription animated>
@@ -311,7 +313,7 @@ function ClassroomList({ userContext }: { userContext: UserContextType }) {
311313
asChild
312314
// className="me-2 rounded-lg border px-5 py-2.5 text-center text-sm font-medium hover:bg-green-800 hover:text-white focus:outline-none focus:ring-4 focus:ring-green-300 dark:border-green-500 dark:text-green-500 dark:hover:bg-green-600 dark:hover:text-white dark:focus:ring-green-900"
313315
>
314-
<Link href={`../chat/${classroom.id}`} passHref>
316+
<Link href={`/classrooms/${classroom.id}/chat`} passHref>
315317
<MessageSquareMore className="scale-[200%]" />{" "}
316318
</Link>
317319
</Button>
@@ -401,7 +403,7 @@ function ClassroomList({ userContext }: { userContext: UserContextType }) {
401403

402404
<Tabs
403405
value={currentTab}
404-
onValueChange={setCurrentTab}
406+
onValueChange={(value) => {window.history.replaceState(null, "", `/classrooms?tab=${value}`); setCurrentTab(value)}}
405407
defaultValue="enrolled"
406408
// className="w-[75vw] bg-"
407409
>
@@ -424,7 +426,7 @@ function ClassroomList({ userContext }: { userContext: UserContextType }) {
424426
<Separator className="my-4 mb-10" />
425427
<TabsContent value="admin">
426428
<div>
427-
<div className="flex flex-wrap justify-start gap-4">
429+
<div className="flex flex-wrap gap-4">
428430
{adminClasses.map((classroom) => (
429431
<ClassroomCard
430432
key={classroom.id}

app/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default function Home() {
3131
<div className="flex flex-col items-center gap-4 sm:flex-row">
3232
<a
3333
className="flex h-10 items-center justify-center gap-2 rounded-full border border-solid border-transparent bg-foreground px-4 text-sm text-background transition-colors hover:bg-[#383838] dark:hover:bg-[#ccc] sm:h-12 sm:px-5 sm:text-base"
34-
href="classroom"
34+
href="classrooms"
3535
>
3636
My classrooms
3737
</a>

shared/components/ui/sidebar/nav-utils.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { ReadonlyURLSearchParams } from "next/navigation";
2+
13
type PageStructure =
24
| PickOne<{
35
classroomLanding: PickOne<{
@@ -20,15 +22,18 @@ type PageStructure =
2022
| undefined;
2123

2224
// TODO: once structure is finalized, fix this
23-
export function getPageAspectsByPath(pathname: string): PageStructure {
25+
export function getPageAspectsByPath(pathname: string, searchParams: ReadonlyURLSearchParams): PageStructure {
2426
if (pathname == "/") {
2527
return undefined;
2628
}
2729

2830
const split = pathname.split("/");
2931

3032
if (pathname.includes("classroom") && split.length == 2) {
31-
// TODO: add admin separate
33+
const tab = searchParams.get("tab")
34+
if (tab && tab === "admin" ){
35+
return { classroomLanding: { admin: true } };
36+
}
3237
return { classroomLanding: { enrolled: true } };
3338
}
3439

0 commit comments

Comments
 (0)