mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-11 17:19:34 +00:00
fix: import preview enable after error
This commit is contained in:
committed by
Carlos Valente
parent
8d8625aa77
commit
ac61f257c0
@@ -103,6 +103,7 @@ export default function SourcesPanel() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmitImportPreview = async (importMap: ImportMap) => {
|
const handleSubmitImportPreview = async (importMap: ImportMap) => {
|
||||||
|
setError(''); // to clear previous error
|
||||||
if (importFlow === 'excel') {
|
if (importFlow === 'excel') {
|
||||||
try {
|
try {
|
||||||
const previewData = await importRundownPreviewExcel(importMap);
|
const previewData = await importRundownPreviewExcel(importMap);
|
||||||
|
|||||||
+10
-1
@@ -1,4 +1,4 @@
|
|||||||
import { useState } from 'react';
|
import { useEffect, useState } from 'react';
|
||||||
import { useFieldArray, useForm } from 'react-hook-form';
|
import { useFieldArray, useForm } from 'react-hook-form';
|
||||||
import { IoAdd, IoTrash } from 'react-icons/io5';
|
import { IoAdd, IoTrash } from 'react-icons/io5';
|
||||||
import { Button, IconButton, Input, Select, Tooltip } from '@chakra-ui/react';
|
import { Button, IconButton, Input, Select, Tooltip } from '@chakra-ui/react';
|
||||||
@@ -28,6 +28,7 @@ export default function ImportMapForm(props: ImportMapFormProps) {
|
|||||||
control,
|
control,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
register,
|
register,
|
||||||
|
setValue,
|
||||||
formState: { errors, isValid },
|
formState: { errors, isValid },
|
||||||
} = useForm<NamedImportMap>({
|
} = useForm<NamedImportMap>({
|
||||||
mode: 'onChange',
|
mode: 'onChange',
|
||||||
@@ -45,6 +46,14 @@ export default function ImportMapForm(props: ImportMapFormProps) {
|
|||||||
|
|
||||||
const [loading, setLoading] = useState<'' | 'export' | 'import'>('');
|
const [loading, setLoading] = useState<'' | 'export' | 'import'>('');
|
||||||
|
|
||||||
|
// Set first sheet as default worksheet when 'event schedule' sheet is not there
|
||||||
|
useEffect(() => {
|
||||||
|
if (!worksheetNames || worksheetNames.length === 0) return;
|
||||||
|
if (!worksheetNames.includes(namedImportMap.Worksheet)) {
|
||||||
|
setValue('Worksheet', worksheetNames[0], { shouldValidate: true, shouldDirty: true });
|
||||||
|
}
|
||||||
|
}, [worksheetNames, setValue, namedImportMap.Worksheet]);
|
||||||
|
|
||||||
const handleExport = async (values: NamedImportMap) => {
|
const handleExport = async (values: NamedImportMap) => {
|
||||||
setLoading('export');
|
setLoading('export');
|
||||||
const importMap = convertToImportMap(values);
|
const importMap = convertToImportMap(values);
|
||||||
|
|||||||
Reference in New Issue
Block a user