Changes
Co-authored-by: renee-png <262607627+renee-png@users.noreply.github.com>
This commit is contained in:
co-authored by
renee-png
parent
2c36910885
commit
b933d04847
@@ -678,7 +678,7 @@ function ImportPage() {
|
||||
console.info(`[import] lookups loaded: clients=${ctx.clientByExt.size}/${ctx.clientByName.size} cases=${ctx.caseByExt.size}/${ctx.caseByNumber.size}/${ctx.caseByTitle.size} users=${ctx.userByName.size}`);
|
||||
};
|
||||
|
||||
const handleFile = async (cfg: ImporterConfig, file: File) => {
|
||||
const handleFile = async (cfg: ImporterConfig, source: File | string) => {
|
||||
if (!user?.id) return;
|
||||
setResults((r) => ({ ...r, [cfg.key]: "running" }));
|
||||
ctx.defaultClientId = cfg.key === "locations" ? (defaultClientId || null) : null;
|
||||
@@ -686,12 +686,20 @@ function ImportPage() {
|
||||
await ensureLookupsLoaded();
|
||||
|
||||
const parsed = await new Promise<Papa.ParseResult<Record<string, string>>>((resolve, reject) => {
|
||||
Papa.parse<Record<string, string>>(file, {
|
||||
header: true,
|
||||
skipEmptyLines: true,
|
||||
complete: resolve,
|
||||
error: reject,
|
||||
});
|
||||
if (typeof source === "string") {
|
||||
const result = Papa.parse<Record<string, string>>(source, {
|
||||
header: true,
|
||||
skipEmptyLines: true,
|
||||
});
|
||||
resolve(result);
|
||||
} else {
|
||||
Papa.parse<Record<string, string>>(source, {
|
||||
header: true,
|
||||
skipEmptyLines: true,
|
||||
complete: resolve,
|
||||
error: reject,
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
const rawRows = parsed.data;
|
||||
|
||||
Reference in New Issue
Block a user