Skip to content

Commit

Permalink
Merge pull request #121 from STAPLE-verse/remove-tsnocheck-warnings
Browse files Browse the repository at this point in the history
Remove tsnocheck warnings
  • Loading branch information
doomlab authored Jul 10, 2024
2 parents 5a0c8ac + 729fdb1 commit 5f1517e
Show file tree
Hide file tree
Showing 28 changed files with 121 additions and 128 deletions.
4 changes: 2 additions & 2 deletions src/core/components/SortableBox.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// @ts-nocheck
// dont need size in the second one will fix later
// dont need size in the second one will fix later: set to null to avoid the warning

import {
SortableContext,
Expand Down Expand Up @@ -36,6 +35,7 @@ export const SortableProjectBox = ({ boxes }) => {
<SortableContext items={boxes} strategy={rectSwappingStrategy}>
{boxes.map((boxes) => (
<Boxes
size={null}
key={boxes.id}
id={boxes.id}
title={boxes.title}
Expand Down
49 changes: 26 additions & 23 deletions src/core/components/navbar/MainNavbar.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// @ts-nocheck
//
// issue with element versus string

import Link from "next/link"
Expand All @@ -13,6 +13,30 @@ import { HomeIcon } from "@heroicons/react/24/outline"
import NotificationsMenu from "src/core/components/NotificationMenu"
import Image from "next/image"

type LogoProps = {
theme: string
}
const StapleLogo = ({ theme }: LogoProps) => {
const Themes = [
"dark",
"dracula",
"halloween",
"forest",
"luxury",
"business",
"night",
"coffee",
"dim",
"sunset",
]

return Themes.includes(theme) ? (
<Image src="/stapler_white.png" width={25} height={25} alt="Staple Logo" />
) : (
<Image src="/stapler_black.png" width={25} height={25} alt="Staple Logo" />
)
}

// MainNavbar
// Always present on the top of the page
// Includes non-project specific functionalities
Expand Down Expand Up @@ -57,33 +81,12 @@ const Navbar = () => {
}
}, [theme])

var logo = ""

if (
[
"dark",
"dracula",
"halloween",
"forest",
"luxury",
"business",
"night",
"coffee",
"dim",
"sunset",
].includes(theme)
) {
logo = <Image src="/stapler_white.png" width={25} height={25} alt="Staple Logo" />
} else {
logo = <Image src="/stapler_black.png" width={25} height={25} alt="Staple Logo" />
}

// return pages
return (
<div className="flex-0 navbar bg-base-100 sticky z-[1099] top-0 border-b border-gray-300 sm:px-4 md:px-6 lg:px-8 xl:px-10">
{/* Tabs */}
{/* On the left */}
<div className="flex-1">{logo}</div>
<div className="flex-1">{StapleLogo({ theme })}</div>
{/* On the right */}
<div className="flex space-x-5">
{/* Templated tabs tab */}
Expand Down
12 changes: 6 additions & 6 deletions src/elements/components/ElementDashboard.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-nocheck
// element dashboard assignees issue

import { useRouter } from "next/router"
Expand Down Expand Up @@ -130,7 +129,7 @@ export const PMElement = () => {
return task.schema !== null
})
if (allAssignments.length > 0) {
const allForms = allAssignments.flatMap((assignment) => assignment.assignees)
const allForms = allAssignments.flatMap((assignment) => assignment["assignees"])
const completedAssignments = allForms.filter(
(assignment) => assignment.statusLogs[0].status === "COMPLETED"
)
Expand All @@ -140,7 +139,8 @@ export const PMElement = () => {
}

const completedLabels = tasks.filter((task) => {
return task.labels.length > 0
const l = task.hasOwnProperty("labels") ? task["labels"].length : 0
return l > 0
})
labelPercent = completedLabels.length / tasks.length
} else {
Expand Down Expand Up @@ -171,7 +171,7 @@ export const PMElement = () => {
text={`${Math.round(taskPercent * 100)}%`}
styles={buildStyles({
textSize: "16px",
pathTransitionDuration: "none",
pathTransitionDuration: 0,
pathColor: "oklch(var(--p))",
textColor: "oklch(var(--s))",
trailColor: "oklch(var(--pc))",
Expand All @@ -196,7 +196,7 @@ export const PMElement = () => {
text={`${Math.round(formPercent * 100)}%`}
styles={buildStyles({
textSize: "16px",
pathTransitionDuration: "none",
pathTransitionDuration: 0,
pathColor: "oklch(var(--p))",
textColor: "oklch(var(--s))",
trailColor: "oklch(var(--pc))",
Expand All @@ -221,7 +221,7 @@ export const PMElement = () => {
text={`${Math.round(labelPercent * 100)}%`}
styles={buildStyles({
textSize: "16px",
pathTransitionDuration: "none",
pathTransitionDuration: 0,
pathColor: "oklch(var(--p))",
textColor: "oklch(var(--s))",
trailColor: "oklch(var(--pc))",
Expand Down
7 changes: 2 additions & 5 deletions src/forms/components/FormsTable.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
// @ts-nocheck
// issue with !.title

import React from "react"
import { Forms } from "db"

import { createColumnHelper } from "@tanstack/react-table"
import Link from "next/link"
import { Routes } from "@blitzjs/next"
import { JsonFormModal } from "src/core/components/JsonFormModal"
import { getSchemaTitle } from "src/services/getSchemaTitle"

// TODO: Is it better to call the database for column name every time or just one time and pass the value to child components?
// Column helper
Expand All @@ -16,7 +13,7 @@ const columnHelper = createColumnHelper<Forms>()
// ColumnDefs
export const formsTableColumns = [
columnHelper.accessor("schema", {
cell: (info) => <span>{info.getValue()!.title}</span>,
cell: (info) => <span>{getSchemaTitle(info.getValue())}</span>,
header: "Name",
}),
columnHelper.accessor("updatedAt", {
Expand Down
12 changes: 5 additions & 7 deletions src/forms/components/ProjectFormsTable.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
// @ts-nocheck
// issue with !.title

import Link from "next/link"
import { Routes } from "@blitzjs/next"
import { Prisma } from "@prisma/client"
import { Prisma, Task } from "@prisma/client"
import Table from "src/core/components/Table"
import getTasks from "src/tasks/queries/getTasks"
import { createColumnHelper } from "@tanstack/react-table"
import { useRouter } from "next/router"
import { usePaginatedQuery } from "@blitzjs/rpc"
import { useParam } from "@blitzjs/next"
import { useState, useEffect } from "react"
import { getSchemaTitle } from "src/services/getSchemaTitle"

const columnHelper = createColumnHelper<Forms>()
const columnHelper = createColumnHelper<Task>()
export const projectFormTableColumns = [
columnHelper.accessor("name", {
cell: (info) => <span>{info.getValue()}</span>,
header: "Task",
}),
columnHelper.accessor("schema", {
cell: (info) => <span> {info.getValue() ? info.getValue()!.title : ""}</span>,
cell: (info) => <span> {info.getValue() ? getSchemaTitle(info.getValue()) : ""}</span>,
header: "Form Required",
}),
columnHelper.accessor("id", {
Expand All @@ -31,9 +31,7 @@ export const projectFormTableColumns = [
className="btn btn-primary"
href={Routes.ShowFormPage({
taskId: info.getValue(),
// eslint-disable-next-line react-hooks/exhaustive-deps
// eslint-disable-next-line react-hooks/rules-of-hooks
projectId: useParam("projectId", "number"),
projectId: info.row.original.projectId,
})}
>
View
Expand Down
7 changes: 3 additions & 4 deletions src/forms/mutations/createForm.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
// @ts-nocheck
// issue with schema line?
import { resolver } from "@blitzjs/rpc"
import { CreateFormSchema } from "../schemas"
import db from "db"
import db, { Prisma } from "db"

export default resolver.pipe(
resolver.zod(CreateFormSchema),
resolver.authorize(),
async ({ userId, schema, uiSchema }) => {
const newSchema = schema != null ? schema : Prisma.JsonNull
const form = await db.forms.create({
data: {
schema,
schema: newSchema,
uiSchema,
user: {
connect: { id: userId },
Expand Down
14 changes: 9 additions & 5 deletions src/forms/mutations/updateForm.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,19 @@
// @ts-nocheck
// null not assignable to json null

import { resolver } from "@blitzjs/rpc"
import db from "db"
import db, { Prisma } from "db"
import { EditFormSchema } from "../schemas"

export default resolver.pipe(
resolver.zod(EditFormSchema),
resolver.authorize(),
async ({ id, ...data }) => {
const forms = await db.forms.update({ where: { id }, data })
const newSchema = data.schema != null ? data.schema : Prisma.JsonNull
const forms = await db.forms.update({
where: { id },
data: {
uiSchema: data.uiSchema,
schema: newSchema,
},
})

return forms
}
Expand Down
15 changes: 5 additions & 10 deletions src/labels/components/ContributorsLabelsList.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
// @ts-nocheck
// issue with label.user

import { useQuery } from "@blitzjs/rpc"
import { useRouter } from "next/router"
import getLabels from "../queries/getLabels"
import { LabelInformation, labelTableColumnsSimple } from "./LabelTable"
import { LabelInformation } from "./LabelTable"
import Table from "src/core/components/Table"

export const ContributorLabelsList = ({ usersId, projectId, columns }) => {
Expand All @@ -26,9 +23,10 @@ export const ContributorLabelsList = ({ usersId, projectId, columns }) => {
const description = label.description || ""
const taxonomy = label.taxonomy || ""

const userName = label.user.firstName
? `${label.user.firstName} ${label.user.lastName}`
: label.user.username
const user = label["user"]
const userName = user["firstName"]
? `${user["firstName"]} ${user["lastName"]}`
: user["username"]

let t: LabelInformation = {
name: name,
Expand All @@ -43,12 +41,9 @@ export const ContributorLabelsList = ({ usersId, projectId, columns }) => {
return t
})

//console.log(labels)

return (
<div>
<main className="flex flex-col mt-2 mx-auto w-full max-w-7xl">
{/* <h1 className="flex justify-center mb-2">All Contributors</h1> */}
<Table columns={columns} data={contributorLabelInformation} />
</main>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/labels/components/LabelTable.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-nocheck
import React, { useState } from "react"
import { createColumnHelper } from "@tanstack/react-table"
import Modal from "src/core/components/Modal"
Expand All @@ -19,6 +18,7 @@ export type LabelInformation = {
userId: number
onChangeCallback?: () => void
taxonomyList: string[]
userName?: string
}

const EditColumn = ({ row }) => {
Expand Down
12 changes: 7 additions & 5 deletions src/messages/hooks/useNotificationTable.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
// @ts-nocheck
import { Notification } from "db"
import { createColumnHelper } from "@tanstack/react-table"
import ReadToggle from "../components/ReadToggle"
import { useNotification } from "../components/NotificationContext"
import { useNotification, ExtendedNotification } from "../components/NotificationContext"
import { Project } from "db"

// Column helper
const columnHelper = createColumnHelper<Notification>()
const columnHelper = createColumnHelper<ExtendedNotification>()

const getProjectName = (project: Project) => {
return project ? project.name.substring(0, 20) : "N/A"
}

// ColumnDefs
export const useNotificationTableColumns = () => {
Expand All @@ -28,7 +31,6 @@ export const useNotificationTableColumns = () => {
),
header: "Date",
}),
// TODO: Define Notification with extended project because of include
columnHelper.accessor("projectId", {
id: "projectTitle",
header: "Project",
Expand Down
4 changes: 2 additions & 2 deletions src/pages/notifications/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { useNotificationTableColumns } from "src/messages/hooks/useNotificationT
const NotificationContent = () => {
// Get notifications
const { notifications, page, hasMore, goToPreviousPage, goToNextPage } = useNotification()
console.log(notifications)
// console.log(notifications)
// Get columns and pass refetch
const columns = useNotificationTableColumns()

Expand All @@ -19,7 +19,7 @@ const NotificationContent = () => {
</Head>
<main className="flex flex-col mt-2 mx-auto w-full max-w-7xl">
<h1 className="flex justify-center mb-2 text-3xl">All Notifications</h1>
<Table columns={columns} data={notifications} />
<Table columns={columns} data={extendeNotifications} />
<div className="join grid grid-cols-2 my-6">
<button
className="join-item btn btn-secondary"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @ts-nocheck
import { Suspense } from "react"
import { Routes } from "@blitzjs/next"
import Head from "next/head"
Expand Down Expand Up @@ -42,7 +41,9 @@ export const ContributorPage = () => {
})

const user = contributor[0].user
const teams = currentContributor.teams.map((team) => team.name)
const teams = currentContributor.hasOwnProperty("teams")
? currentContributor["teams"].map((team) => team.name)
: ""

const handleDelete = async () => {
if (
Expand Down
Loading

0 comments on commit 5f1517e

Please sign in to comment.