mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -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(
|
||||
"draggableItem",
|
||||
JSON.stringify({
|
||||
type: "assignment",
|
||||
type,
|
||||
item,
|
||||
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 components;
|
||||
@tailwind utilities;
|
||||
@@ -8,6 +10,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
:root {
|
||||
font-family: "DM Sans", sans-serif;
|
||||
}
|
||||
|
||||
/* monaco editor */
|
||||
.monaco-editor-background,
|
||||
.monaco-editor .margin {
|
||||
|
||||
@@ -5,6 +5,8 @@ import { Suspense } from "react";
|
||||
import { getQueryClient } from "./providersQueryClientUtils";
|
||||
import { hydrateCourses } from "@/hooks/hookHydration";
|
||||
import { dehydrate, HydrationBoundary } from "@tanstack/react-query";
|
||||
import { ToastBar, Toaster } from "react-hot-toast";
|
||||
import { MyToaster } from "./MyToaster";
|
||||
|
||||
export const metadata: Metadata = {
|
||||
title: "Canvas Manager 2.0",
|
||||
@@ -21,7 +23,20 @@ export default async function RootLayout({
|
||||
|
||||
return (
|
||||
<html lang="en">
|
||||
<head>
|
||||
</head>
|
||||
<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>
|
||||
<Providers>
|
||||
<HydrationBoundary state={dehydratedState}>
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
useMutation,
|
||||
} from "@tanstack/react-query";
|
||||
import { useCourseContext } from "@/app/course/[courseName]/context/courseContext";
|
||||
import { axiosClient } from "@/services/axiosUtils";
|
||||
|
||||
export const getAssignmentNamesQueryConfig = (
|
||||
courseName: string,
|
||||
@@ -22,7 +23,7 @@ export const getAssignmentNamesQueryConfig = (
|
||||
"/modules/" +
|
||||
encodeURIComponent(moduleName) +
|
||||
"/assignments";
|
||||
const response = await axios.get(url);
|
||||
const response = await axiosClient.get(url);
|
||||
return response.data;
|
||||
},
|
||||
});
|
||||
@@ -53,7 +54,7 @@ export const getAssignmentQueryConfig = (
|
||||
encodeURIComponent(moduleName) +
|
||||
"/assignments/" +
|
||||
encodeURIComponent(assignmentName);
|
||||
const response = await axios.get(url);
|
||||
const response = await axiosClient.get(url);
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
@@ -110,7 +111,7 @@ export const useUpdateAssignmentMutation = () => {
|
||||
encodeURIComponent(moduleName) +
|
||||
"/assignments/" +
|
||||
encodeURIComponent(assignmentName);
|
||||
await axios.put(url, assignment);
|
||||
await axiosClient.put(url, assignment);
|
||||
},
|
||||
onSuccess: (_, { moduleName, assignmentName }) => {
|
||||
queryClient.invalidateQueries({
|
||||
|
||||
@@ -7,6 +7,7 @@ import {
|
||||
} from "@tanstack/react-query";
|
||||
import axios from "axios";
|
||||
import { localCourseKeys } from "./localCourseKeys";
|
||||
import { axiosClient } from "@/services/axiosUtils";
|
||||
import {
|
||||
getAssignmentNamesQueryConfig,
|
||||
getAssignmentQueryConfig,
|
||||
@@ -23,7 +24,7 @@ export const useLocalCourseNamesQuery = () =>
|
||||
queryKey: localCourseKeys.allCourses,
|
||||
queryFn: async (): Promise<string[]> => {
|
||||
const url = `/api/courses`;
|
||||
const response = await axios.get(url);
|
||||
const response = await axiosClient.get(url);
|
||||
return response.data;
|
||||
},
|
||||
});
|
||||
@@ -34,7 +35,7 @@ export const useLocalCourseSettingsQuery = () => {
|
||||
queryKey: localCourseKeys.settings(courseName),
|
||||
queryFn: async (): Promise<LocalCourseSettings> => {
|
||||
const url = `/api/courses/${courseName}/settings`;
|
||||
const response = await axios.get(url);
|
||||
const response = await axiosClient.get(url);
|
||||
return response.data;
|
||||
},
|
||||
});
|
||||
@@ -46,7 +47,7 @@ export const useModuleNamesQuery = () => {
|
||||
queryKey: localCourseKeys.moduleNames(courseName),
|
||||
queryFn: async (): Promise<string[]> => {
|
||||
const url = `/api/courses/${courseName}/modules`;
|
||||
const response = await axios.get(url);
|
||||
const response = await axiosClient.get(url);
|
||||
return response.data;
|
||||
},
|
||||
});
|
||||
@@ -185,7 +186,7 @@ export const useAllCourseDataQuery = () => {
|
||||
// previousCourse: LocalCourse;
|
||||
// }) => {
|
||||
// const url = `/api/courses/${courseName}`;
|
||||
// await axios.put(url, body);
|
||||
// await axiosClient.put(url, body);
|
||||
// },
|
||||
// onSuccess: () => {
|
||||
// queryClient.invalidateQueries({
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
import axios from "axios";
|
||||
import { localCourseKeys } from "./localCourseKeys";
|
||||
import { useCourseContext } from "@/app/course/[courseName]/context/courseContext";
|
||||
import { axiosClient } from "@/services/axiosUtils";
|
||||
|
||||
export function getPageNamesQueryConfig(
|
||||
courseName: string,
|
||||
@@ -23,7 +24,7 @@ export function getPageNamesQueryConfig(
|
||||
"/modules/" +
|
||||
encodeURIComponent(moduleName) +
|
||||
"/pages";
|
||||
const response = await axios.get(url);
|
||||
const response = await axiosClient.get(url);
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
@@ -68,7 +69,7 @@ export function getPageQueryConfig(
|
||||
"/pages/" +
|
||||
encodeURIComponent(pageName);
|
||||
try {
|
||||
const response = await axios.get(url);
|
||||
const response = await axiosClient.get(url);
|
||||
return response.data;
|
||||
} catch (e) {
|
||||
console.log("error getting page", e, url);
|
||||
@@ -103,7 +104,7 @@ export const useUpdatePageMutation = () => {
|
||||
encodeURIComponent(moduleName) +
|
||||
"/pages/" +
|
||||
encodeURIComponent(pageName);
|
||||
await axios.put(url, page);
|
||||
await axiosClient.put(url, page);
|
||||
},
|
||||
onSuccess: (_, { moduleName, pageName }) => {
|
||||
queryClient.invalidateQueries({
|
||||
|
||||
@@ -6,9 +6,9 @@ import {
|
||||
useSuspenseQueries,
|
||||
useSuspenseQuery,
|
||||
} from "@tanstack/react-query";
|
||||
import axios from "axios";
|
||||
import { localCourseKeys } from "./localCourseKeys";
|
||||
import { useCourseContext } from "@/app/course/[courseName]/context/courseContext";
|
||||
import { axiosClient } from "@/services/axiosUtils";
|
||||
|
||||
|
||||
export function getQuizNamesQueryConfig(courseName: string, moduleName: string) {
|
||||
@@ -20,7 +20,7 @@ export function getQuizNamesQueryConfig(courseName: string, moduleName: string)
|
||||
"/modules/" +
|
||||
encodeURIComponent(moduleName) +
|
||||
"/quizzes";
|
||||
const response = await axios.get(url);
|
||||
const response = await axiosClient.get(url);
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
@@ -63,7 +63,7 @@ export function getQuizQueryConfig(
|
||||
encodeURIComponent(moduleName) +
|
||||
"/quizzes/" +
|
||||
encodeURIComponent(quizName);
|
||||
const response = await axios.get(url);
|
||||
const response = await axiosClient.get(url);
|
||||
return response.data;
|
||||
},
|
||||
};
|
||||
@@ -93,7 +93,7 @@ export const useUpdateQuizMutation = () => {
|
||||
encodeURIComponent(moduleName) +
|
||||
"/quizzes/" +
|
||||
encodeURIComponent(quizName);
|
||||
await axios.put(url, quiz);
|
||||
await axiosClient.put(url, quiz);
|
||||
},
|
||||
onSuccess: (_, { moduleName, quizName }) => {
|
||||
queryClient.invalidateQueries({
|
||||
|
||||
@@ -39,10 +39,16 @@ const settingsToMarkdown = (assignment: LocalAssignment) => {
|
||||
|
||||
export const assignmentMarkdownSerializer = {
|
||||
toMarkdown(assignment: LocalAssignment): string {
|
||||
const settingsMarkdown = settingsToMarkdown(assignment);
|
||||
const rubricMarkdown = assignmentRubricToMarkdown(assignment);
|
||||
const assignmentMarkdown = `${settingsMarkdown}\n---\n\n${assignment.description}\n\n## Rubric\n\n${rubricMarkdown}`;
|
||||
try {
|
||||
const settingsMarkdown = settingsToMarkdown(assignment);
|
||||
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