mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2026-03-12 10:33:49 +00:00
Tweaked server types and data
This commit is contained in:
@@ -1,12 +1,12 @@
|
||||
import { CsvJson } from 'csvjson';
|
||||
import { RegularServer } from '../data';
|
||||
import { NewServerData } from '../data';
|
||||
|
||||
const CSV_MIME_TYPE = 'text/csv';
|
||||
|
||||
export default class ServersImporter {
|
||||
public constructor(private readonly csvjson: CsvJson, private readonly fileReaderFactory: () => FileReader) {}
|
||||
|
||||
public importServersFromFile = async (file?: File | null): Promise<RegularServer[]> => {
|
||||
public importServersFromFile = async (file?: File | null): Promise<NewServerData[]> => {
|
||||
if (!file || file.type !== CSV_MIME_TYPE) {
|
||||
throw new Error('No file provided or file is not a CSV');
|
||||
}
|
||||
@@ -16,7 +16,7 @@ export default class ServersImporter {
|
||||
return new Promise((resolve) => {
|
||||
reader.addEventListener('loadend', (e: ProgressEvent<FileReader>) => {
|
||||
const content = e.target?.result?.toString() ?? '';
|
||||
const servers = this.csvjson.toObject<RegularServer>(content);
|
||||
const servers = this.csvjson.toObject<NewServerData>(content);
|
||||
|
||||
resolve(servers);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user