mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 15:48:32 -06:00
updating font
This commit is contained in:
34
nextjs/src/app/MyToaster.tsx
Normal file
34
nextjs/src/app/MyToaster.tsx
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
"use client";
|
||||||
|
import React from "react";
|
||||||
|
import { Toaster, ToastBar, useToaster } from "react-hot-toast";
|
||||||
|
|
||||||
|
export const MyToaster = () => {
|
||||||
|
const { toasts, handlers } = useToaster({ duration: Infinity });
|
||||||
|
const { startPause, endPause } = handlers;
|
||||||
|
|
||||||
|
return (
|
||||||
|
// <Toaster />
|
||||||
|
<Toaster
|
||||||
|
position="top-center"
|
||||||
|
reverseOrder={false}
|
||||||
|
// gutter={8}
|
||||||
|
containerClassName=" flex flex-row w-full "
|
||||||
|
containerStyle={{}}
|
||||||
|
toastOptions={{
|
||||||
|
className: "border-4 border-rose-900 drop-shadow-2xl grow",
|
||||||
|
duration: 5_000,
|
||||||
|
style: {
|
||||||
|
background: "#030712",
|
||||||
|
color: "#e5e7eb",
|
||||||
|
paddingLeft: "2em",
|
||||||
|
paddingRight: "2em",
|
||||||
|
width: "100%"
|
||||||
|
},
|
||||||
|
|
||||||
|
success: {
|
||||||
|
duration: 3000,
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
);
|
||||||
|
};
|
||||||
@@ -107,7 +107,7 @@ function DraggableListItem({
|
|||||||
e.dataTransfer.setData(
|
e.dataTransfer.setData(
|
||||||
"draggableItem",
|
"draggableItem",
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
type: "assignment",
|
type,
|
||||||
item,
|
item,
|
||||||
sourceModuleName: moduleName,
|
sourceModuleName: moduleName,
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&display=swap');
|
||||||
|
|
||||||
@tailwind base;
|
@tailwind base;
|
||||||
@tailwind components;
|
@tailwind components;
|
||||||
@tailwind utilities;
|
@tailwind utilities;
|
||||||
@@ -8,6 +10,10 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
:root {
|
||||||
|
font-family: "DM Sans", sans-serif;
|
||||||
|
}
|
||||||
|
|
||||||
/* monaco editor */
|
/* monaco editor */
|
||||||
.monaco-editor-background,
|
.monaco-editor-background,
|
||||||
.monaco-editor .margin {
|
.monaco-editor .margin {
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ import { Suspense } from "react";
|
|||||||
import { getQueryClient } from "./providersQueryClientUtils";
|
import { getQueryClient } from "./providersQueryClientUtils";
|
||||||
import { hydrateCourses } from "@/hooks/hookHydration";
|
import { hydrateCourses } from "@/hooks/hookHydration";
|
||||||
import { dehydrate, HydrationBoundary } from "@tanstack/react-query";
|
import { dehydrate, HydrationBoundary } from "@tanstack/react-query";
|
||||||
|
import { ToastBar, Toaster } from "react-hot-toast";
|
||||||
|
import { MyToaster } from "./MyToaster";
|
||||||
|
|
||||||
export const metadata: Metadata = {
|
export const metadata: Metadata = {
|
||||||
title: "Canvas Manager 2.0",
|
title: "Canvas Manager 2.0",
|
||||||
@@ -21,7 +23,20 @@ export default async function RootLayout({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<html lang="en">
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
</head>
|
||||||
<body className="bg-slate-900 h-screen p-1 text-slate-300">
|
<body className="bg-slate-900 h-screen p-1 text-slate-300">
|
||||||
|
{/* <Toaster
|
||||||
|
containerClassName=""
|
||||||
|
toastOptions={{
|
||||||
|
className: "bg-slate-900",
|
||||||
|
error: { duration: Infinity },
|
||||||
|
style: {
|
||||||
|
// backgroundColor: "black",
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
/> */}
|
||||||
|
<MyToaster />
|
||||||
<Suspense>
|
<Suspense>
|
||||||
<Providers>
|
<Providers>
|
||||||
<HydrationBoundary state={dehydratedState}>
|
<HydrationBoundary state={dehydratedState}>
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
useMutation,
|
useMutation,
|
||||||
} from "@tanstack/react-query";
|
} from "@tanstack/react-query";
|
||||||
import { useCourseContext } from "@/app/course/[courseName]/context/courseContext";
|
import { useCourseContext } from "@/app/course/[courseName]/context/courseContext";
|
||||||
|
import { axiosClient } from "@/services/axiosUtils";
|
||||||
|
|
||||||
export const getAssignmentNamesQueryConfig = (
|
export const getAssignmentNamesQueryConfig = (
|
||||||
courseName: string,
|
courseName: string,
|
||||||
@@ -22,7 +23,7 @@ export const getAssignmentNamesQueryConfig = (
|
|||||||
"/modules/" +
|
"/modules/" +
|
||||||
encodeURIComponent(moduleName) +
|
encodeURIComponent(moduleName) +
|
||||||
"/assignments";
|
"/assignments";
|
||||||
const response = await axios.get(url);
|
const response = await axiosClient.get(url);
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -53,7 +54,7 @@ export const getAssignmentQueryConfig = (
|
|||||||
encodeURIComponent(moduleName) +
|
encodeURIComponent(moduleName) +
|
||||||
"/assignments/" +
|
"/assignments/" +
|
||||||
encodeURIComponent(assignmentName);
|
encodeURIComponent(assignmentName);
|
||||||
const response = await axios.get(url);
|
const response = await axiosClient.get(url);
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -110,7 +111,7 @@ export const useUpdateAssignmentMutation = () => {
|
|||||||
encodeURIComponent(moduleName) +
|
encodeURIComponent(moduleName) +
|
||||||
"/assignments/" +
|
"/assignments/" +
|
||||||
encodeURIComponent(assignmentName);
|
encodeURIComponent(assignmentName);
|
||||||
await axios.put(url, assignment);
|
await axiosClient.put(url, assignment);
|
||||||
},
|
},
|
||||||
onSuccess: (_, { moduleName, assignmentName }) => {
|
onSuccess: (_, { moduleName, assignmentName }) => {
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import {
|
|||||||
} from "@tanstack/react-query";
|
} from "@tanstack/react-query";
|
||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { localCourseKeys } from "./localCourseKeys";
|
import { localCourseKeys } from "./localCourseKeys";
|
||||||
|
import { axiosClient } from "@/services/axiosUtils";
|
||||||
import {
|
import {
|
||||||
getAssignmentNamesQueryConfig,
|
getAssignmentNamesQueryConfig,
|
||||||
getAssignmentQueryConfig,
|
getAssignmentQueryConfig,
|
||||||
@@ -23,7 +24,7 @@ export const useLocalCourseNamesQuery = () =>
|
|||||||
queryKey: localCourseKeys.allCourses,
|
queryKey: localCourseKeys.allCourses,
|
||||||
queryFn: async (): Promise<string[]> => {
|
queryFn: async (): Promise<string[]> => {
|
||||||
const url = `/api/courses`;
|
const url = `/api/courses`;
|
||||||
const response = await axios.get(url);
|
const response = await axiosClient.get(url);
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -34,7 +35,7 @@ export const useLocalCourseSettingsQuery = () => {
|
|||||||
queryKey: localCourseKeys.settings(courseName),
|
queryKey: localCourseKeys.settings(courseName),
|
||||||
queryFn: async (): Promise<LocalCourseSettings> => {
|
queryFn: async (): Promise<LocalCourseSettings> => {
|
||||||
const url = `/api/courses/${courseName}/settings`;
|
const url = `/api/courses/${courseName}/settings`;
|
||||||
const response = await axios.get(url);
|
const response = await axiosClient.get(url);
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -46,7 +47,7 @@ export const useModuleNamesQuery = () => {
|
|||||||
queryKey: localCourseKeys.moduleNames(courseName),
|
queryKey: localCourseKeys.moduleNames(courseName),
|
||||||
queryFn: async (): Promise<string[]> => {
|
queryFn: async (): Promise<string[]> => {
|
||||||
const url = `/api/courses/${courseName}/modules`;
|
const url = `/api/courses/${courseName}/modules`;
|
||||||
const response = await axios.get(url);
|
const response = await axiosClient.get(url);
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -185,7 +186,7 @@ export const useAllCourseDataQuery = () => {
|
|||||||
// previousCourse: LocalCourse;
|
// previousCourse: LocalCourse;
|
||||||
// }) => {
|
// }) => {
|
||||||
// const url = `/api/courses/${courseName}`;
|
// const url = `/api/courses/${courseName}`;
|
||||||
// await axios.put(url, body);
|
// await axiosClient.put(url, body);
|
||||||
// },
|
// },
|
||||||
// onSuccess: () => {
|
// onSuccess: () => {
|
||||||
// queryClient.invalidateQueries({
|
// queryClient.invalidateQueries({
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
import axios from "axios";
|
import axios from "axios";
|
||||||
import { localCourseKeys } from "./localCourseKeys";
|
import { localCourseKeys } from "./localCourseKeys";
|
||||||
import { useCourseContext } from "@/app/course/[courseName]/context/courseContext";
|
import { useCourseContext } from "@/app/course/[courseName]/context/courseContext";
|
||||||
|
import { axiosClient } from "@/services/axiosUtils";
|
||||||
|
|
||||||
export function getPageNamesQueryConfig(
|
export function getPageNamesQueryConfig(
|
||||||
courseName: string,
|
courseName: string,
|
||||||
@@ -23,7 +24,7 @@ export function getPageNamesQueryConfig(
|
|||||||
"/modules/" +
|
"/modules/" +
|
||||||
encodeURIComponent(moduleName) +
|
encodeURIComponent(moduleName) +
|
||||||
"/pages";
|
"/pages";
|
||||||
const response = await axios.get(url);
|
const response = await axiosClient.get(url);
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -68,7 +69,7 @@ export function getPageQueryConfig(
|
|||||||
"/pages/" +
|
"/pages/" +
|
||||||
encodeURIComponent(pageName);
|
encodeURIComponent(pageName);
|
||||||
try {
|
try {
|
||||||
const response = await axios.get(url);
|
const response = await axiosClient.get(url);
|
||||||
return response.data;
|
return response.data;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log("error getting page", e, url);
|
console.log("error getting page", e, url);
|
||||||
@@ -103,7 +104,7 @@ export const useUpdatePageMutation = () => {
|
|||||||
encodeURIComponent(moduleName) +
|
encodeURIComponent(moduleName) +
|
||||||
"/pages/" +
|
"/pages/" +
|
||||||
encodeURIComponent(pageName);
|
encodeURIComponent(pageName);
|
||||||
await axios.put(url, page);
|
await axiosClient.put(url, page);
|
||||||
},
|
},
|
||||||
onSuccess: (_, { moduleName, pageName }) => {
|
onSuccess: (_, { moduleName, pageName }) => {
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
|
|||||||
@@ -6,9 +6,9 @@ import {
|
|||||||
useSuspenseQueries,
|
useSuspenseQueries,
|
||||||
useSuspenseQuery,
|
useSuspenseQuery,
|
||||||
} from "@tanstack/react-query";
|
} from "@tanstack/react-query";
|
||||||
import axios from "axios";
|
|
||||||
import { localCourseKeys } from "./localCourseKeys";
|
import { localCourseKeys } from "./localCourseKeys";
|
||||||
import { useCourseContext } from "@/app/course/[courseName]/context/courseContext";
|
import { useCourseContext } from "@/app/course/[courseName]/context/courseContext";
|
||||||
|
import { axiosClient } from "@/services/axiosUtils";
|
||||||
|
|
||||||
|
|
||||||
export function getQuizNamesQueryConfig(courseName: string, moduleName: string) {
|
export function getQuizNamesQueryConfig(courseName: string, moduleName: string) {
|
||||||
@@ -20,7 +20,7 @@ export function getQuizNamesQueryConfig(courseName: string, moduleName: string)
|
|||||||
"/modules/" +
|
"/modules/" +
|
||||||
encodeURIComponent(moduleName) +
|
encodeURIComponent(moduleName) +
|
||||||
"/quizzes";
|
"/quizzes";
|
||||||
const response = await axios.get(url);
|
const response = await axiosClient.get(url);
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -63,7 +63,7 @@ export function getQuizQueryConfig(
|
|||||||
encodeURIComponent(moduleName) +
|
encodeURIComponent(moduleName) +
|
||||||
"/quizzes/" +
|
"/quizzes/" +
|
||||||
encodeURIComponent(quizName);
|
encodeURIComponent(quizName);
|
||||||
const response = await axios.get(url);
|
const response = await axiosClient.get(url);
|
||||||
return response.data;
|
return response.data;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
@@ -93,7 +93,7 @@ export const useUpdateQuizMutation = () => {
|
|||||||
encodeURIComponent(moduleName) +
|
encodeURIComponent(moduleName) +
|
||||||
"/quizzes/" +
|
"/quizzes/" +
|
||||||
encodeURIComponent(quizName);
|
encodeURIComponent(quizName);
|
||||||
await axios.put(url, quiz);
|
await axiosClient.put(url, quiz);
|
||||||
},
|
},
|
||||||
onSuccess: (_, { moduleName, quizName }) => {
|
onSuccess: (_, { moduleName, quizName }) => {
|
||||||
queryClient.invalidateQueries({
|
queryClient.invalidateQueries({
|
||||||
|
|||||||
@@ -39,10 +39,16 @@ const settingsToMarkdown = (assignment: LocalAssignment) => {
|
|||||||
|
|
||||||
export const assignmentMarkdownSerializer = {
|
export const assignmentMarkdownSerializer = {
|
||||||
toMarkdown(assignment: LocalAssignment): string {
|
toMarkdown(assignment: LocalAssignment): string {
|
||||||
const settingsMarkdown = settingsToMarkdown(assignment);
|
try {
|
||||||
const rubricMarkdown = assignmentRubricToMarkdown(assignment);
|
const settingsMarkdown = settingsToMarkdown(assignment);
|
||||||
const assignmentMarkdown = `${settingsMarkdown}\n---\n\n${assignment.description}\n\n## Rubric\n\n${rubricMarkdown}`;
|
const rubricMarkdown = assignmentRubricToMarkdown(assignment);
|
||||||
|
const assignmentMarkdown = `${settingsMarkdown}\n---\n\n${assignment.description}\n\n## Rubric\n\n${rubricMarkdown}`;
|
||||||
|
|
||||||
return assignmentMarkdown;
|
return assignmentMarkdown;
|
||||||
|
} catch (e) {
|
||||||
|
console.log(assignment);
|
||||||
|
console.log("Error converting assignment to markdown");
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
27
nextjs/src/services/axiosUtils.ts
Normal file
27
nextjs/src/services/axiosUtils.ts
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import axios, { AxiosInstance, AxiosError } from "axios";
|
||||||
|
import toast from "react-hot-toast";
|
||||||
|
|
||||||
|
export const axiosClient: AxiosInstance = axios.create();
|
||||||
|
|
||||||
|
axiosClient.interceptors.response.use(
|
||||||
|
(response) => response,
|
||||||
|
(error: AxiosError) => {
|
||||||
|
if (error.response) {
|
||||||
|
console.log("response error", error.response);
|
||||||
|
const responseErrorText =
|
||||||
|
typeof error.response.data === "object"
|
||||||
|
? (error.response.data as any).error
|
||||||
|
: error.response.data;
|
||||||
|
toast.error(
|
||||||
|
`Error: ${error.response.status} - ${responseErrorText}, ${decodeURI(
|
||||||
|
error.response.config.url ?? ""
|
||||||
|
)}`
|
||||||
|
);
|
||||||
|
} else if (error.request) {
|
||||||
|
toast.error("Error: No response from server");
|
||||||
|
} else {
|
||||||
|
toast.error(`Error: ${error.message}`);
|
||||||
|
}
|
||||||
|
return Promise.reject(error);
|
||||||
|
}
|
||||||
|
);
|
||||||
Reference in New Issue
Block a user