aboutsummaryrefslogtreecommitdiff
path: root/src/client/util/reportManager/reportManagerUtils.ts
diff options
context:
space:
mode:
authorZachary Zhang <zacharyzhang7@gmail.com>2024-08-31 00:46:29 -0400
committerZachary Zhang <zacharyzhang7@gmail.com>2024-08-31 00:46:29 -0400
commit196294f331496262bef256da8b8e9dbc80288bea (patch)
tree85ff27b7a8070585f9a5ef71dff63566e03232ba /src/client/util/reportManager/reportManagerUtils.ts
parent0cf61501ec9be34294935f01973c1bd9cad6d267 (diff)
parentc36607691e0b7f5c04f3209a64958f5e51ddd785 (diff)
Merge branch 'master' into zach-starter
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;