mirror of
https://github.com/cpvalente/ontime.git
synced 2026-08-11 10:23:54 +00:00
refactor: clear state on sheet flows
This commit is contained in:
committed by
Carlos Valente
parent
5501f57b45
commit
a8756c8afe
@@ -70,6 +70,17 @@ export default function SourcesPanel() {
|
||||
fileInputRef.current?.click();
|
||||
};
|
||||
|
||||
const resetFlow = () => {
|
||||
// we purposely omit clearing the authentication status
|
||||
setImportFlow('none');
|
||||
setRundown(null);
|
||||
setHasFile('none');
|
||||
setWorksheets(null);
|
||||
setCustomFields(null);
|
||||
setError('');
|
||||
setSheetId(null);
|
||||
};
|
||||
|
||||
const openGSheetFlow = async () => {
|
||||
const result = await verifyAuth();
|
||||
if (result) {
|
||||
@@ -89,7 +100,7 @@ export default function SourcesPanel() {
|
||||
};
|
||||
|
||||
const cancelGSheetFlow = () => {
|
||||
setImportFlow('none');
|
||||
resetFlow();
|
||||
};
|
||||
|
||||
const handleSubmitImportPreview = async (importMap: ImportMap) => {
|
||||
@@ -110,9 +121,7 @@ export default function SourcesPanel() {
|
||||
};
|
||||
|
||||
const cancelImportMap = async () => {
|
||||
setImportFlow('none');
|
||||
setHasFile('none');
|
||||
setWorksheets(null);
|
||||
resetFlow();
|
||||
if (authenticationStatus === 'authenticated') {
|
||||
const result = await verifyAuth();
|
||||
if (result) {
|
||||
@@ -127,6 +136,7 @@ export default function SourcesPanel() {
|
||||
setHasFile('none');
|
||||
setWorksheets(null);
|
||||
setCustomFields(null);
|
||||
setError('');
|
||||
};
|
||||
|
||||
const handleSubmitExport = async (importMap: ImportMap) => {
|
||||
@@ -134,15 +144,6 @@ export default function SourcesPanel() {
|
||||
await exportRundown(sheetId, importMap);
|
||||
};
|
||||
|
||||
const resetFlow = () => {
|
||||
setImportFlow('none');
|
||||
setRundown(null);
|
||||
setHasFile('none');
|
||||
setWorksheets(null);
|
||||
setCustomFields(null);
|
||||
setError('');
|
||||
};
|
||||
|
||||
const isExcelFlow = importFlow === 'excel';
|
||||
const isGSheetFlow = importFlow === 'gsheet';
|
||||
const isAuthenticated = authenticationStatus === 'authenticated';
|
||||
|
||||
+1
-1
@@ -121,7 +121,7 @@ export default function ImportMapForm(props: ImportMapFormProps) {
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Ontime field</th>
|
||||
<th>From spreadsheet name</th>
|
||||
<th>Column name in spreadsheet</th>
|
||||
<th className={style.singleActionCell} />
|
||||
</tr>
|
||||
</thead>
|
||||
|
||||
Reference in New Issue
Block a user