Skip to content

Commit

Permalink
chore: format
Browse files Browse the repository at this point in the history
  • Loading branch information
reacto11mecha committed Oct 14, 2023
1 parent 862e2aa commit 028d25c
Showing 1 changed file with 14 additions and 7 deletions.
21 changes: 14 additions & 7 deletions apps/web/src/pages/peserta/csv.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,10 @@ import {
import { api } from "~/utils/api";
import Sidebar from "~/components/Sidebar";

type StateZodErr = { error: Array<{ message: string; path: Array<number | string> }>; dataOfError: Array<{ "Bagian Dari": string; Nama: string }> };
type StateZodErr = {
error: Array<{ message: string; path: Array<number | string> }>;
dataOfError: Array<{ "Bagian Dari": string; Nama: string }>;
};

const HalamanTambah = () => {
const toast = useToast();
Expand Down Expand Up @@ -96,18 +99,21 @@ const HalamanTambah = () => {
const result = CSVDataValidator.safeParse(records);

if (!result.success) {
const error = JSON.parse(result.error.message) as StateZodErr['error'];
const error = JSON.parse(result.error.message) as StateZodErr["error"];

// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
const dataOfError = error.map(d => records[d.path[0]])
const dataOfError = error.map((d) => records[d.path[0]]);

setErr({ error, dataOfError: dataOfError as StateZodErr['dataOfError'] });
setErr({
error,
dataOfError: dataOfError as StateZodErr["dataOfError"],
});

return onOpen();
}

console.log(result.data)
console.log(result.data);

insertManyMutation.mutate(result.data);
});
Expand Down Expand Up @@ -206,8 +212,9 @@ const HalamanTambah = () => {
<ListItem key={idx}>
{/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
{/** @ts-ignore */}
Kolom {error.path[1]} data {JSON.stringify(errors.dataOfError[idx][error.path[1]])}
. {error.message}
Kolom {error.path[1]} data{" "}
{JSON.stringify(errors.dataOfError[idx][error.path[1]])}.{" "}
{error.message}
</ListItem>
))}
</UnorderedList>
Expand Down

0 comments on commit 028d25c

Please sign in to comment.