Skip to content

Commit 0863674

Browse files
FWF-4550:[Feature] -updated pr comments.
- Removed axios and used request service instead - added submission type and a seperate file
1 parent 5a7364f commit 0863674

File tree

9 files changed

+140
-152
lines changed

9 files changed

+140
-152
lines changed

forms-flow-submissions/package-lock.json

Lines changed: 51 additions & 67 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

forms-flow-submissions/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@
6060
"@tanstack/react-query": "^4.29.15",
6161
"@types/systemjs": "^6.1.1",
6262
"@types/webpack-env": "^1.16.2",
63-
"axios": "^1.9.0",
6463
"connected-react-router": "^6.9.2",
6564
"history": "^4.10.1",
6665
"i18next": "^25.2.1",

forms-flow-submissions/src/Routes/SubmissionListing.tsx

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@ import { useDispatch, useSelector } from "react-redux";
33
import { useQuery } from "@tanstack/react-query";
44
import { useTranslation } from "react-i18next";
55
import { push } from "connected-react-router";
6-
6+
import { Submission } from "../types/submissions";
77
import { getSubmissionList } from "../api/queryServices/analyzeSubmissionServices";
88
import { formatDate } from "../helper/helper";
99
import {
1010
setAnalyzeSubmissionSort,
1111
setAnalyzeSubmissionPage,
12+
setAnalyzeSubmissionLimit,
1213
} from "../actions/analyzeSubmissionActions";
1314
import {
1415
ReusableResizableTable,
@@ -18,16 +19,6 @@ import {
1819
} from "@formsflow/components";
1920
import { MULTITENANCY_ENABLED } from "../constants";
2021

21-
type Submission = {
22-
applicationStatus: string;
23-
createdBy: string;
24-
data: any;
25-
formName: string;
26-
id: string;
27-
submissionId: string;
28-
created?: string;
29-
};
30-
3122
interface Column {
3223
name: string;
3324
width: number;
@@ -39,11 +30,12 @@ const TaskSubmissionList: React.FC = () => {
3930
const { t } = useTranslation();
4031
const dispatch = useDispatch();
4132
const scrollWrapperRef = useRef<HTMLDivElement>(null);
42-
const [limit, setLimit] = useState(10);
43-
4433
const sortParams = useSelector(
4534
(state: any) => state?.analyzeSubmission.analyzeSubmissionSortParams ?? {}
4635
);
36+
const limit = useSelector(
37+
(state: any) => state?.analyzeSubmission.limit ?? 10
38+
);
4739
const { page } = useSelector(
4840
(state: any) => state?.analyzeSubmission.page ?? 1
4941
);
@@ -193,7 +185,7 @@ const TaskSubmissionList: React.FC = () => {
193185
);
194186

195187
const handleLimitChange = (newLimit: number) => {
196-
setLimit(newLimit);
188+
setAnalyzeSubmissionLimit(newLimit);
197189
setAnalyzeSubmissionPage(1);
198190
};
199191

@@ -214,6 +206,7 @@ const TaskSubmissionList: React.FC = () => {
214206
"No submissions have been found. Try a different filter combination or contact your admin."
215207
)}
216208
onColumnResize={(newWidths) =>
209+
//TBD
217210
console.log("Column resized:", newWidths)
218211
}
219212
tableClassName="resizable-table"
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export default {
22
UPDATE_SUBMISSION_SORT_PARAMS:"UPDATE_SUBMISSION_SORT_PARAMS",
33
UPDATE_SUBMISSION_PAGE: "UPDATE_SUBMISSION_PAGE",
4+
UPDATE_SUBMISSION_LIMIT: "UPDATE_SUBMISSION_LIMIT"
45
};

forms-flow-submissions/src/actions/analyzeSubmissionActions.ts

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,23 @@
11
import ACTION_CONSTANTS from "../constants/actionConstants";
22

33
export const setAnalyzeSubmissionSort = (data) => (dispatch) => {
4-
dispatch({
5-
type: ACTION_CONSTANTS.UPDATE_SUBMISSION_SORT_PARAMS,
6-
payload: data,
7-
});
8-
};
9-
10-
export const setAnalyzeSubmissionPage = (data) => (dispatch) => {
11-
dispatch({
12-
type: ACTION_CONSTANTS.UPDATE_SUBMISSION_PAGE,
13-
payload: data,
14-
});
15-
};
4+
dispatch({
5+
type: ACTION_CONSTANTS.UPDATE_SUBMISSION_SORT_PARAMS,
6+
payload: data,
7+
});
8+
};
9+
10+
export const setAnalyzeSubmissionPage = (data) => (dispatch) => {
11+
dispatch({
12+
type: ACTION_CONSTANTS.UPDATE_SUBMISSION_PAGE,
13+
payload: data,
14+
});
15+
};
16+
export const setAnalyzeSubmissionLimit = (data) => (dispatch) => {
17+
dispatch({
18+
type: ACTION_CONSTANTS.UPDATE_SUBMISSION_LIMIT,
19+
payload: data,
20+
});
21+
};
22+
1623

17-
Lines changed: 41 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,62 +1,46 @@
11
import API from "../endpoints";
2-
import { StorageService } from "@formsflow/service";
3-
import axios from "axios";
2+
import { StorageService, RequestService } from "@formsflow/service";
3+
import { SubmissionListResponse } from "../../types/submissions";
44

55

6-
type Submission = {
7-
applicationStatus: string;
8-
createdBy: string;
9-
data: any;
10-
formName: string;
11-
id: string;
12-
submissionId: string;
13-
};
14-
15-
type SubmissionListResponse = {
16-
submissions: Submission[];
17-
totalCount: number;
18-
pageNo: number;
19-
limit: number;
20-
};
21-
22-
export const getSubmissionList = (
23-
limit = 10,
24-
pageNo = 1,
25-
sortOrder = "asc",
26-
sortBy = "formName"
27-
): Promise<SubmissionListResponse> => {
28-
const query = `
29-
query MyQuery {
30-
getSubmission(limit: ${limit}, pageNo: ${pageNo}, sortOrder: "${sortOrder}", sortBy: "${sortBy}") {
31-
submissions {
32-
applicationStatus
33-
createdBy
34-
data
35-
formName
36-
id
37-
submissionId
38-
created
39-
}
40-
totalCount
41-
pageNo
42-
limit
6+
export const getSubmissionList = (
7+
limit = 10,
8+
pageNo = 1,
9+
sortOrder = "asc",
10+
sortBy = "formName"
11+
): Promise<SubmissionListResponse> => {
12+
const query = `
13+
query MyQuery {
14+
getSubmission(limit: ${limit}, pageNo: ${pageNo}, sortOrder: "${sortOrder}", sortBy: "${sortBy}") {
15+
submissions {
16+
applicationStatus
17+
createdBy
18+
data
19+
formName
20+
id
21+
submissionId
22+
created
4323
}
24+
totalCount
25+
pageNo
26+
limit
4427
}
45-
`;
46-
47-
const payload = { query };
48-
const token = StorageService.get("AUTH_TOKEN");
49-
50-
return axios
51-
.post(API.GRAPHQL_API, payload, {
52-
headers: {
53-
"Content-Type": "application/json",
54-
Authorization: token ? `Bearer ${token}` : "",
55-
},
56-
})
57-
.then((response) => {
58-
const result = response.data?.data?.getSubmission;
59-
return result;
60-
});
61-
};
62-
28+
}
29+
`;
30+
31+
const payload = { query };
32+
const token = StorageService.get("AUTH_TOKEN");
33+
34+
return RequestService.httpPOSTRequest(
35+
API.GRAPHQL_API,
36+
payload,
37+
token,
38+
true,
39+
{
40+
"Content-Type": "application/json"
41+
}
42+
).then((response) => {
43+
const result = response.data?.data?.getSubmission;
44+
return result;
45+
});
46+
};

forms-flow-submissions/src/constants/actionConstants.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
export default {
33
UPDATE_SUBMISSION_SORT_PARAMS:"UPDATE_SUBMISSION_SORT_PARAMS",
44
UPDATE_SUBMISSION_PAGE: "UPDATE_SUBMISSION_PAGE",
5+
UPDATE_SUBMISSION_LIMIT: "UPDATE_SUBMISSION_LIMIT",
56
}

forms-flow-submissions/src/reducers/analizeSubmissionReducer.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ const initialState = {
99
submissionDate: { sortOrder: "asc" },
1010
applicationStatus: { sortOrder: "asc" },
1111
},
12+
page: 1,
13+
limit: 10,
1214
};
1315

1416

@@ -19,6 +21,8 @@ const analyzeSubmission = (state = initialState, action: any) => {
1921
return { ...state, analyzeSubmissionSortParams: action.payload };
2022
case ACTION_CONSTANTS.UPDATE_SUBMISSION_PAGE:
2123
return { ...state, page: action.payload };
24+
case ACTION_CONSTANTS.UPDATE_SUBMISSION_LIMIT:
25+
return { ...state, limit: action.payload };
2226
default:
2327
return state;
2428
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
export type Submission = {
2+
applicationStatus: string;
3+
createdBy: string;
4+
data: any;
5+
formName: string;
6+
id: string;
7+
submissionId: string;
8+
created?: string;
9+
};
10+
11+
export type SubmissionListResponse = {
12+
submissions: Submission[];
13+
totalCount: number;
14+
pageNo: number;
15+
limit: number;
16+
};

0 commit comments

Comments
 (0)