refactor: update type imports to use 'type' for better TypeScript compatibility across the codebase
This commit is contained in:
@@ -7,7 +7,7 @@ import { useForm } from "react-hook-form"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { signInAction } from "@/lib/actions/auth.actions"
|
||||
import { SignInFormType, signInSchema } from "@/lib/schemas/auth.schemas"
|
||||
import { type SignInFormType, signInSchema } from "@/lib/schemas/auth.schemas"
|
||||
|
||||
export default function SignInForm() {
|
||||
const router = useRouter()
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { UpdateAssignmentFormType } from "@/lib/schemas/assignment.schemas"
|
||||
import type { UpdateAssignmentFormType } from "@/lib/schemas/assignment.schemas"
|
||||
import type { Item } from "@/lib/types"
|
||||
import { AssetService } from "@/services/asset.service"
|
||||
import { AssignmentService } from "@/services/assignment.service"
|
||||
|
||||
@@ -8,10 +8,10 @@ import { toast } from "sonner"
|
||||
import { SubmitButton } from "@/components/forms/submitButton"
|
||||
import { updateAssignment } from "@/lib/actions/assignament.actions"
|
||||
import {
|
||||
UpdateAssignmentFormType,
|
||||
type UpdateAssignmentFormType,
|
||||
updateAssignmentSchema,
|
||||
} from "@/lib/schemas/assignment.schemas"
|
||||
import { Asset, Item, Recipient } from "@/lib/types"
|
||||
import type { Asset, Item, Recipient } from "@/lib/types"
|
||||
|
||||
interface Props {
|
||||
recipients: Recipient[]
|
||||
|
||||
@@ -9,10 +9,10 @@ import { toast } from "sonner"
|
||||
import { SubmitButton } from "@/components/forms/submitButton"
|
||||
import { createAssignment } from "@/lib/actions/assignament.actions"
|
||||
import {
|
||||
CreateAssignmentFormType,
|
||||
type CreateAssignmentFormType,
|
||||
createAssignmentSchema,
|
||||
} from "@/lib/schemas/assignment.schemas"
|
||||
import { Asset, Item, Recipient } from "@/lib/types"
|
||||
import type { Asset, Item, Recipient } from "@/lib/types"
|
||||
|
||||
interface Props {
|
||||
recipients: Recipient[]
|
||||
|
||||
@@ -7,7 +7,7 @@ import { toast } from "sonner"
|
||||
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { returnAssignment } from "@/lib/actions/assignament.actions"
|
||||
import { ReturnAssignmentFormType } from "@/lib/schemas/assignment.schemas"
|
||||
import type { ReturnAssignmentFormType } from "@/lib/schemas/assignment.schemas"
|
||||
|
||||
export default function ReturnButton({
|
||||
assignmentId,
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
|
||||
import { zodResolver } from "@hookform/resolvers/zod"
|
||||
import { useRouter } from "next/navigation"
|
||||
import { ChangeEvent } from "react"
|
||||
import type { ChangeEvent } from "react"
|
||||
import { useForm } from "react-hook-form"
|
||||
import { toast } from "sonner"
|
||||
|
||||
import { SubmitButton } from "@/components/forms/submitButton"
|
||||
import { importItems } from "@/lib/actions/import.actions"
|
||||
import { ImportFormType, importSchema } from "@/lib/schemas/import.schemas"
|
||||
import { CategorySummary } from "@/lib/types"
|
||||
import { type ImportFormType, importSchema } from "@/lib/schemas/import.schemas"
|
||||
import type { CategorySummary } from "@/lib/types"
|
||||
|
||||
export default function ImportForm({
|
||||
categories,
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
"use server"
|
||||
|
||||
import { AssetWithAssignment } from "@/lib/types"
|
||||
import type { AssetWithAssignment } from "@/lib/types"
|
||||
import { AssetService } from "@/services/asset.service"
|
||||
import { ItemService } from "@/services/item.service"
|
||||
import { RecipientService } from "@/services/recipient.service"
|
||||
|
||||
@@ -9,10 +9,10 @@ import { SubmitButton } from "@/components/forms/submitButton"
|
||||
import { ItemStatus } from "@/generated/prisma/client"
|
||||
import { updateAssetAction } from "@/lib/actions/asset.actions"
|
||||
import {
|
||||
UpdateAssetFormType,
|
||||
type UpdateAssetFormType,
|
||||
updateAssetSchema,
|
||||
} from "@/lib/schemas/asset.schemas"
|
||||
import {
|
||||
import type {
|
||||
AssetWithAssignment,
|
||||
Item,
|
||||
Recipient,
|
||||
|
||||
@@ -9,10 +9,10 @@ import { SubmitButton } from "@/components/forms/submitButton"
|
||||
import { ItemStatus } from "@/generated/prisma/client"
|
||||
import { createAssetAction } from "@/lib/actions/asset.actions"
|
||||
import {
|
||||
CreateAssetFormType,
|
||||
type CreateAssetFormType,
|
||||
createAssetSchema,
|
||||
} from "@/lib/schemas/asset.schemas"
|
||||
import { ItemWithoutStock, Recipient } from "@/lib/types"
|
||||
import type { ItemWithoutStock, Recipient } from "@/lib/types"
|
||||
|
||||
interface NewAssetFormProps {
|
||||
items: ItemWithoutStock[]
|
||||
|
||||
@@ -8,10 +8,10 @@ import { toast } from "sonner"
|
||||
import { SubmitButton } from "@/components/forms/submitButton"
|
||||
import { updateCategoryAction } from "@/lib/actions/category.actions"
|
||||
import {
|
||||
UpdateCategoryFormType,
|
||||
type UpdateCategoryFormType,
|
||||
updateCategorySchema,
|
||||
} from "@/lib/schemas/category.schemas"
|
||||
import { CategorySummary } from "@/lib/types"
|
||||
import type { CategorySummary } from "@/lib/types"
|
||||
|
||||
export default function EditCategoryForm({
|
||||
category,
|
||||
|
||||
@@ -8,7 +8,7 @@ import { toast } from "sonner"
|
||||
import { SubmitButton } from "@/components/forms/submitButton"
|
||||
import { createCategoryAction } from "@/lib/actions/category.actions"
|
||||
import {
|
||||
CreateCategoryFormType,
|
||||
type CreateCategoryFormType,
|
||||
createCategorySchema,
|
||||
} from "@/lib/schemas/category.schemas"
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ import { toast } from "sonner"
|
||||
import { SubmitButton } from "@/components/forms/submitButton"
|
||||
import { createItemAction } from "@/lib/actions/item.actions"
|
||||
import {
|
||||
CreateItemFormType,
|
||||
type CreateItemFormType,
|
||||
createItemSchema,
|
||||
} from "@/lib/schemas/item.schemas"
|
||||
import { CategorySummary } from "@/lib/types"
|
||||
import type { CategorySummary } from "@/lib/types"
|
||||
|
||||
export default function NewItemForm({
|
||||
categories,
|
||||
|
||||
@@ -8,10 +8,10 @@ import { toast } from "sonner"
|
||||
import { SubmitButton } from "@/components/forms/submitButton"
|
||||
import { updateItemAction } from "@/lib/actions/item.actions"
|
||||
import {
|
||||
UpdateItemFormType,
|
||||
type UpdateItemFormType,
|
||||
updateItemSchema,
|
||||
} from "@/lib/schemas/item.schemas"
|
||||
import { CategorySummary, ItemWithAssetCount } from "@/lib/types"
|
||||
import type { CategorySummary, ItemWithAssetCount } from "@/lib/types"
|
||||
|
||||
export default function UpdateItemForm({
|
||||
categories,
|
||||
|
||||
@@ -12,11 +12,11 @@ import {
|
||||
updateRecipient,
|
||||
} from "@/lib/actions/recipient.actions"
|
||||
import {
|
||||
CreateRecipientFormType,
|
||||
type CreateRecipientFormType,
|
||||
recipientSchema,
|
||||
UpdateRecipientFormType,
|
||||
type UpdateRecipientFormType,
|
||||
} from "@/lib/schemas/recipients.schemas"
|
||||
import { Recipient } from "@/lib/types"
|
||||
import type { Recipient } from "@/lib/types"
|
||||
|
||||
interface RecipientFormProps {
|
||||
initialData?: Recipient
|
||||
|
||||
@@ -4,7 +4,7 @@ import Link from "next/link"
|
||||
import PageHeader from "@/components/common/pageheader"
|
||||
import PaginationButtons from "@/components/common/pagination"
|
||||
import { Button } from "@/components/ui/button"
|
||||
import { Recipient } from "@/generated/prisma/client"
|
||||
import type { Recipient } from "@/generated/prisma/client"
|
||||
import { RecipientService } from "@/services/recipient.service"
|
||||
|
||||
export default async function RecipientsPage(props: {
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
import { ChevronRight } from "lucide-react"
|
||||
import Link from "next/link"
|
||||
import { usePathname } from "next/navigation"
|
||||
import React, { useEffect, useState } from "react"
|
||||
import type React from "react"
|
||||
import { useEffect, useState } from "react"
|
||||
|
||||
import {
|
||||
Collapsible,
|
||||
|
||||
@@ -7,9 +7,9 @@ import {
|
||||
updateAssignment,
|
||||
} from "@/lib/actions/assignament.actions"
|
||||
import {
|
||||
CreateAssetFormType,
|
||||
type CreateAssetFormType,
|
||||
createAssetSchema,
|
||||
UpdateAssetFormType,
|
||||
type UpdateAssetFormType,
|
||||
updateAssetSchema,
|
||||
} from "@/lib/schemas/asset.schemas"
|
||||
import { AssetService } from "@/services/asset.service"
|
||||
|
||||
@@ -11,9 +11,9 @@ import { MovementService } from "@/services/movement.service"
|
||||
|
||||
import {
|
||||
assignmentSchema,
|
||||
CreateAssignmentFormType,
|
||||
ReturnAssignmentFormType,
|
||||
UpdateAssignmentFormType,
|
||||
type CreateAssignmentFormType,
|
||||
type ReturnAssignmentFormType,
|
||||
type UpdateAssignmentFormType,
|
||||
updateAssignmentSchema,
|
||||
} from "../schemas/assignment.schemas"
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { AuthError } from "next-auth"
|
||||
|
||||
import { signIn } from "@/lib/auth"
|
||||
import { SignInFormType } from "@/lib/schemas/auth.schemas"
|
||||
import type { SignInFormType } from "@/lib/schemas/auth.schemas"
|
||||
|
||||
export async function signInAction(values: SignInFormType) {
|
||||
const { username, password } = values
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
import { revalidatePath } from "next/cache"
|
||||
|
||||
import {
|
||||
CreateCategoryFormType,
|
||||
type CreateCategoryFormType,
|
||||
createCategorySchema,
|
||||
UpdateCategoryFormType,
|
||||
type UpdateCategoryFormType,
|
||||
updateCategorySchema,
|
||||
} from "@/lib/schemas/category.schemas"
|
||||
import { CategoryService } from "@/services/category.service"
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
import { revalidatePath } from "next/cache"
|
||||
import Papa from "papaparse"
|
||||
|
||||
import { ImportFormType, importSchema } from "@/lib/schemas/import.schemas"
|
||||
import { ImportItem } from "@/lib/types"
|
||||
import { type ImportFormType, importSchema } from "@/lib/schemas/import.schemas"
|
||||
import type { ImportItem } from "@/lib/types"
|
||||
import { AssetService } from "@/services/asset.service"
|
||||
import { AssignmentService } from "@/services/assignment.service"
|
||||
import { CategoryService } from "@/services/category.service"
|
||||
@@ -47,7 +47,7 @@ export async function importItems(formData: ImportFormType) {
|
||||
if (papaErrors.length > 0) {
|
||||
return {
|
||||
errors: {
|
||||
file: papaErrors.map((err) => err.message).flat(),
|
||||
file: papaErrors.flatMap((err) => err.message),
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,9 +4,9 @@ import { revalidatePath } from "next/cache"
|
||||
|
||||
import prisma from "@/lib/prisma"
|
||||
import {
|
||||
CreateItemFormType,
|
||||
type CreateItemFormType,
|
||||
createItemSchema,
|
||||
UpdateItemFormType,
|
||||
type UpdateItemFormType,
|
||||
updateItemSchema,
|
||||
} from "@/lib/schemas/item.schemas"
|
||||
import { getAuthenticatedUserId } from "@/services/auth.service"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
CreateMovementFormType,
|
||||
type CreateMovementFormType,
|
||||
createMovementSchema,
|
||||
} from "../schemas/movement.schemas"
|
||||
|
||||
|
||||
@@ -4,9 +4,9 @@ import { revalidatePath } from "next/cache"
|
||||
|
||||
import prisma from "@/lib/prisma"
|
||||
import {
|
||||
CreateRecipientFormType,
|
||||
type CreateRecipientFormType,
|
||||
createRecipientSchema,
|
||||
UpdateRecipientFormType,
|
||||
type UpdateRecipientFormType,
|
||||
updateRecipientSchema,
|
||||
} from "@/lib/schemas/recipients.schemas"
|
||||
import { RecipientService } from "@/services/recipient.service"
|
||||
|
||||
+1
-1
@@ -2,7 +2,7 @@ import NextAuth, { type DefaultSession } from "next-auth"
|
||||
import Credentials from "next-auth/providers/credentials"
|
||||
import { ZodError } from "zod"
|
||||
|
||||
import { UserRole } from "@/generated/prisma/client"
|
||||
import type { UserRole } from "@/generated/prisma/client"
|
||||
import { SIGN_IN_URL, TOKEN_EXPIRATION_SECONDS } from "@/lib/constants"
|
||||
import { signInSchema } from "@/lib/schemas/auth.schemas"
|
||||
import { verifyPassword } from "@/lib/security"
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
import { Prisma } from "@/generated/prisma/client"
|
||||
import { PaginatedResult } from "@/lib/types"
|
||||
import type { Prisma } from "@/generated/prisma/client"
|
||||
import type { PaginatedResult } from "@/lib/types"
|
||||
|
||||
//eslint-disable-next-line
|
||||
type PaginationArgs<T> = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import {
|
||||
Asset as PrismaAsset,
|
||||
import type {
|
||||
Assignment,
|
||||
Asset as PrismaAsset,
|
||||
ItemStatus as PrismaItemStatus,
|
||||
} from "@/generated/prisma/client"
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Assignment as PrismaAssignment } from "@/generated/prisma/client"
|
||||
import type { Assignment as PrismaAssignment } from "@/generated/prisma/client"
|
||||
|
||||
import { Asset } from "./asset"
|
||||
import { Item } from "./item"
|
||||
import { Recipient } from "./recipient"
|
||||
import type { Asset } from "./asset"
|
||||
import type { Item } from "./item"
|
||||
import type { Recipient } from "./recipient"
|
||||
|
||||
export type Assignment = PrismaAssignment
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Category as PrismaCategory } from "@/generated/prisma/client"
|
||||
import type { Category as PrismaCategory } from "@/generated/prisma/client"
|
||||
|
||||
export type Category = PrismaCategory
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Category, Item as PrismaItem } from "@/generated/prisma/client"
|
||||
import type { Category, Item as PrismaItem } from "@/generated/prisma/client"
|
||||
|
||||
export type Item = PrismaItem
|
||||
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Movement as PrismaMovement } from "@/generated/prisma/client"
|
||||
import type { Movement as PrismaMovement } from "@/generated/prisma/client"
|
||||
|
||||
import { Asset } from "./asset"
|
||||
import { Item } from "./item"
|
||||
import { Recipient } from "./recipient"
|
||||
import type { Asset } from "./asset"
|
||||
import type { Item } from "./item"
|
||||
import type { Recipient } from "./recipient"
|
||||
|
||||
export type Movement = PrismaMovement
|
||||
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import { Recipient as PrismaRecipient } from "@/generated/prisma/client"
|
||||
import type { Recipient as PrismaRecipient } from "@/generated/prisma/client"
|
||||
|
||||
export type Recipient = PrismaRecipient
|
||||
|
||||
@@ -1,3 +1,3 @@
|
||||
import { User as PrismaUser } from "@/generated/prisma/client"
|
||||
import type { User as PrismaUser } from "@/generated/prisma/client"
|
||||
|
||||
export type User = PrismaUser
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Asset, Prisma } from "@/generated/prisma/client"
|
||||
import type { Asset, Prisma } from "@/generated/prisma/client"
|
||||
import { paginate } from "@/lib/paginate"
|
||||
import prisma from "@/lib/prisma"
|
||||
import {
|
||||
import type {
|
||||
AssetWithAssignment,
|
||||
AssetWithItemAndCategory,
|
||||
} from "@/lib/types/asset"
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { Prisma } from "@/generated/prisma/client"
|
||||
import type { Prisma } from "@/generated/prisma/client"
|
||||
import { paginate } from "@/lib/paginate"
|
||||
import prisma from "@/lib/prisma"
|
||||
import { CreateAssignmentFormType } from "@/lib/schemas/assignment.schemas"
|
||||
import { Assignment, AssignmentWithRecipientItemAsset } from "@/lib/types"
|
||||
import type { CreateAssignmentFormType } from "@/lib/schemas/assignment.schemas"
|
||||
import type { Assignment, AssignmentWithRecipientItemAsset } from "@/lib/types"
|
||||
|
||||
import { getAuthenticatedUserId } from "./auth.service"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Prisma } from "@/generated/prisma/client"
|
||||
import type { Prisma } from "@/generated/prisma/client"
|
||||
import { paginate } from "@/lib/paginate"
|
||||
import prisma from "@/lib/prisma"
|
||||
import { Category, CategorySummary, CategoryWithItemsCount } from "@/lib/types"
|
||||
import type { Category, CategorySummary, CategoryWithItemsCount } from "@/lib/types"
|
||||
|
||||
export const CategoryService = {
|
||||
findAll: async (): Promise<CategorySummary[]> => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Prisma } from "@/generated/prisma/client"
|
||||
import type { Prisma } from "@/generated/prisma/client"
|
||||
import { paginate } from "@/lib/paginate"
|
||||
import prisma from "@/lib/prisma"
|
||||
import {
|
||||
import type {
|
||||
Item,
|
||||
ItemSummary,
|
||||
ItemWithAssetAndMovementCount,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import { MovementType, Prisma } from "@/generated/prisma/client"
|
||||
import type { MovementType, Prisma } from "@/generated/prisma/client"
|
||||
import { paginate } from "@/lib/paginate"
|
||||
import prisma from "@/lib/prisma"
|
||||
import { CreateMovementFormType } from "@/lib/schemas/movement.schemas"
|
||||
import { Movement } from "@/lib/types"
|
||||
import type { CreateMovementFormType } from "@/lib/schemas/movement.schemas"
|
||||
import type { Movement } from "@/lib/types"
|
||||
|
||||
import { getAuthenticatedUserId } from "./auth.service"
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Prisma, Recipient } from "@/generated/prisma/client"
|
||||
import type { Prisma, Recipient } from "@/generated/prisma/client"
|
||||
import { paginate } from "@/lib/paginate"
|
||||
import prisma from "@/lib/prisma"
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { UserRole } from "@/generated/prisma/client"
|
||||
import prisma from "@/lib/prisma"
|
||||
import { getPasswordHash } from "@/lib/security"
|
||||
import { User } from "@/lib/types/user"
|
||||
import type { User } from "@/lib/types/user"
|
||||
|
||||
export async function createUser({ data }: { data: User }) {
|
||||
const newUser = await prisma.user.create({
|
||||
|
||||
Reference in New Issue
Block a user