diff options
| author | A.J. Shulman <Shulman.aj@gmail.com> | 2024-09-05 11:40:24 -0400 |
|---|---|---|
| committer | A.J. Shulman <Shulman.aj@gmail.com> | 2024-09-05 11:40:24 -0400 |
| commit | c1053475810a1b1b3a9963c3f1ef0b1a9509d222 (patch) | |
| tree | 41da9f26592ba7f189f8d00536435182e38272da /src/client/util/reportManager/reportManagerUtils.ts | |
| parent | 785e55141cab178a761080f5c99384bb19855969 (diff) | |
| parent | 9014cc474a039f0daef6cc0ee2011329da7703ac (diff) | |
merged with master
Diffstat (limited to 'src/client/util/reportManager/reportManagerUtils.ts')
| -rw-r--r-- | src/client/util/reportManager/reportManagerUtils.ts | 16 |
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; |
