refactor: update accepted file types for CSV uploads in import form and schema
This commit is contained in:
@@ -69,7 +69,7 @@ export default function ImportForm({
|
|||||||
</label>
|
</label>
|
||||||
<input
|
<input
|
||||||
type="file"
|
type="file"
|
||||||
accept=".csv"
|
accept="text/csv, text/comma-separated-values"
|
||||||
onChange={handleFileChange}
|
onChange={handleFileChange}
|
||||||
className="w-full rounded-lg border px-4 py-2"
|
className="w-full rounded-lg border px-4 py-2"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -1,9 +1,13 @@
|
|||||||
import { z } from "zod"
|
import { z } from "zod"
|
||||||
|
|
||||||
|
const ACCEPTED_MIME_TYPES = ["text/csv", "text/comma-separated-values"]
|
||||||
|
|
||||||
export const importSchema = z.object({
|
export const importSchema = z.object({
|
||||||
file: z.instanceof(File).refine((file) => file.type === "text/csv", {
|
file: z
|
||||||
message: "File must be a CSV",
|
.instanceof(File)
|
||||||
}),
|
.refine((file) => ACCEPTED_MIME_TYPES.includes(file.type), {
|
||||||
|
message: "File must be a CSV",
|
||||||
|
}),
|
||||||
categoryId: z.string().optional(),
|
categoryId: z.string().optional(),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user