mirror of
https://github.com/cpvalente/ontime.git
synced 2026-09-01 12:29:10 +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();
|
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 openGSheetFlow = async () => {
|
||||||
const result = await verifyAuth();
|
const result = await verifyAuth();
|
||||||
if (result) {
|
if (result) {
|
||||||
@@ -89,7 +100,7 @@ export default function SourcesPanel() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const cancelGSheetFlow = () => {
|
const cancelGSheetFlow = () => {
|
||||||
setImportFlow('none');
|
resetFlow();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmitImportPreview = async (importMap: ImportMap) => {
|
const handleSubmitImportPreview = async (importMap: ImportMap) => {
|
||||||
@@ -110,9 +121,7 @@ export default function SourcesPanel() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const cancelImportMap = async () => {
|
const cancelImportMap = async () => {
|
||||||
setImportFlow('none');
|
resetFlow();
|
||||||
setHasFile('none');
|
|
||||||
setWorksheets(null);
|
|
||||||
if (authenticationStatus === 'authenticated') {
|
if (authenticationStatus === 'authenticated') {
|
||||||
const result = await verifyAuth();
|
const result = await verifyAuth();
|
||||||
if (result) {
|
if (result) {
|
||||||
@@ -127,6 +136,7 @@ export default function SourcesPanel() {
|
|||||||
setHasFile('none');
|
setHasFile('none');
|
||||||
setWorksheets(null);
|
setWorksheets(null);
|
||||||
setCustomFields(null);
|
setCustomFields(null);
|
||||||
|
setError('');
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleSubmitExport = async (importMap: ImportMap) => {
|
const handleSubmitExport = async (importMap: ImportMap) => {
|
||||||
@@ -134,15 +144,6 @@ export default function SourcesPanel() {
|
|||||||
await exportRundown(sheetId, importMap);
|
await exportRundown(sheetId, importMap);
|
||||||
};
|
};
|
||||||
|
|
||||||
const resetFlow = () => {
|
|
||||||
setImportFlow('none');
|
|
||||||
setRundown(null);
|
|
||||||
setHasFile('none');
|
|
||||||
setWorksheets(null);
|
|
||||||
setCustomFields(null);
|
|
||||||
setError('');
|
|
||||||
};
|
|
||||||
|
|
||||||
const isExcelFlow = importFlow === 'excel';
|
const isExcelFlow = importFlow === 'excel';
|
||||||
const isGSheetFlow = importFlow === 'gsheet';
|
const isGSheetFlow = importFlow === 'gsheet';
|
||||||
const isAuthenticated = authenticationStatus === 'authenticated';
|
const isAuthenticated = authenticationStatus === 'authenticated';
|
||||||
|
|||||||
+1
-1
@@ -121,7 +121,7 @@ export default function ImportMapForm(props: ImportMapFormProps) {
|
|||||||
<thead>
|
<thead>
|
||||||
<tr>
|
<tr>
|
||||||
<th>Ontime field</th>
|
<th>Ontime field</th>
|
||||||
<th>From spreadsheet name</th>
|
<th>Column name in spreadsheet</th>
|
||||||
<th className={style.singleActionCell} />
|
<th className={style.singleActionCell} />
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
|
|||||||
Reference in New Issue
Block a user