aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/reportManager/reportManagerUtils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'src/client/util/reportManager/reportManagerUtils.ts')
-rw-r--r--src/client/util/reportManager/reportManagerUtils.ts16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/client/util/reportManager/reportManagerUtils.ts b/src/client/util/reportManager/reportManagerUtils.ts
index f14967e0a..d51418cbe 100644
--- a/src/client/util/reportManager/reportManagerUtils.ts
+++ b/src/client/util/reportManager/reportManagerUtils.ts
@@ -3,6 +3,7 @@
import { Octokit } from '@octokit/core';
import { Networking } from '../../Network';
import { Issue } from './reportManagerSchema';
+import { Upload } from '../../../server/SharedMediaTypes';
// enums and interfaces
@@ -53,7 +54,7 @@ export const emptyReportForm = {
* Fetches issues from Github.
* @returns array of all issues
*/
-export const getAllIssues = async (octokit: Octokit): Promise<any[]> => {
+export const getAllIssues = async (octokit: Octokit): Promise<unknown[]> => {
const res = await octokit.request('GET /repos/{owner}/{repo}/issues', {
owner: 'brown-dash',
repo: 'Dash-Web',
@@ -103,7 +104,10 @@ export const fileLinktoServerLink = (fileLink: string): string => {
* @param link response from file upload
* @returns server file path
*/
-export const getServerPath = (link: any): string => link.result.accessPaths.agnostic.server as string;
+export const getServerPath = (link: Upload.FileResponse<Upload.FileInformation>): string => {
+ if (link.result instanceof Error) return '';
+ return link.result.accessPaths.agnostic.server;
+};
/**
* Uploads media files to the server.
@@ -114,11 +118,11 @@ export const uploadFilesToServer = async (mediaFiles: FileData[]): Promise<strin
// need to always upload to browndash
const links = await Networking.UploadFilesToServer(mediaFiles.map(file => ({ file: file.file })));
return (links ?? []).map(getServerPath).map(fileLinktoServerLink);
- } catch (err) {
- if (err instanceof Error) {
- alert(err.message);
+ } catch (result) {
+ if (result instanceof Error) {
+ alert(result.message);
} else {
- alert(err);
+ alert(result);
}
}
return undefined;