8000 Merge pull request #5 from idurar/dev · idurar/mern-admin@7d3d86b · GitHub
[go: up one dir, main page]

Skip to content

Commit 7d3d86b

Browse files
author
Salah Eddine Lalami
authored
Merge pull request #5 from idurar/dev
delete & search features fixed
2 parents 49fa5e4 + 74ae4d8 commit 7d3d86b

File tree

8 files changed

+12
-12
lines changed

8 files changed

+12
-12
lines changed

backend/controllers/crudController/crudMethods.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -221,10 +221,7 @@ exports.search = async (Model, req, res) => {
221221
}
222222

223223
try {
224-
let results = await Model.find(fields)
225-
.where("removed", false)
226-
.sort({ name: "asc" })
227-
.limit(10);
224+
let results = await Model.find(fields).sort({ name: "asc" }).limit(10);
228225

229226
if (results.length >= 1) {
230227
return res.status(200).json({

frontend/src/components/DeleteModal/index.jsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ export default function DeleteModal({ config }) {
2525
if (isSuccess) {
2626
modal.close();
2727
dispatch(crud.list(entity));
28+
dispatch(crud.resetAction(entity));
2829
}
2930
if (current) {
3031
let labels = entityDisplayLabels

frontend/src/components/RecentTable/index.jsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,16 @@ export default function RecentTable({ ...props }) {
4848
return request.list(entity);
4949
};
5050
const { result, isLoading, isSuccess } = useFetch(asyncList);
51-
51+
const firstFiveItems = () => {
52+
if (isSuccess && result) return result.slice(0, 5);
53+
return [];
54+
};
5255
return (
5356
<>
5457
<Table
5558
columns={dataTableColumns}
5659
rowKey={(item) => item._id}
57-
dataSource={isSuccess && result}
60+
dataSource={isSuccess && firstFiveItems()}
5861
pagination={false}
5962
loading={isLoading}
6063
/>
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export const API_BASE_URL = "https://antd-admin-mern.idurar.net/api/";
2+
// export const API_BASE_URL = "http://localhost:8888/api/";
23
export const ACCESS_TOKEN_NAME = "x-auth-token";

frontend/src/modules/CrudModule/index.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function FixHeaderPanel({ config }) {
5757
);
5858
}
5959

60-
function CrudModule({ config, createForm, updateForm }) {
60+
export default function CrudModule({ config, createForm, updateForm }) {
6161
const dispatch = useDispatch();
6262

6363
useLayoutEffect(() => {
@@ -80,5 +80,3 @@ function CrudModule({ config, createForm, updateForm }) {
8080
</CrudLayout>
8181
);
8282
}
83-
84-
export default CrudModule;

frontend/src/pages/Customer.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import CustomerForm from "@/forms/CustomerForm";
66
function Customer() {
77
const entity = "client";
88
const searchConfig = {
9-
displayLabels: ["company"],
9+
displayLabels: ["company", "surname", "name"],
1010
searchFields: "company,surname,name",
1111
outputValue: "_id",
1212
};

frontend/src/pages/Product.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ function Product() {
77
const entity = "product";
88
const searchConfig = {
99
displayLabels: ["productName"],
10-
searchFields: "productName,surname,name",
10+
searchFields: "productName",
1111
outputValue: "_id",
1212
};
1313

frontend/src/redux/crud/reducer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ const crudReducer = (state = INITIAL_STATE, action) => {
7373
return {
7474
...state,
7575
[keyState]: {
76-
...state[keyState],
76+
...INITIAL_KEY_STATE,
7777
current: payload,
7878
},
7979
};

0 commit comments

Comments
 (0)
0