Skip to content

Commit

Permalink
Merge pull request #143 from Red-Stream-Y3/feature/dinushka/admin
Browse files Browse the repository at this point in the history
revert user email order list
  • Loading branch information
it21047824 authored May 11, 2023
2 parents efc589d + d3aafb1 commit 9851221
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions FrontEnd/herbal-store/src/actions/adminActions.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,6 @@ export const getAllUsers = async (setter) => {
export const getAllOrders = async (setter) => {
const orders = await axios.get('http://localhost:9124/api/orders', config);

orders.data.forEach( async (order) => {
order.user = (await axios.get(`http://localhost:9120/api/users/${order.user}`, config)).data;
});

setter(orders.data);
};

Expand Down Expand Up @@ -69,7 +65,11 @@ export const getOrderById = async (id, setter) => {
//User
export const getUserById = async (id, setter) => {
const user = await axios.get(`http://localhost:9120/api/users/${id}`, config);
setter(user.data);

if(setter){
setter(user.data);
}
return(user.data);
};

//Commission rate
Expand Down
8 changes: 4 additions & 4 deletions FrontEnd/herbal-store/src/components/adminDash/OrderList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ const OrderList = (props) => {

//get selected order and user
await getOrderById(orders[index]._id, setSelectOrder);
await getUserById(orders[index].user._id, setSelectOrderUser);
await getUserById(orders[index].user, setSelectOrderUser);

}

Expand All @@ -145,7 +145,7 @@ const OrderList = (props) => {

//get selected order and user
await getOrderById(orders[index]._id, setSelectOrder);
await getUserById(orders[index].user._id, setSelectOrderUser);
await getUserById(orders[index].user, setSelectOrderUser);
}

//hide popup when clicked outside of popup content or cancel button
Expand Down Expand Up @@ -179,7 +179,7 @@ const OrderList = (props) => {
<thead>
<tr>
<th className={tableHeaderClasses}>Order Date</th>
<th className={tableHeaderClasses}>User</th>
<th className={tableHeaderClasses}>Order ID</th>
<th className={tableHeaderClasses}>Order Total</th>
<th className={tableHeaderClasses}>Order Status</th>
<th className={tableHeaderClasses}>Confirmation</th>
Expand All @@ -193,7 +193,7 @@ const OrderList = (props) => {
<td className="px-6 py-4">
{order.createdAt.split("T")[0]}
</td>
<td className="px-6 py-4">{order.user.email}</td>
<td className="px-6 py-4">...{order._id.slice(18)}</td>
<td className="px-6 py-4">
${order.totalPrice}
</td>
Expand Down
2 changes: 1 addition & 1 deletion FrontEnd/herbal-store/src/pages/AdminDash.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ const AdminDash = () => {
"hidden transition-all ease-in fixed left-0 top-0 right-0 z-10 w-screen h-screen p-4 bg-black bg-opacity-50";
const cardClasses = "bg-darkbg rounded-lg px-10 py-8 m-auto";
const tableHeaderClasses =
"sticky top-0 px-6 py-3 w-2/12 text-sm uppercase bg-gray-700 text-gray-400";
"sticky top-0 px-6 py-3 text-sm uppercase bg-gray-700 text-gray-400";
const breadcrumbClasses = "transition-all hover:cursor-pointer hover:underline";
const filterButtonClasses = "transition-all ml-2 w-24 w-auto inline-block text-slate-500 hover:cursor-pointer hover:underline";

Expand Down

0 comments on commit 9851221

Please sign in to comment.