Skip to content

Commit

Permalink
fix(merge): merge
Browse files Browse the repository at this point in the history
  • Loading branch information
NSUWAL123 committed Feb 14, 2025
2 parents e820296 + 6554ecd commit 3254adc
Show file tree
Hide file tree
Showing 26 changed files with 17 additions and 210 deletions.
39 changes: 0 additions & 39 deletions src/frontend/src/api/CreateProjectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,7 @@ const CreateProjectService = (
await dispatch(CreateProjectActions.GenerateProjectError(true));
dispatch(
CommonActions.SetSnackBar({
open: true,
message: JSON.stringify(error?.response?.data?.detail) || 'Something went wrong. Please try again.',
variant: 'error',
duration: 2000,
}),
);
dispatch(CreateProjectActions.CreateProjectLoading(false));
Expand Down Expand Up @@ -176,10 +173,7 @@ const UploadTaskAreasService = (url: string, filePayload: any) => {
await dispatch(CreateProjectActions.GenerateProjectError(true));
dispatch(
CommonActions.SetSnackBar({
open: true,
message: JSON.stringify(error?.response?.data?.detail) || 'Something Went Wrong.',
variant: 'error',
duration: 2000,
}),
);
}
Expand Down Expand Up @@ -252,10 +246,7 @@ const GenerateProjectFilesService = (url: string, projectData: any, formUpload:
dispatch(CreateProjectActions.GenerateProjectError(true));
dispatch(
CommonActions.SetSnackBar({
open: true,
message: JSON.stringify(error?.response?.data?.detail),
variant: 'error',
duration: 2000,
}),
);
dispatch(CreateProjectActions.GenerateProjectLoading(false));
Expand Down Expand Up @@ -287,10 +278,7 @@ const PostAdditionalFeatureService = (url: string, file: File) => {
isAPISuccess = false;
dispatch(
CommonActions.SetSnackBar({
open: true,
message: JSON.stringify(error?.response?.data?.detail),
variant: 'error',
duration: 2000,
}),
);
}
Expand Down Expand Up @@ -411,10 +399,7 @@ const TaskSplittingPreviewService = (
} catch (error) {
dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'Task generation failed. Please try again',
variant: 'error',
duration: 2000,
}),
);
dispatch(CreateProjectActions.GetTaskSplittingPreviewLoading(false));
Expand All @@ -439,20 +424,15 @@ const PatchProjectDetails = (url: string, projectData: Record<string, any>) => {
dispatch(CreateProjectActions.SetPatchProjectDetailsLoading(false));
dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'Project Successfully Edited',
variant: 'success',
duration: 2000,
}),
);
} catch (error) {
dispatch(CreateProjectActions.SetPatchProjectDetailsLoading(false));
dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'Failed. Do you have permission to edit?',
variant: 'error',
duration: 2000,
}),
);
} finally {
Expand Down Expand Up @@ -482,19 +462,14 @@ const PostFormUpdate = (url: string, projectData: Record<string, any>) => {
dispatch(CreateProjectActions.SetPostFormUpdateLoading(false));
dispatch(
CommonActions.SetSnackBar({
open: true,
message: resp.message,
variant: 'success',
duration: 2000,
}),
);
} catch (error) {
dispatch(
CommonActions.SetSnackBar({
open: true,
message: error?.response?.data?.detail || 'Failed to update Form',
variant: 'error',
duration: 2000,
}),
);
dispatch(CreateProjectActions.SetPostFormUpdateLoading(false));
Expand Down Expand Up @@ -525,10 +500,8 @@ const EditProjectBoundaryService = (url: string, geojsonUpload: any, dimension:
dispatch(CreateProjectActions.SetEditProjectBoundaryServiceLoading(false));
dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'Project Boundary Successfully Updated',
variant: 'success',
duration: 2000,
}),
);
} catch (error) {
Expand Down Expand Up @@ -556,20 +529,15 @@ const ValidateCustomForm = (url: string, formUpload: any) => {
dispatch(CreateProjectActions.ValidateCustomFormLoading(false));
dispatch(
CommonActions.SetSnackBar({
open: true,
message: JSON.stringify(resp.message),
variant: 'success',
duration: 2000,
}),
);
dispatch(CreateProjectActions.SetCustomFileValidity(true));
} catch (error) {
dispatch(
CommonActions.SetSnackBar({
open: true,
message: error?.response?.data?.detail || 'Something Went Wrong',
variant: 'error',
duration: 5000,
}),
);
dispatch(CreateProjectActions.ValidateCustomFormLoading(false));
Expand All @@ -590,10 +558,8 @@ const DeleteProjectService = (url: string, hasRedirect: boolean = true) => {
await API.delete(url);
dispatch(
CommonActions.SetSnackBar({
open: true,
message: `Project deleted. ${hasRedirect && 'Redirecting...'}`,
variant: 'success',
duration: 2000,
}),
);
// Redirect to homepage
Expand All @@ -606,10 +572,8 @@ const DeleteProjectService = (url: string, hasRedirect: boolean = true) => {
if (error.response.status === 404) {
dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'Project already deleted',
variant: 'success',
duration: 2000,
}),
);
} else {
Expand All @@ -629,10 +593,7 @@ const AssignProjectManager = (url: string, params: { id: number; project_id: num
} catch (error) {
dispatch(
CommonActions.SetSnackBar({
open: true,
message: error.response.data.detail || 'Could not assign project manager',
variant: 'error',
duration: 2000,
}),
);
}
Expand Down
23 changes: 0 additions & 23 deletions src/frontend/src/api/OrganisationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,20 +100,15 @@ export const PostOrganisationDataService = (url: string, payload: any) => {

dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'Organization Request Submitted.',
variant: 'success',
duration: 2000,
}),
);
} catch (error: any) {
dispatch(OrganisationAction.PostOrganisationDataLoading(false));
dispatch(
CommonActions.SetSnackBar({
open: true,
message: error.response.data.detail || 'Failed to create organization.',
variant: 'error',
duration: 2000,
}),
);
}
Expand All @@ -134,10 +129,7 @@ export const GetIndividualOrganizationService = (url: string) => {
} catch (error) {
dispatch(
CommonActions.SetSnackBar({
open: true,
message: error.response.data.detail || 'Failed to fetch organization.',
variant: 'error',
duration: 2000,
}),
);
}
Expand Down Expand Up @@ -167,20 +159,15 @@ export const PatchOrganizationDataService = (url: string, payload: any) => {
dispatch(OrganisationAction.SetOrganisationFormData({}));
dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'Organization Updated Successfully.',
variant: 'success',
duration: 2000,
}),
);
} catch (error: any) {
dispatch(OrganisationAction.PostOrganisationDataLoading(false));
dispatch(
CommonActions.SetSnackBar({
open: true,
message: error.response.data.detail || 'Failed to update organization.',
variant: 'error',
duration: 2000,
}),
);
}
Expand All @@ -198,10 +185,8 @@ export const ApproveOrganizationService = (url: string) => {
await axios.post(url);
dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'Organization approved successfully.',
variant: 'success',
duration: 2000,
}),
);
dispatch(OrganisationAction.SetOrganizationApproving(false));
Expand All @@ -211,10 +196,7 @@ export const ApproveOrganizationService = (url: string) => {
dispatch(OrganisationAction.SetOrganizationApproving(false));
dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'Failed to approve organization.',
variant: 'error',
duration: 2000,
}),
);
}
Expand All @@ -231,10 +213,8 @@ export const RejectOrganizationService = (url: string) => {
await axios.delete(url);
dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'Organization rejected successfully.',
variant: 'success',
duration: 2000,
}),
);
dispatch(OrganisationAction.SetOrganizationRejecting(false));
Expand All @@ -244,10 +224,7 @@ export const RejectOrganizationService = (url: string) => {
dispatch(OrganisationAction.SetOrganizationRejecting(false));
dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'Failed to reject organization.',
variant: 'error',
duration: 2000,
}),
);
}
Expand Down
12 changes: 0 additions & 12 deletions src/frontend/src/api/Project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,7 @@ export const ProjectById = (projectId: string) => {
dispatch(ProjectActions.SetProjectDetialsLoading(false));
dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'Failed to fetch project.',
variant: 'error',
duration: 2000,
}),
);
}
Expand Down Expand Up @@ -186,10 +183,7 @@ export const DownloadBasemapFile = (url: string | null) => {
if (!url) {
dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'No url associated to download basemap.',
variant: 'error',
duration: 2000,
}),
);
} else {
Expand Down Expand Up @@ -311,10 +305,7 @@ export const UpdateEntityState = (url: string, payload: { entity_id: string; sta
} catch (error) {
dispatch(
CommonActions.SetSnackBar({
open: true,
message: error?.response?.data?.detail || 'Failed to update entity state.',
variant: 'error',
duration: 2000,
}),
);
dispatch(ProjectActions.UpdateEntityStateLoading(false));
Expand All @@ -340,10 +331,7 @@ export const DownloadSubmissionGeojson = (url: string, projectName: string) => {
const errortxt = JSON.parse(await error.response.data.text()).detail;
dispatch(
CommonActions.SetSnackBar({
open: true,
message: errortxt || 'Failed to download submission geojson.',
variant: 'error',
duration: 2000,
}),
);
dispatch(ProjectActions.SetDownloadSubmissionGeojsonLoading(false));
Expand Down
12 changes: 0 additions & 12 deletions src/frontend/src/api/SubmissionService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,7 @@ export const UpdateReviewStateService = (url: string, payload: object) => {
} catch (error) {
dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'Failed to update review state.',
variant: 'error',
duration: 2000,
}),
);
dispatch(SubmissionActions.UpdateReviewStateLoading(false));
Expand Down Expand Up @@ -118,10 +115,7 @@ export const PostGeometry = (url: string, payload: geometryLogType) => {
} catch (error) {
dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'Failed to post geometry.',
variant: 'error',
duration: 2000,
}),
);
}
Expand All @@ -139,10 +133,7 @@ export const DeleteGeometry = (url: string) => {
} catch (error) {
dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'Failed to delete geometry.',
variant: 'error',
duration: 2000,
}),
);
}
Expand Down Expand Up @@ -170,10 +161,7 @@ export const downloadSubmissionGeojson = (
} catch (error) {
dispatch(
CommonActions.SetSnackBar({
open: true,
message: JSON.parse(await error.response.data.text())?.detail || 'Something went wrong',
variant: 'error',
duration: 2000,
}),
);
} finally {
Expand Down
9 changes: 2 additions & 7 deletions src/frontend/src/api/TaskEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,21 +75,16 @@ export const CreateTaskEvent = (

dispatch(CommonActions.SetLoading(false));
dispatch(
HomeActions.SetSnackBar({
open: true,
CommonActions.SetSnackBar({
message: `Task #${taskId} has been updated to ${response.data.state}`,
variant: 'success',
duration: 3000,
}),
);
} catch (error) {
dispatch(CommonActions.SetLoading(false));
dispatch(
HomeActions.SetSnackBar({
open: true,
CommonActions.SetSnackBar({
message: `Failed to update Task #${taskId}`,
variant: 'error',
duration: 4000,
}),
);
}
Expand Down
5 changes: 0 additions & 5 deletions src/frontend/src/api/User.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,14 @@ export const UpdateUserRole = (url: string, payload: { role: 'READ_ONLY' | 'ADMI
dispatch(UserActions.UpdateUserList(response.data));
dispatch(
CommonActions.SetSnackBar({
open: true,
message: `Updated ${response.data.username}'s role to ${response.data.role} successfully`,
variant: 'success',
duration: 2000,
}),
);
} catch (error) {
dispatch(
CommonActions.SetSnackBar({
open: true,
message: 'Failed to update user role',
variant: 'error',
duration: 2000,
}),
);
} finally {
Expand Down
Loading

0 comments on commit 3254adc

Please sign in to comment.