diff --git a/public/index.html b/public/index.html index 8958a5d..a2b3647 100644 --- a/public/index.html +++ b/public/index.html @@ -19,13 +19,9 @@ sizes="16x16" href="%PUBLIC_URL%/favicon-16x16.png" /> - - + - + - React App + Spotify Manager diff --git a/public/manifest.json b/public/manifest.json index 7fa5dde..cb2934a 100644 --- a/public/manifest.json +++ b/public/manifest.json @@ -1,6 +1,6 @@ { - "short_name": "React App", - "name": "Create React App Sample", + "short_name": "Spotify Manager", + "name": "Spotify Manager", "icons": [ { "src": "android-chrome-192x192.png", diff --git a/src/App.tsx b/src/App.tsx index 0fa9c43..162fb6d 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -33,7 +33,7 @@ export const RefreshAuthContext: Context<() => Promise> = function App(): React.ReactNode { // States const [width, setWidth] = useState(0); - const [auth, setAuth] = useState(false); + const [auth, setAuth] = useState(true); const refreshAuth = async () => { // reauth @@ -82,7 +82,9 @@ function App(): React.ReactNode { showErrorToastNotification(resp.data.message); return false; } - if (resp.status === 401) await refreshAuth(); + if (resp.status === 401) { + return await refreshAuth(); + } setAuth(false); showWarnToastNotification(resp.data.message); return false; diff --git a/src/api/load.ts b/src/api/load.ts new file mode 100644 index 0000000..d8ccec8 --- /dev/null +++ b/src/api/load.ts @@ -0,0 +1,20 @@ +import type { AxiosResponse } from "axios"; +import { type apiRespBaseType, axiosInstance } from "./axiosInstance.ts"; +import { loadImportDataURL } from "./paths.ts"; + +interface importGraphDataType extends apiRespBaseType {} + +export const apiImportGraph = async ( + data: File +): Promise> => { + try { + const formData = new FormData(); + formData.append("dataFile", data); + const response = await axiosInstance.put(loadImportDataURL, formData, { + headers: { "Content-Type": "multipart/form-data" }, + }); + return response; + } catch (error: any) { + return error.response; + } +}; diff --git a/src/api/paths.ts b/src/api/paths.ts index 02292e4..ab0a902 100644 --- a/src/api/paths.ts +++ b/src/api/paths.ts @@ -18,3 +18,7 @@ export const opBackfillLinkURL = "api/operations/populate/link"; export const opBackfillChainURL = "api/operations/populate/chain"; export const opPruneLinkURL = "api/operations/prune/link"; export const opPruneChainURL = "api/operations/prune/chain"; + +export const loadExportDataURL = "api/load"; +export const loadExportDataFullURL: string = backendDomain + loadExportDataURL; +export const loadImportDataURL = "api/load"; diff --git a/src/components/Navbar/index.tsx b/src/components/Navbar/index.tsx index 9b00245..47b26cf 100644 --- a/src/components/Navbar/index.tsx +++ b/src/components/Navbar/index.tsx @@ -10,12 +10,11 @@ const Navbar = (): React.ReactNode => { return (