Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS types add to services #1737

Merged
merged 8 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions src/frontend/src/api/CreateProjectService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import { CommonActions } from '@/store/slices/CommonSlice';
import { ValidateCustomFormResponse } from '@/store/types/ICreateProject';
import { isStatusSuccess } from '@/utilfunctions/commonUtils';

const CreateProjectService: Function = (
const CreateProjectService = (
url: string,
projectData: any,
taskAreaGeojson: any,
Expand Down Expand Up @@ -110,11 +110,11 @@ const CreateProjectService: Function = (
};
};

const FormCategoryService: Function = (url: string) => {
const FormCategoryService = (url: string) => {
return async (dispatch) => {
dispatch(CreateProjectActions.GetFormCategoryLoading(true));

const getFormCategoryList = async (url) => {
const getFormCategoryList = async (url: string) => {
try {
const getFormCategoryListResponse = await axios.get(url);
const resp: FormCategoryListModel = getFormCategoryListResponse.data;
Expand All @@ -128,10 +128,10 @@ const FormCategoryService: Function = (url: string) => {
};
};

const UploadTaskAreasService: Function = (url: string, filePayload: any, projectData: any) => {
const UploadTaskAreasService = (url: string, filePayload: any, projectData: any) => {
return async (dispatch) => {
dispatch(CreateProjectActions.UploadAreaLoading(true));
const postUploadArea = async (url, filePayload) => {
const postUploadArea = async (url: string, filePayload: any) => {
let isAPISuccess = true;
try {
const areaFormData = new FormData();
Expand Down Expand Up @@ -169,7 +169,7 @@ const UploadTaskAreasService: Function = (url: string, filePayload: any, project
};
};

const GenerateProjectFilesService: Function = (url: string, projectData: any, formUpload: any) => {
const GenerateProjectFilesService = (url: string, projectData: any, formUpload: any) => {
return async (dispatch) => {
dispatch(CreateProjectActions.GenerateProjectLoading(true));
dispatch(CommonActions.SetLoading(true));
Expand Down Expand Up @@ -221,11 +221,11 @@ const GenerateProjectFilesService: Function = (url: string, projectData: any, fo
};
};

const OrganisationService: Function = (url: string) => {
const OrganisationService = (url: string) => {
return async (dispatch) => {
dispatch(CreateProjectActions.GetOrganisationListLoading(true));

const getOrganisationList = async (url) => {
const getOrganisationList = async (url: string) => {
try {
const getOrganisationListResponse = await axios.get(url);
const resp: OrganisationListModel = getOrganisationListResponse.data;
Expand All @@ -239,11 +239,11 @@ const OrganisationService: Function = (url: string) => {
};
};

const GetDividedTaskFromGeojson: Function = (url: string, projectData: any) => {
const GetDividedTaskFromGeojson = (url: string, projectData: Record<string, any>) => {
return async (dispatch) => {
dispatch(CreateProjectActions.SetDividedTaskFromGeojsonLoading(true));

const getDividedTaskFromGeojson = async (url, projectData) => {
const getDividedTaskFromGeojson = async (url: string, projectData: Record<string, any>) => {
try {
const dividedTaskFormData = new FormData();
dividedTaskFormData.append('project_geojson', projectData.geojson);
Expand All @@ -265,13 +265,13 @@ const GetDividedTaskFromGeojson: Function = (url: string, projectData: any) => {
};
};

const GetIndividualProjectDetails: Function = (url: string, projectData: any) => {
const GetIndividualProjectDetails = (url: string) => {
return async (dispatch) => {
dispatch(CreateProjectActions.SetIndividualProjectDetailsLoading(true));

const getIndividualProjectDetails = async (url, projectData) => {
const getIndividualProjectDetails = async (url: string) => {
try {
const getIndividualProjectDetailsResponse = await axios.get(url, { params: projectData });
const getIndividualProjectDetailsResponse = await axios.get(url);
const resp: ProjectDetailsModel = getIndividualProjectDetailsResponse.data;
const formattedOutlineGeojson = { type: 'FeatureCollection', features: [{ ...resp.outline_geojson, id: 1 }] };
const modifiedResponse = {
Expand All @@ -292,11 +292,11 @@ const GetIndividualProjectDetails: Function = (url: string, projectData: any) =>
}
};

await getIndividualProjectDetails(url, projectData);
await getIndividualProjectDetails(url);
};
};

const TaskSplittingPreviewService: Function = (
const TaskSplittingPreviewService = (
url: string,
projectAoiFile: any,
no_of_buildings: string,
Expand All @@ -305,7 +305,7 @@ const TaskSplittingPreviewService: Function = (
return async (dispatch) => {
dispatch(CreateProjectActions.GetTaskSplittingPreviewLoading(true));

const getTaskSplittingGeojson = async (url, projectAoiFile, dataExtractFile) => {
const getTaskSplittingGeojson = async (url: string, projectAoiFile: any, dataExtractFile: any) => {
try {
const taskSplittingFileFormData = new FormData();
taskSplittingFileFormData.append('project_geojson', projectAoiFile);
Expand Down Expand Up @@ -343,11 +343,11 @@ const TaskSplittingPreviewService: Function = (
await getTaskSplittingGeojson(url, projectAoiFile, dataExtractFile);
};
};
const PatchProjectDetails: Function = (url: string, projectData: any) => {
const PatchProjectDetails = (url: string, projectData: Record<string, any>) => {
return async (dispatch) => {
dispatch(CreateProjectActions.SetPatchProjectDetailsLoading(true));

const patchProjectDetails = async (url, projectData) => {
const patchProjectDetails = async (url: string, projectData: Record<string, any>) => {
try {
const getIndividualProjectDetailsResponse = await axios.patch(url, projectData);
const resp: ProjectDetailsModel = getIndividualProjectDetailsResponse.data;
Expand All @@ -373,11 +373,11 @@ const PatchProjectDetails: Function = (url: string, projectData: any) => {
};
};

const PostFormUpdate: Function = (url: string, projectData: any) => {
const PostFormUpdate = (url: string, projectData: Record<string, any>) => {
return async (dispatch) => {
dispatch(CreateProjectActions.SetPostFormUpdateLoading(true));

const postFormUpdate = async (url, projectData) => {
const postFormUpdate = async (url: string, projectData: Record<string, any>) => {
try {
const formFormData = new FormData();
formFormData.append('xform_id', projectData.xformId);
Expand Down Expand Up @@ -415,11 +415,11 @@ const PostFormUpdate: Function = (url: string, projectData: any) => {
await postFormUpdate(url, projectData);
};
};
const EditProjectBoundaryService: Function = (url: string, geojsonUpload: any, dimension: any) => {
const EditProjectBoundaryService = (url: string, geojsonUpload: any, dimension: any) => {
return async (dispatch) => {
dispatch(CreateProjectActions.SetEditProjectBoundaryServiceLoading(true));

const postFormUpdate = async (url, geojsonUpload, dimension) => {
const postFormUpdate = async (url: string, geojsonUpload: any, dimension: any) => {
try {
const editBoundaryFormData = new FormData();
editBoundaryFormData.append('project_geojson', geojsonUpload);
Expand Down Expand Up @@ -450,7 +450,7 @@ const EditProjectBoundaryService: Function = (url: string, geojsonUpload: any, d
};
};

const ValidateCustomForm: Function = (url: string, formUpload: any) => {
const ValidateCustomForm = (url: string, formUpload: any) => {
return async (dispatch) => {
dispatch(CreateProjectActions.ValidateCustomFormLoading(true));

Expand Down Expand Up @@ -492,7 +492,7 @@ const ValidateCustomForm: Function = (url: string, formUpload: any) => {
};
};

const DeleteProjectService: Function = (url: string, hasRedirect: boolean = true) => {
const DeleteProjectService = (url: string, hasRedirect: boolean = true) => {
return async (dispatch) => {
const deleteProject = async (url: string) => {
try {
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/api/HomeService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const HomeSummaryService: Function = (url: string) => {
return async (dispatch) => {
dispatch(HomeActions.HomeProjectLoading(true));

const fetchHomeSummaries = async (url) => {
const fetchHomeSummaries = async (url: string) => {
try {
const fetchHomeData = await axios.get(url);
const projectSummaries: any = fetchHomeData.data.results;
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/api/Login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { LoginActions } from '@/store/slices/LoginSlice';

export const TemporaryLoginService: Function = (url: string) => {
return async (dispatch) => {
const getTemporaryLogin = async (url) => {
const getTemporaryLogin = async (url: string) => {
// Sets a cookie in the browser that is used for auth
await axios.get(url);

Expand Down
10 changes: 5 additions & 5 deletions src/frontend/src/api/OrganisationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { OrganisationAction } from '@/store/slices/organisationSlice';
import { API } from '.';
import { LoginActions } from '@/store/slices/LoginSlice';

function appendObjectToFormData(formData, object) {
function appendObjectToFormData(formData: FormData, object: Record<string, any>) {
for (const [key, value] of Object.entries(object)) {
// if (key === 'logo') {
// formData.append(key, value[0])
Expand All @@ -19,7 +19,7 @@ export const OrganisationService: Function = (url: string, payload: Organisation
return async (dispatch) => {
dispatch(CommonActions.PostOrganisationLoading(true));

const postOrganisation = async (url, payload) => {
const postOrganisation = async (url: string, payload: OrganisationModal) => {
try {
const generateApiFormData = new FormData();
appendObjectToFormData(generateApiFormData, payload);
Expand All @@ -43,7 +43,7 @@ export const OrganisationService: Function = (url: string, payload: Organisation
export const OrganisationDataService: Function = (url: string) => {
return async (dispatch) => {
dispatch(OrganisationAction.GetOrganisationDataLoading(true));
const getOrganisationData = async (url) => {
const getOrganisationData = async (url: string) => {
try {
const getOrganisationDataResponse = await API.get(url);
const response: GetOrganisationDataModel = getOrganisationDataResponse.data;
Expand All @@ -63,7 +63,7 @@ export const OrganisationDataService: Function = (url: string) => {
export const MyOrganisationDataService: Function = (url: string) => {
return async (dispatch) => {
dispatch(OrganisationAction.GetMyOrganisationDataLoading(true));
const getMyOrganisationData = async (url) => {
const getMyOrganisationData = async (url: string) => {
try {
const getMyOrganisationDataResponse = await API.get(url);
const response: GetOrganisationDataModel[] = getMyOrganisationDataResponse.data;
Expand Down Expand Up @@ -126,7 +126,7 @@ export const PostOrganisationDataService: Function = (url: string, payload: any)
export const GetIndividualOrganizationService: Function = (url: string) => {
return async (dispatch) => {
dispatch(OrganisationAction.SetOrganisationFormData({}));
const getOrganisationData = async (url) => {
const getOrganisationData = async (url: string) => {
try {
const getOrganisationDataResponse = await axios.get(url);
const response: GetOrganisationDataModel = getOrganisationDataResponse.data;
Expand Down
Loading
Loading