Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixing typescript errors from the previous improvements added #154

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion prisma/schema.prisma
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
generator client {
provider = "prisma-client-js"
binaryTargets = ["native", "linux-musl-arm64-openssl-3.0.x"]
output = "../node_modules/.prisma/client"
output = "../node_modules/.prisma/client"
}

datasource db {
Expand Down Expand Up @@ -58,6 +58,8 @@ model Ticket {
usersInGroup User[] @relation("groupTickets")
PersonalQueue PersonalQueue? @relation(fields: [personalQueueName], references: [name])
ticketType TicketType @default(DEBUGGING)
template String @default("")
isOnline Boolean @default(false)

helpedByUserId String?
createdByUserId String
Expand Down
17 changes: 12 additions & 5 deletions src/components/admin/AdminList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
} from "@chakra-ui/react";
import { Assignment, Category, Location } from "@prisma/client";
import { CreatableSelect } from "chakra-react-select";
import { useState } from "react";
import { useState, useEffect } from "react";
import { trpc } from "../../utils/trpc";
import AdminCard from "./AdminCard";

Expand All @@ -26,7 +26,7 @@ interface AdminListProps {
const AdminList = (props: AdminListProps) => {
const { assignmentsOrLocationsProps, isAssignment } = props;
const [assignmentsOrLocations, setAssignmentsOrLocations] = useState<
Assignment[] | Location[]
(Assignment | Location)[]
>(assignmentsOrLocationsProps);
const [createText, setCreateText] = useState<string>("");
const [isHiddenVisible, setIsHiddenVisible] = useState<boolean>(false);
Expand All @@ -43,9 +43,16 @@ const AdminList = (props: AdminListProps) => {
const editLocationMutation = trpc.admin.editLocation.useMutation();
const createCategoryMutation = trpc.admin.createCategory.useMutation();

const [numVisible, setNumVisible] = useState(
assignmentsOrLocations.filter((a) => !a?.isHidden).length
);
const [numVisible, setNumVisible] = useState(0);

useEffect(() => {
const hiddenAssignmentsOrLocations = (assignmentsOrLocations as (Assignment | Location)[]).filter(
(a) => !a?.isHidden
);
setNumVisible(
(hiddenAssignmentsOrLocations as (Assignment | Location)[]).length
);
}, [assignmentsOrLocations]);

const changeNumVisible = (delta: number) => {
setNumVisible(numVisible + delta);
Expand Down
2 changes: 1 addition & 1 deletion src/components/layout/AvatarDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const AvatarDropdown = () => {
<Center>
{session?.user?.name || session?.user?.preferredName ? (
<NameAndPronunciationPopoverForm
name={name}
name={name ?? ""}
setName={setName}
pronunciation={pronunciation}
setPronunciation={setPronunciation}
Expand Down
4 changes: 2 additions & 2 deletions src/components/modals/EditTemplateModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const EditTemplateModal = (props: EditTemplateModalProps) => {
<ModalCloseButton />
<ModalBody>
<Text>
Include "[this test]" or "[this concept]" as mandatory placeholders for students to fill.
Include &quot;[this test]&quot; or &quot;[this concept]&quot; as mandatory placeholders for students to fill.
</Text>
<Textarea
value={tempTemplate}
Expand All @@ -59,7 +59,7 @@ const EditTemplateModal = (props: EditTemplateModalProps) => {
colorScheme="blue"
mr={3}
onClick={() => {
handleConfirm(tempTemplate);
handleConfirm(tempTemplate ?? "");
setIsModalOpen(false);
}}
>
Expand Down
4 changes: 2 additions & 2 deletions src/components/queue/CreateTicketForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ const CreateTicketForm = (props: CreateTicketFormProps) => {
changeDescription(assignment, newVal);
};

const changeDescription = (assignment: Assignment | undefined, ticketType: TicketType) => {
const changeDescription = (assignment: Assignment | undefined, ticketType: TicketType | undefined) => {
if (assignment === undefined || assignment?.template === "") {
if (ticketType == TicketType.DEBUGGING) {
setDescription(STARTER_DEBUGGING_TICKET_DESCRIPTION);
Expand Down Expand Up @@ -228,7 +228,7 @@ const CreateTicketForm = (props: CreateTicketFormProps) => {
setLocation(undefined); // todo look at this
setAssignment(newVal ?? undefined);
refetch();
changeDescription(newVal, ticketType);
changeDescription(newVal ?? undefined, ticketType ?? undefined);
};

const onSubmit = async (e: React.FormEvent<HTMLFormElement>) => {
Expand Down