style: fix biome lint and format issues across codebase
This commit is contained in:
@@ -35,14 +35,18 @@ export async function createAssignment(formData: CreateAssignmentFormType) {
|
||||
|
||||
try {
|
||||
const createdBy = await getAuthenticatedUserId()
|
||||
const { itemId, quantity, notes } = validatedFields.data
|
||||
if (!itemId || quantity == null) {
|
||||
throw new Error("Missing required assignment fields")
|
||||
}
|
||||
|
||||
const result = await createAssignmentUseCase({
|
||||
...validatedFields.data,
|
||||
lines: [
|
||||
{
|
||||
itemId: validatedFields.data.itemId!,
|
||||
quantity: validatedFields.data.quantity!,
|
||||
notes: validatedFields.data.notes,
|
||||
itemId,
|
||||
quantity,
|
||||
notes,
|
||||
},
|
||||
],
|
||||
actorId: createdBy,
|
||||
@@ -86,14 +90,18 @@ export async function updateAssignment(formData: UpdateAssignmentFormType) {
|
||||
|
||||
try {
|
||||
const createdBy = await getAuthenticatedUserId()
|
||||
const { itemId, quantity, notes } = validatedFields.data
|
||||
if (!itemId || quantity == null) {
|
||||
throw new Error("Missing required assignment fields")
|
||||
}
|
||||
|
||||
const result = await updateAssignmentUseCase({
|
||||
...validatedFields.data,
|
||||
lines: [
|
||||
{
|
||||
itemId: validatedFields.data.itemId!,
|
||||
quantity: validatedFields.data.quantity!,
|
||||
notes: validatedFields.data.notes,
|
||||
itemId,
|
||||
quantity,
|
||||
notes,
|
||||
},
|
||||
],
|
||||
actorId: createdBy,
|
||||
|
||||
@@ -7,7 +7,10 @@ import { Button } from "@/components/ui/button"
|
||||
import { getI18n } from "@/i18n/server"
|
||||
import { AssetService } from "@/services/asset.service"
|
||||
|
||||
import type { AssetDetailCopy, AssetStatusCopy } from "../_components/asset.copy"
|
||||
import type {
|
||||
AssetDetailCopy,
|
||||
AssetStatusCopy,
|
||||
} from "../_components/asset.copy"
|
||||
|
||||
function formatAssetStatus(
|
||||
status: string,
|
||||
@@ -77,7 +80,9 @@ export default async function AssetDetailPage({
|
||||
<dd>{asset.serialNumber}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt className="text-sm text-muted-foreground">{copy.labels.assetTag}</dt>
|
||||
<dt className="text-sm text-muted-foreground">
|
||||
{copy.labels.assetTag}
|
||||
</dt>
|
||||
<dd>{asset.assetTag ?? missingValue}</dd>
|
||||
</div>
|
||||
<div>
|
||||
@@ -119,11 +124,19 @@ export default async function AssetDetailPage({
|
||||
<dd>{asset.notes ?? missingValue}</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt className="text-sm text-muted-foreground">{copy.labels.status}</dt>
|
||||
<dd>{formatAssetStatus(asset.status, statusCopy, { unknownStatus: missingValue })}</dd>
|
||||
<dt className="text-sm text-muted-foreground">
|
||||
{copy.labels.status}
|
||||
</dt>
|
||||
<dd>
|
||||
{formatAssetStatus(asset.status, statusCopy, {
|
||||
unknownStatus: missingValue,
|
||||
})}
|
||||
</dd>
|
||||
</div>
|
||||
<div>
|
||||
<dt className="text-sm text-muted-foreground">{copy.labels.person}</dt>
|
||||
<dt className="text-sm text-muted-foreground">
|
||||
{copy.labels.person}
|
||||
</dt>
|
||||
<dd>{formatPersonName(asset.assignment?.person, missingValue)}</dd>
|
||||
</div>
|
||||
</dl>
|
||||
|
||||
+3
-1
@@ -39,7 +39,9 @@ export const { handlers, signIn, signOut, auth } = NextAuth({
|
||||
|
||||
if (!success) throw new Error("Invalid email or password")
|
||||
|
||||
const user = await getUserCredentialsByEmail(normalizeEmail(data.email))
|
||||
const user = await getUserCredentialsByEmail(
|
||||
normalizeEmail(data.email),
|
||||
)
|
||||
|
||||
if (!user) {
|
||||
throw new Error("Invalid email or password")
|
||||
|
||||
+16
-12
@@ -44,12 +44,14 @@ function buildTrackingTypeSchema(copy: ItemSchemaCopy) {
|
||||
}
|
||||
|
||||
function buildOptionalTrackingTypeSchema(copy: ItemSchemaCopy) {
|
||||
return z.preprocess(
|
||||
(value) => (value === "" || value === null ? undefined : value),
|
||||
z.enum(itemTrackingTypes, {
|
||||
error: () => copy.invalidTrackingType,
|
||||
}),
|
||||
).optional()
|
||||
return z
|
||||
.preprocess(
|
||||
(value) => (value === "" || value === null ? undefined : value),
|
||||
z.enum(itemTrackingTypes, {
|
||||
error: () => copy.invalidTrackingType,
|
||||
}),
|
||||
)
|
||||
.optional()
|
||||
}
|
||||
|
||||
function buildStatusSchema(copy: ItemSchemaCopy) {
|
||||
@@ -65,12 +67,14 @@ function buildStatusSchema(copy: ItemSchemaCopy) {
|
||||
}
|
||||
|
||||
function buildOptionalStatusSchema(copy: ItemSchemaCopy) {
|
||||
return z.preprocess(
|
||||
(value) => (value === "" || value === null ? undefined : value),
|
||||
z.enum(itemStatuses, {
|
||||
error: () => copy.invalidStatus,
|
||||
}),
|
||||
).optional()
|
||||
return z
|
||||
.preprocess(
|
||||
(value) => (value === "" || value === null ? undefined : value),
|
||||
z.enum(itemStatuses, {
|
||||
error: () => copy.invalidStatus,
|
||||
}),
|
||||
)
|
||||
.optional()
|
||||
}
|
||||
|
||||
function buildOptionalReasonSchema() {
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
import type { AssetStatus, InventoryMovementType, Prisma } from "@/generated/prisma/client"
|
||||
import type {
|
||||
AssetStatus,
|
||||
InventoryMovementType,
|
||||
Prisma,
|
||||
} from "@/generated/prisma/client"
|
||||
import { paginate } from "@/lib/paginate"
|
||||
import prisma from "@/lib/prisma"
|
||||
import type { CreateMovementFormType } from "@/schemas/movement.schema"
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
import type {
|
||||
Prisma,
|
||||
Asset as PrismaAsset,
|
||||
AssetStatus as PrismaAssetStatus,
|
||||
Prisma,
|
||||
} from "@/generated/prisma/client"
|
||||
|
||||
import type { Assignment } from "./assignment"
|
||||
|
||||
@@ -9,8 +9,8 @@ type FieldErrors = Record<string, string[]>
|
||||
|
||||
type CreateItemUseCaseInput = Omit<CreateItemData, "trackingType" | "status"> &
|
||||
Partial<Pick<CreateItemData, "trackingType" | "status">> & {
|
||||
actorId: string
|
||||
}
|
||||
actorId: string
|
||||
}
|
||||
|
||||
type UpdateItemUseCaseInput = UpdateItemData & {
|
||||
actorId: string
|
||||
@@ -145,8 +145,7 @@ export async function updateItemUseCase(
|
||||
return itemError({ name: ["An item with this name already exists"] })
|
||||
}
|
||||
|
||||
const effectiveTrackingType =
|
||||
trackingType ?? existingItem.trackingType
|
||||
const effectiveTrackingType = trackingType ?? existingItem.trackingType
|
||||
const isSerialized = effectiveTrackingType === "SERIALIZED"
|
||||
|
||||
await ItemService.update(
|
||||
|
||||
@@ -24,7 +24,7 @@ vi.mock("@/components/common/pageheader", () => ({
|
||||
|
||||
vi.mock("@/components/ui/button", () => ({
|
||||
Button: ({ children }: { children: React.ReactNode }) =>
|
||||
createElement("button", null, children),
|
||||
createElement("button", { type: "button" }, children),
|
||||
}))
|
||||
|
||||
vi.mock("next/link", () => ({
|
||||
@@ -109,7 +109,9 @@ describe("asset detail page", () => {
|
||||
)
|
||||
|
||||
const html = renderToStaticMarkup(
|
||||
await AssetDetailPage({ params: Promise.resolve({ assetId: "asset-1" }) }),
|
||||
await AssetDetailPage({
|
||||
params: Promise.resolve({ assetId: "asset-1" }),
|
||||
}),
|
||||
)
|
||||
|
||||
expect(html).toContain("Asset Details")
|
||||
|
||||
@@ -29,7 +29,7 @@ vi.mock("@/components/common/pagination", () => ({
|
||||
|
||||
vi.mock("@/components/ui/button", () => ({
|
||||
Button: ({ children }: { children: React.ReactNode }) =>
|
||||
createElement("button", null, children),
|
||||
createElement("button", { type: "button" }, children),
|
||||
}))
|
||||
|
||||
vi.mock("next/link", () => ({
|
||||
|
||||
@@ -5,8 +5,8 @@ vi.mock("@/lib/prisma", () => ({
|
||||
}))
|
||||
|
||||
import {
|
||||
getUserById,
|
||||
getUserByEmail,
|
||||
getUserById,
|
||||
getUserCredentialsByEmail,
|
||||
} from "@/services/user.service"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user