Skip to content

Commit

Permalink
Merge pull request #5 from idurar/dev
Browse files Browse the repository at this point in the history
delete & search features fixed
  • Loading branch information
Salah Eddine Lalami authored Jul 21, 2021
2 parents 49fa5e4 + 74ae4d8 commit 7d3d86b
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 12 deletions.
5 changes: 1 addition & 4 deletions backend/controllers/crudController/crudMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,7 @@ exports.search = async (Model, req, res) => {
}

try {
let results = await Model.find(fields)
.where("removed", false)
.sort({ name: "asc" })
.limit(10);
let results = await Model.find(fields).sort({ name: "asc" }).limit(10);

if (results.length >= 1) {
return res.status(200).json({
Expand Down
1 change: 1 addition & 0 deletions frontend/src/components/DeleteModal/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export default function DeleteModal({ config }) {
if (isSuccess) {
modal.close();
dispatch(crud.list(entity));
dispatch(crud.resetAction(entity));
}
if (current) {
let labels = entityDisplayLabels
Expand Down
7 changes: 5 additions & 2 deletions frontend/src/components/RecentTable/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,16 @@ export default function RecentTable({ ...props }) {
return request.list(entity);
};
const { result, isLoading, isSuccess } = useFetch(asyncList);

const firstFiveItems = () => {
if (isSuccess && result) return result.slice(0, 5);
return [];
};
return (
<>
<Table
columns={dataTableColumns}
rowKey={(item) => item._id}
dataSource={isSuccess && result}
dataSource={isSuccess && firstFiveItems()}
pagination={false}
loading={isLoading}
/>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/config/serverApiConfig.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export const API_BASE_URL = "https://antd-admin-mern.idurar.net/api/";
// export const API_BASE_URL = "http://localhost:8888/api/";
export const ACCESS_TOKEN_NAME = "x-auth-token";
4 changes: 1 addition & 3 deletions frontend/src/modules/CrudModule/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ function FixHeaderPanel({ config }) {
);
}

function CrudModule({ config, createForm, updateForm }) {
export default function CrudModule({ config, createForm, updateForm }) {
const dispatch = useDispatch();

useLayoutEffect(() => {
Expand All @@ -80,5 +80,3 @@ function CrudModule({ config, createForm, updateForm }) {
</CrudLayout>
);
}

export default CrudModule;
2 changes: 1 addition & 1 deletion frontend/src/pages/Customer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import CustomerForm from "@/forms/CustomerForm";
function Customer() {
const entity = "client";
const searchConfig = {
displayLabels: ["company"],
displayLabels: ["company", "surname", "name"],
searchFields: "company,surname,name",
outputValue: "_id",
};
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/pages/Product.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function Product() {
const entity = "product";
const searchConfig = {
displayLabels: ["productName"],
searchFields: "productName,surname,name",
searchFields: "productName",
outputValue: "_id",
};

Expand Down
2 changes: 1 addition & 1 deletion frontend/src/redux/crud/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const crudReducer = (state = INITIAL_STATE, action) => {
return {
...state,
[keyState]: {
...state[keyState],
...INITIAL_KEY_STATE,
current: payload,
},
};
Expand Down

0 comments on commit 7d3d86b

Please sign in to comment.