This commit is contained in:
arc-alex
2023-11-19 19:39:13 +01:00
parent e52a75db7d
commit 85ee9de528
5 changed files with 27 additions and 55 deletions
+1 -4
View File
@@ -239,10 +239,7 @@ export const uploadSheetClientFile = async (file: File) => {
.post(`${ontimeURL}/sheet-clientsecrect`, formData, {
headers: {
'Content-Type': 'multipart/form-data',
},
onUploadProgress: (progressEvent) => {
const complete = progressEvent?.total ? Math.round((progressEvent.loaded * 100) / progressEvent.total) : 0;
},
}
})
.then((response) => response.data.id);
};
@@ -11,21 +11,21 @@ import {
ModalOverlay,
} from '@chakra-ui/react';
import { useQueryClient } from '@tanstack/react-query';
import { OntimeRundown, ProjectData, UserFields } from 'ontime-types';
import { PROJECT_DATA, RUNDOWN, USERFIELDS } from '../../../common/api/apiConstants';
import { maybeAxiosError } from '../../../common/api/apiUtils';
import {
getSheetsAuthStatus,
getSheetsAuthUrl,
postPreviewSheet,
uploadSheetClientFile,
patchData,
postPreviewSheet,
postPushSheet,
uploadSheetClientFile,
} from '../../../common/api/ontimeApi';
import { OntimeRundown, ProjectData, UserFields } from 'ontime-types';
import PreviewExcel from '../upload-modal/preview/PreviewExcel';
import { projectDataPlaceholder } from '../../../common/models/ProjectData';
import { userFieldsPlaceholder } from '../../../common/models/UserFields';
import { PROJECT_DATA, RUNDOWN, USERFIELDS } from '../../../common/api/apiConstants';
import { maybeAxiosError } from '../../../common/api/apiUtils';
import PreviewExcel from '../upload-modal/preview/PreviewExcel';
interface SheetsModalProps {
onClose: () => void;
@@ -35,7 +35,6 @@ interface SheetsModalProps {
export default function SheetsModal(props: SheetsModalProps) {
const { isOpen, onClose } = props;
const fileInputRef = useRef<HTMLInputElement>(null);
const [file, setFile] = useState<File | null>(null);
const [authState, setAuthState] = useState<boolean>(true);
const [rundown, setRundown] = useState<OntimeRundown | null>(null);
@@ -59,12 +58,10 @@ export default function SheetsModal(props: SheetsModalProps) {
const handleFile = (event: ChangeEvent<HTMLInputElement>) => {
const selectedFile = event?.target?.files?.[0];
if (!selectedFile) {
setFile(null);
return;
} else {
uploadSheetClientFile(selectedFile);
}
setFile(selectedFile);
};
//TODO: do smoething better here
@@ -75,8 +72,7 @@ export default function SheetsModal(props: SheetsModalProps) {
const handleAuthenticate = () => {
getSheetsAuthUrl().then((data) => {
console.log(data);
if (data == 'bad') {
} else {
if (data != 'bad') {
window.open(data, '_blank', 'noreferrer');
}
});