-
Notifications
You must be signed in to change notification settings - Fork 3.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Refactor Upload Folders to Use Mutations for HTTP Request Manag…
…ement (#2810) * ✨ (frontend): Add new API queries for user authentication and messages handling 📝 (frontend): Update API queries for user authentication to include new functionalities like logout, reset password, update user, add user, login user, and refresh access token 📝 (frontend): Update API queries for messages to change the update messages functionality to use PUT method instead of PATCH * ✨ (sideBarFolderButtons/index.tsx): Add usePostUploadFolders query to handle uploading folders and files 🔧 (constants.ts): Add FOLDERS constant to API URLs for folder-related endpoints 🔧 (folders/index.tsx): Add use-post-upload-folders query to handle uploading folders and files 🔧 (use-update-messages.ts): Remove unused file use-update-messages.ts to clean up the project 🔧 (foldersStore.tsx): Remove unused uploadFolder function to improve code maintainability and reduce complexity 🔧 (folders/index.ts): Remove unused uploadFolder function to simplify the codebase and improve readability * [autofix.ci] apply automated fixes --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
- Loading branch information
1 parent
90508b2
commit 65acbd5
Showing
15 changed files
with
86 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,10 @@ | ||
export * from "./use-delete-users"; | ||
export * from "./use-get-autologin"; | ||
export * from "./use-get-user"; | ||
export * from "./use-get-users-page"; | ||
export * from "./use-patch-logout"; | ||
export * from "./use-patch-reset-password"; | ||
export * from "./use-patch-update-user"; | ||
export * from "./use-post-add-user"; | ||
export * from "./use-post-login-user"; | ||
export * from "./use-post-refresh-access"; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./use-post-upload-folders"; |
32 changes: 32 additions & 0 deletions
32
src/frontend/src/controllers/API/queries/folders/use-post-upload-folders.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import useFlowsManagerStore from "@/stores/flowsManagerStore"; | ||
import { useFolderStore } from "@/stores/foldersStore"; | ||
import { Users, useMutationFunctionType } from "@/types/api"; | ||
import { api } from "../../api"; | ||
import { getURL } from "../../helpers/constants"; | ||
import { UseRequestProcessor } from "../../services/request-processor"; | ||
|
||
interface IPostAddUploadFolders { | ||
formData: FormData; | ||
} | ||
|
||
export const usePostUploadFolders: useMutationFunctionType< | ||
undefined, | ||
IPostAddUploadFolders | ||
> = (options?) => { | ||
const { mutate } = UseRequestProcessor(); | ||
|
||
const uploadFoldersFn = async ( | ||
payload: IPostAddUploadFolders, | ||
): Promise<void> => { | ||
const res = await api.post( | ||
`${getURL("FOLDERS")}/upload/`, | ||
payload.formData, | ||
); | ||
await useFolderStore.getState().getFoldersApi(true); | ||
return res.data; | ||
}; | ||
|
||
const mutation = mutate(["usePostUploadFolders"], uploadFoldersFn, options); | ||
|
||
return mutation; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
export * from "./use-delete-messages"; | ||
export * from "./use-get-messages"; | ||
export * from "./use-update-messages"; | ||
export * from "./use-put-update-messages"; |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters