mirror of
https://github.com/alexmickelson/canvasManagement.git
synced 2026-03-26 07:38:33 -06:00
trpc stuff
This commit is contained in:
@@ -8,6 +8,7 @@ import {
|
||||
getDateOnlyMarkdownString,
|
||||
} from "@/models/local/timeUtils";
|
||||
import { useAllCourseDataQuery } from "@/hooks/localCourse/localCourseModuleHooks";
|
||||
import { trpc } from "@/services/trpc/utils";
|
||||
|
||||
export default function CalendarItemsContextProvider({
|
||||
children,
|
||||
@@ -17,6 +18,9 @@ export default function CalendarItemsContextProvider({
|
||||
const { assignmentsAndModules, quizzesAndModules, pagesAndModules } =
|
||||
useAllCourseDataQuery();
|
||||
|
||||
|
||||
|
||||
|
||||
const assignmentsByModuleByDate = assignmentsAndModules.reduce(
|
||||
(previous, { assignment, moduleName }) => {
|
||||
const dueDay = getDateOnlyMarkdownString(
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
"use client";
|
||||
import { useAssignmentsQueries } from "@/hooks/localCourse/assignmentHooks";
|
||||
import { usePagesQueries } from "@/hooks/localCourse/pageHooks";
|
||||
import { IModuleItem } from "@/models/local/IModuleItem";
|
||||
import {
|
||||
@@ -13,13 +12,17 @@ import NewItemForm from "./NewItemForm";
|
||||
import { ModuleCanvasStatus } from "./ModuleCanvasStatus";
|
||||
import ClientOnly from "@/components/ClientOnly";
|
||||
import ExpandIcon from "../../../../components/icons/ExpandIcon";
|
||||
import { DraggableItem, useDraggingContext } from "../context/drag/draggingContext";
|
||||
import {
|
||||
DraggableItem,
|
||||
useDraggingContext,
|
||||
} from "../context/drag/draggingContext";
|
||||
import Link from "next/link";
|
||||
import { getModuleItemUrl } from "@/services/urlUtils";
|
||||
import { useCourseContext } from "../context/courseContext";
|
||||
import { Expandable } from "../../../../components/Expandable";
|
||||
import { useDragStyleContext } from "../context/drag/dragStyleContext";
|
||||
import { useItemsQueries } from "@/hooks/localCourse/courseItemHooks";
|
||||
import { useAssignmentsQuery } from "@/hooks/localCourse/assignmentHooks";
|
||||
|
||||
export default function ExpandableModule({
|
||||
moduleName,
|
||||
@@ -28,7 +31,7 @@ export default function ExpandableModule({
|
||||
}) {
|
||||
const { itemDropOnModule } = useDraggingContext();
|
||||
|
||||
const { data: assignments } = useAssignmentsQueries(moduleName);
|
||||
const [assignments] = useAssignmentsQuery(moduleName);
|
||||
const { data: quizzes } = useItemsQueries(moduleName, "Quiz");
|
||||
const { data: pages } = usePagesQueries(moduleName);
|
||||
const modal = useModal();
|
||||
|
||||
@@ -14,7 +14,9 @@ import {
|
||||
getDateFromString,
|
||||
getDateFromStringOrThrow,
|
||||
} from "@/models/local/timeUtils";
|
||||
import { trpc } from "@/services/trpc/utils";
|
||||
import React, { useState } from "react";
|
||||
import { useCourseContext } from "../context/courseContext";
|
||||
|
||||
export default function NewItemForm({
|
||||
moduleName: defaultModuleName,
|
||||
@@ -26,10 +28,15 @@ export default function NewItemForm({
|
||||
onCreate?: () => void;
|
||||
}) {
|
||||
const { data: settings } = useLocalCourseSettingsQuery();
|
||||
const { courseName } = useCourseContext();
|
||||
const { data: modules } = useModuleNamesQuery();
|
||||
const [type, setType] = useState<"Assignment" | "Quiz" | "Page">(
|
||||
"Assignment"
|
||||
);
|
||||
const assignmentCreationMutation = useCreateAssignmentMutation({
|
||||
courseName,
|
||||
moduleName: defaultModuleName ?? "",
|
||||
});
|
||||
|
||||
const [moduleName, setModuleName] = useState<string | undefined>(
|
||||
defaultModuleName
|
||||
@@ -50,12 +57,13 @@ export default function NewItemForm({
|
||||
const [assignmentGroup, setAssignmentGroup] =
|
||||
useState<LocalAssignmentGroup>();
|
||||
|
||||
const createAssignment = useCreateAssignmentMutation();
|
||||
const createPage = useCreatePageMutation();
|
||||
const createQuiz = useCreateItemMutation("Quiz");
|
||||
|
||||
const isPending =
|
||||
createAssignment.isPending || createPage.isPending || createQuiz.isPending;
|
||||
assignmentCreationMutation.isPending ||
|
||||
createPage.isPending ||
|
||||
createQuiz.isPending;
|
||||
|
||||
return (
|
||||
<form
|
||||
@@ -84,8 +92,22 @@ export default function NewItemForm({
|
||||
return;
|
||||
}
|
||||
if (type === "Assignment") {
|
||||
createAssignment.mutate({
|
||||
item: {
|
||||
// createAssignment.mutate({
|
||||
// item: {
|
||||
// name,
|
||||
// description: "",
|
||||
// localAssignmentGroupName: assignmentGroup?.name ?? "",
|
||||
// dueAt,
|
||||
// lockAt,
|
||||
// submissionTypes: settings.defaultAssignmentSubmissionTypes,
|
||||
// allowedFileUploadExtensions: settings.defaultFileUploadTypes,
|
||||
// rubric: [],
|
||||
// },
|
||||
// moduleName: moduleName,
|
||||
// itemName: name,
|
||||
// });
|
||||
assignmentCreationMutation.mutate({
|
||||
assignment: {
|
||||
name,
|
||||
description: "",
|
||||
localAssignmentGroupName: assignmentGroup?.name ?? "",
|
||||
@@ -96,7 +118,8 @@ export default function NewItemForm({
|
||||
rubric: [],
|
||||
},
|
||||
moduleName: moduleName,
|
||||
itemName: name,
|
||||
assignmentName: name,
|
||||
courseName,
|
||||
});
|
||||
} else if (type === "Quiz") {
|
||||
createQuiz.mutate({
|
||||
|
||||
@@ -27,7 +27,7 @@ export default function EditAssignment({
|
||||
const router = useRouter();
|
||||
const { courseName } = useCourseContext();
|
||||
const { data: settings } = useLocalCourseSettingsQuery();
|
||||
const { data: assignment } = useAssignmentQuery(moduleName, assignmentName);
|
||||
const [assignment] = useAssignmentQuery(moduleName, assignmentName);
|
||||
const updateAssignment = useUpdateAssignmentMutation();
|
||||
|
||||
const [assignmentText, setAssignmentText] = useState(
|
||||
|
||||
Reference in New Issue
Block a user