-
Notifications
You must be signed in to change notification settings - Fork 67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat: Added Manging Block users in frontend successfully issue 389 #391
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. In the meantime, please ensure that your changes align with our CONTRIBUTING.md. If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊 |
@VaibhavArora314 I created a types.ts where all the interface is situated and I am using IPost, IUser and IStats in other files as I promised ! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rest is looking good to me, just this one change and also add an logout button on account suspend page
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here we can use setInterval to check user block status every 5 or 10 minutes and we can store interval value in a state to remove or update interval
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interval means, can you tell me more about it ! I haven't use interval approach in my projects can you elaborate please 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I got this sample code snippet of a hook to fetch todos and refresh them after a while, you can take reference from this
import { useEffect, useState } from 'react';
import axios from 'axios';
// Custom hook for fetching todos with auto-refresh
function useTodos(n) {
const [loading, setLoading] = useState(true);
const [todos, setTodos] = useState([]);
// Function to fetch data from the backend
function getData() {
axios.get("<api-url-here>")
.then(res => {
setTodos(res.data.todos);
setLoading(false);
})
.catch(error => {
console.error("Error fetching todos:", error);
setLoading(false);
});
}
useEffect(() => {
// Initial data fetch
getData();
// Set up interval to fetch data every n seconds
const intervalId = setInterval(() => {
getData();
}, n * 1000);
// Clean up the interval on component unmount or when n changes
return () => clearInterval(intervalId);
}, [n]);
// Return todos and loading state
return {
todos: todos,
loading: loading
};
}
// Main App component
function App() {
// Using the custom hook to fetch todos with auto-refresh every 5 seconds
const { todos, loading } = useTodos(5);
// Rendering loading message if data is still loading
if (loading) {
return <div>Loading...</div>;
}
// Rendering Track component for each todo
return (
<>
{todos.map(todo => <Track key={todo.id} todo={todo} />)}
</>
);
}
// Track component for rendering individual todo
function Track({ todo }) {
return (
<div>
{todo.title}
<br />
{todo.description}
</div>
);
}
export default App;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@VaibhavArora314 Amazing bro thank you very much i learned very new feature today,
I implemented it so, basically i add the timeout and updating state according to the time i set it to every 5 minute, so if admin unblock/block the user without reloading the page will update to suspended page.
So, if user is in the app and he/she is scrolling and using the app but when admin block the user, after 5 min the get api is called and user will dynamically see the suspended page.
Thank You very much 😄🙏
@VaibhavArora314 logout button done 👍 |
🎉 Your pull request has been successfully merged! 🎉 Thank you for your valuable contribution to our project. Your efforts are greatly appreciated. Feel free to reach out if you have any more contributions or if there's anything else we can assist you with. Keep up the fantastic work! 🚀 |
please Add GSSOC label and level ! |
@VaibhavArora314 @Ultimateutkarsh11 please add label and level gssoc |
Pull Request Resolves [#389 ]
Title: Added Manging Block users in frontend successfully.
Description
Related Issues
Fixes #389
Changes Made
New features: Added Manging Block users in frontend.
Screenshots
Video
Style.Share._.Login.page.-.Google.Chrome.2024-07-08.15-58-24.online-video-cutter.com.mp4
I certify that I have carried out the relevant code of conduct and provided the requisite screenshot for validation by submitting this pull request.
Thank You for this contribution.