Skip to content

Commit dcfec9c

Browse files
committed
Upload preview page + augment notes button
1 parent c338738 commit dcfec9c

File tree

47 files changed

+1396
-981
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+1396
-981
lines changed

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"Chatrooms",
55
"pipelinerun",
66
"Ragflow",
7+
"Sonner",
78
"supabase",
89
"taskrun",
910
"tekton",

app/api/document/[datasetId]/[documentId]/route.ts

Lines changed: 0 additions & 40 deletions
This file was deleted.

app/chatrooms/[chatroomId]/components/message-area.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
import { ChatClientWithSession } from "@shared/lib/ragflow/chat/chat-client";
44
import { UserContext } from "@shared/lib/userContext/userContext";
55
import { Skeleton } from "@shared/components/ui/skeleton";
6-
import { toast } from "@shared/hooks/use-toast";
76
import { createClient } from "@shared/utils/supabase/client";
87
import { Database, Tables } from "@shared/utils/supabase/database.types";
98
// import { revalidatePath } from "next/cache";
109
import Image from "next/image";
1110
import { useContext, useEffect, useState } from "react";
1211
import { askLLM } from "../../actions";
1312
import { createBrowserClient } from "@supabase/ssr";
13+
import { toast } from "sonner";
1414

1515
interface Message extends Tables<"Messages"> {
1616
user_id: string;
@@ -186,9 +186,7 @@ const MessageArea = ({
186186
},
187187
]);
188188
if (messageError) {
189-
toast({
190-
variant: "destructive",
191-
title: "Error sending message to chatroom",
189+
toast.error("Error sending message to chatroom", {
192190
description: "Please refresh and try again",
193191
});
194192
setMessageBoxValue("");
@@ -201,9 +199,7 @@ const MessageArea = ({
201199
if (!askResult.clientCreationSuccess) {
202200
if (!askResult.failedBecauseEmptyDataset) {
203201
// TODO: ask result has more detailed error differntiations if we want to tell the user
204-
toast({
205-
variant: "destructive",
206-
title: "Error sending communicating with LLM",
202+
toast.error("Error sending communicating with LLM", {
207203
description: "Please refresh and try again",
208204
});
209205
setChatClient(null); // In case client is bad, clear it out

app/classroom/[classroomId]/upload/preview/page.tsx

Lines changed: 0 additions & 17 deletions
This file was deleted.

app/classroom/page.tsx

Lines changed: 0 additions & 33 deletions
This file was deleted.
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
"use client";
2+
import { useState, useRef } from "react";
3+
4+
import { Button } from "@shared/components/ui/button";
5+
import { toast } from "sonner";
6+
import { Input } from "@shared/components/ui/input";
7+
8+
import { FileText, Upload } from "lucide-react";
9+
10+
export default function AugmentComponent({
11+
// TODO: remove when actually implementing augments
12+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
13+
classroomId,
14+
}: {
15+
classroomId: string;
16+
}) {
17+
// TODO: remove when actually implementing augments
18+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
19+
const [isProcessing, setIsProcessing] = useState(false);
20+
const [file, setFile] = useState<File | null>(null);
21+
const inputFile = useRef<HTMLInputElement>(null);
22+
23+
const handleFileChange = (event: React.ChangeEvent<HTMLInputElement>) => {
24+
const selectedFile = event.target.files?.[0];
25+
if (!selectedFile) return;
26+
27+
// Check if file is markdown or pdf
28+
if (
29+
!selectedFile.name.endsWith(".md") &&
30+
!selectedFile.name.endsWith(".pdf")
31+
) {
32+
toast.error("Invalid file format", {
33+
description: "Please upload a Markdown (.md) or PDF (.pdf) file"
34+
});
35+
return;
36+
}
37+
38+
setFile(selectedFile);
39+
};
40+
41+
const handleUpload = async () => {
42+
// TODO
43+
};
44+
45+
return (
46+
<div className="flex flex-col items-center justify-center gap-4 p-8">
47+
<h1 className="text-3xl font-bold">Augment Notes</h1>
48+
<p className="text-muted-foreground">
49+
Upload your notes to get AI-powered enhancements and improvements
50+
</p>
51+
<div className="flex items-center gap-2">
52+
<Input
53+
type="file"
54+
onChange={handleFileChange}
55+
ref={inputFile}
56+
className="hidden"
57+
accept=".md,.pdf"
58+
/>
59+
<Button
60+
variant="outline"
61+
size="lg"
62+
className="cursor-pointer"
63+
disabled={isProcessing}
64+
onClick={() => inputFile.current?.click()}
65+
>
66+
{isProcessing ? (
67+
<Upload className="mr-2 h-4 w-4 animate-spin" />
68+
) : (
69+
<FileText className="mr-2 h-4 w-4" />
70+
)}
71+
Upload Notes
72+
</Button>
73+
{file && (
74+
<Button
75+
variant="default"
76+
size="lg"
77+
onClick={handleUpload}
78+
disabled={isProcessing}
79+
>
80+
Process Notes
81+
</Button>
82+
)}
83+
</div>
84+
</div>
85+
);
86+
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import AugmentComponent from "./component";
2+
import { createClient } from "@shared/utils/supabase/server";
3+
4+
export default async function UploadPage({
5+
params,
6+
}: {
7+
params: Promise<{ classroomId: string }>;
8+
}) {
9+
const { classroomId } = await params;
10+
11+
const supabase = await createClient();
12+
const { data, error } = await supabase
13+
.from("Classrooms")
14+
.select("name")
15+
.eq("id", Number(classroomId))
16+
.single();
17+
18+
if (error || !data || !data.name) {
19+
console.error("Error fetching classroom or its name:", error);
20+
return <h1> Insert 404 page here</h1>;
21+
}
22+
23+
return (
24+
<>
25+
<h1>Classroom: {data.name}</h1>
26+
<AugmentComponent classroomId={classroomId} />
27+
</>
28+
);
29+
}

app/classroom/[classroomId]/chat/MessageBox.tsx renamed to app/classrooms/[classroomId]/chat/MessageBox.tsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
RagFlowMessages,
1616
sendMessage,
1717
} from "@shared/lib/ragflow/chat/chat-client";
18-
import { toast } from "@shared/hooks/use-toast";
18+
import { toast } from "sonner";
1919
import Logo from "@/shared/components/Logo";
2020
import { SendIcon } from "lucide-react";
2121
import ReactMarkdown from "react-markdown";
@@ -51,11 +51,9 @@ export default function MessageBox({
5151
setIsLoading(false);
5252

5353
if (!response.ragflowCallSuccess) {
54-
toast({
55-
title: "Error sending message",
56-
description: "Please try refreshing the page",
54+
toast.error("Error sending message", {
55+
description: `Please try refreshing the page`,
5756
duration: 10000,
58-
variant: "destructive",
5957
});
6058
return;
6159
}
@@ -106,6 +104,7 @@ export default function MessageBox({
106104
value={value}
107105
onChange={(e) => setValue(e.target.value)}
108106
placeholder="Type your message..."
107+
onEnter={handleSend}
109108
/>
110109
<Button
111110
onClick={handleSend}

app/classroom/[classroomId]/chat/page.tsx renamed to app/classrooms/[classroomId]/chat/page.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ export default async function ChatPage({
139139

140140
// // console.log("chatAssistant", chatAssistant);
141141
return (
142-
<div className="p-4 text-gray-800 dark:text-white">
142+
<div className="p-4">
143143
{/* <p>
144144
<strong>Classroom ID: </strong>
145145
{classroomId}

app/classroom/[classroomId]/manage/_components/inviteMember.tsx renamed to app/classrooms/[classroomId]/manage/_components/inviteMember.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
"use client";
22
import { useState } from "react";
33
import { inviteMemberToClassroom } from "../../../actions";
4-
import { toast } from "@shared/hooks/use-toast";
4+
import { toast } from "sonner";
55

66
export default function InviteMember({ classroomId }: { classroomId: number }) {
77
const [email, setEmail] = useState("");
88
const handleInvite = async () => {
99
try {
1010
await inviteMemberToClassroom(email, classroomId);
1111
setEmail("");
12-
toast({
13-
title: "Added Member Successfully",
12+
toast.success("Added Member Successfully", {
1413
description: `${email} was added to the class.`,
1514
});
1615
} catch (error: unknown) {
1716
//type unknown for typescript lint
1817
if (error instanceof Error) {
19-
toast({
20-
variant: "destructive",
21-
title: "The user is already part of the classroom.",
18+
toast.error(
19+
"The user is already part of the classroom."
2220
// description: { email } + "was added to the class.",
23-
});
21+
);
2422
// console.error(error.message);
2523
} else {
2624
console.error("Error Occured");

0 commit comments

Comments
 (0)