Skip to content

Commit

Permalink
Important Changes
Browse files Browse the repository at this point in the history
  • Loading branch information
theknowledgepro committed Mar 30, 2023
1 parent 9746035 commit cc66051
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 41 deletions.
4 changes: 2 additions & 2 deletions src/pages/Dashboard/Dashboard.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const Dashboard = () => {
getData();
}, 60000);
return () => clearInterval(interval);
}, [dispatch]);
}, []);
return (
<React.Fragment>
{/** DASHBOARD SIDEPANEL SECTION */}
Expand Down Expand Up @@ -208,7 +208,7 @@ const Dashboard = () => {
boxShadow="1px 1px 2px 0 rgba(42, 141, 0, 0.3)"
>
<Box w="100%" fontWeight={600} p="10px" fontSize="15px">
Recent Collections
{!pathname.includes("history") ? 'Recent Collections' : 'Your Collections History'}
</Box>
<Outlet />
</Box>
Expand Down
12 changes: 7 additions & 5 deletions src/pages/Dashboard/history_.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export default function Recent() {
}, [data, token]);
useEffect(() => {
fetchAndUpdateData();
}, [fetchAndUpdateData]);
}, [items]);

return (
<>
Expand Down Expand Up @@ -105,7 +105,7 @@ export default function Recent() {
</Tr>
</Thead>
<Tbody>
{newData?.map((item, index) => {
{newData?.reverse()?.map((item, index) => {
return (
<Tr key={item._id}>
<Td>{index + 1}</Td>
Expand All @@ -117,12 +117,13 @@ export default function Recent() {
onOpen();
setWastepic({
image: item.images[0],
Text: item.address,
address: item.address,
description: item.description,
amount: item.quantity,
});
}}
>
<Avatar src={item.images[0]} mr="5px" size="sm" />
<Avatar borderRadius='5px' src={item.images[0]} mr="5px" size="sm" />
<Text my='auto'>{item.Fullname}</Text>
</div>
</Tooltip>
Expand Down Expand Up @@ -168,7 +169,8 @@ export default function Recent() {
<Box>
<Image maxH={{ base: '350px', md: '400px' }} width='100%' height='100%' src={Wastepic.image} alt="waste Picture" />
</Box>
<Text mt='10px' fontWeight={600} color={useColors.appGreen}>Address: <span style={{ color: '#000' }}>{Wastepic.Text}</span></Text>
<Text mt='10px' fontWeight={700} color={useColors.appGreen}>Address: <span style={{ color: '#000' }}>{Wastepic.address}</span></Text>
<Text mt='10px' fontWeight={700} color={useColors.appGreen}>Alert Description: <span style={{ color: '#000' }}>{Wastepic.description}</span></Text>
<Text mt='10px' fontWeight={700} color={useColors.appGreen}>Amount in Kg: <span style={{ color: '#000' }}>{Wastepic.amount}kg</span></Text>
</ModalBody>
<ModalFooter>
Expand Down
24 changes: 11 additions & 13 deletions src/pages/Dashboard/recent.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,6 @@ export default function Recent() {
});
const token = setToken();
const [newData, SetnewData] = useState([]);
const OverlayOne = () => (
<ModalOverlay
bg="blackAlpha.300"
backdropFilter="blur(10px) hue-rotate(90deg)"
/>
);

const { isOpen, onOpen, onClose } = useDisclosure();
const [Wastepic, setWastepic] = useState({});
Expand Down Expand Up @@ -75,10 +69,12 @@ export default function Recent() {
});
const newdata = await Promise.all(promises);
SetnewData(newdata);
}, [data, token]);
}, [items, data, token]);

useEffect(() => {
fetchAndUpdateData();
}, [fetchAndUpdateData]);
}, [items]);

return (
<>
{" "}
Expand Down Expand Up @@ -106,7 +102,7 @@ export default function Recent() {
</Tr>
</Thead>
<Tbody>
{newData?.map((item, index) => {
{newData?.reverse()?.map((item, index) => {
return (
<Tr key={item._id}>
<Td>{index + 1}</Td>
Expand All @@ -118,13 +114,14 @@ export default function Recent() {
onOpen();
setWastepic({
image: item.images[0],
Text: item.address,
address: item.address,
description:item.description,
amount: item.quantity,
});
}}
>
<Avatar src={item.images[0]} mr="5px" size="sm" />
{item.Fullname}
<Avatar borderRadius='5px' src={item.images[0]} mr="5px" size="sm" />
<Text my='auto'>{item.Fullname}</Text>
</div>
</Tooltip>
</Td>
Expand Down Expand Up @@ -172,7 +169,8 @@ export default function Recent() {
<Box>
<Image maxH={{ base: '350px', md: '400px' }} width='100%' height='100%' src={Wastepic.image} alt="waste Picture" />
</Box>
<Text mt='10px' fontWeight={600} color={useColors.appGreen}>Address: <span style={{ color: '#000' }}>{Wastepic.Text}</span></Text>
<Text mt='10px' fontWeight={700} color={useColors.appGreen}>Address: <span style={{ color: '#000' }}>{Wastepic.address}</span></Text>
<Text mt='10px' fontWeight={700} color={useColors.appGreen}>Alert Description: <span style={{ color: '#000' }}>{Wastepic.description}</span></Text>
<Text mt='10px' fontWeight={700} color={useColors.appGreen}>Amount in Kg: <span style={{ color: '#000' }}>{Wastepic.amount}kg</span></Text>
</ModalBody>
<ModalFooter>
Expand Down
35 changes: 14 additions & 21 deletions src/store/alerts.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,16 +13,12 @@ const Alertdata = createSlice({
initialState: initialState,
reducers: {
AcceptingUpdate(state) {
state.Accepted = state.items
.filter((item) => {
return item.status === "accepted" && item.collectorId === state.user;
})
.reduce((initial, item) => {
if (item.status === "accepted") {
return initial + 1;
}
return initial;
}, 0);
state.Accepted = state.items.reduce((initial, item) => {
if (item.status === "accepted" && item.collectorId === state.user) {
return initial + 1;
}
return initial;
}, 0);
},
pendingUpdate(state) {
state.pending = state.items.reduce((initial, item) => {
Expand All @@ -33,16 +29,12 @@ const Alertdata = createSlice({
}, 0);
},
completedUpdate(state) {
state.completed = state.items
.filter((item) => {
return item.status === "collected" && item.collectorId === state.user;
})
.reduce((initial, item) => {
if (item.status === "collected") {
return initial + 1;
}
return initial;
}, 0);
state.completed = state.items.reduce((initial, item) => {
if (item.status === "collected" && item.collectorId === state.user) {
return initial + 1;
}
return initial;
}, 0);
},
update(state) {
Alertdata.caseReducers.completedUpdate(state);
Expand All @@ -52,9 +44,9 @@ const Alertdata = createSlice({
accepted(state, action) {
const actions = action.payload;
const pending = state.items.find((item) => item._id === actions.id);
console.log(state.items);
if (pending?.status === "pending") {
pending.status = "accepted";
pending.collectorId = state.user;
Alertdata.caseReducers.update(state);
}
},
Expand All @@ -71,6 +63,7 @@ const Alertdata = createSlice({
const pending = state.items.find((item) => item._id === actions.id);
if (pending?.status === "accepted") {
pending.status = "collected";
pending.collectorId = state.user;
pending.updatedAt = new Date().toISOString();
Alertdata.caseReducers.update(state);
}
Expand Down

1 comment on commit cc66051

@vercel
Copy link

@vercel vercel bot commented on cc66051 Mar 30, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

fasthrash-fe – ./

fasthrash-fe-git-main-dsc-futo.vercel.app
fasthrash-fe-dsc-futo.vercel.app
fastrash.vercel.app

Please sign in to comment.