diff options
| author | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2024-10-01 03:58:47 -0400 |
|---|---|---|
| committer | Nathan-SR <144961007+Nathan-SR@users.noreply.github.com> | 2024-10-01 03:58:47 -0400 |
| commit | 6d35629dd8f997208130981aac1daf36bc83b134 (patch) | |
| tree | 7b7e3baac15e5f7b4fcb48d90372c48d4552ae4c /src/client/util/reportManager/reportManagerUtils.ts | |
| parent | cf45abf8ada938caddb226c825166d4acdee3086 (diff) | |
| parent | ba01c7376ed4a2b817a26a430faf4041524aef35 (diff) | |
Merge branch 'master' of https://github.com/brown-dash/Dash-Web into nathan-starter
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; |
