Skip to content

Commit

Permalink
Merge branch 'VaibhavArora314:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
lolpanda2004 authored Aug 6, 2024
2 parents 8d553ac + f4b3d17 commit e411334
Show file tree
Hide file tree
Showing 11 changed files with 606 additions and 12 deletions.
29 changes: 29 additions & 0 deletions admin/src/pages/Comments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { tokenState } from "../store/atoms/auth";
import toast from "react-hot-toast";
import { ColorRing } from 'react-loader-spinner';
import { FaComments } from "react-icons/fa";
import { TbReportAnalytics } from "react-icons/tb";

const Comments = () => {
const [posts, setPosts] = useState<IPost[]>([]);
Expand Down Expand Up @@ -47,6 +48,27 @@ const Comments = () => {
}
};

const downloadUsersCommentsReport = async () => {
try {
const response = await axios.get('/api/v1/admin/downloaduserscommentsreport', {
headers: {
Authorization: `Bearer ${token}`,
},
responseType: 'blob',
});

const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'StyleShare_Comments_Report.pdf');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
} catch (error) {
console.error('Error downloading users comments report:', error);
}
};

return (
<div>
<div className="flex-1 flex flex-col lg:ml-80">
Expand All @@ -68,6 +90,7 @@ const Comments = () => {
/>
</div>
:
<>
<div className="mx-5 lg:mr-11 overflow-x-auto shadow-md rounded-xl mb-5">
<table className="w-full text-sm text-left rtl:text-right text-gray-500 dark:text-gray-400">
<thead className="text-xs text-white uppercase bg-sky-500">
Expand Down Expand Up @@ -123,6 +146,12 @@ const Comments = () => {
</tbody>
</table>
</div>
<div className="mx-5 overflow-x-auto rounded-xl mb-5">
<button onClick={downloadUsersCommentsReport} className="flex items-center py-2.5 px-4 rounded-lg transition duration-200 bg-yellow-500 hover:bg-yellow-600 text-gray-100"><TbReportAnalytics size={23} className='mr-3'/>
Download Comments Info
</button>
</div>
</>
}
</div>
</div>
Expand Down
29 changes: 29 additions & 0 deletions admin/src/pages/ContactMessages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import 'react-responsive-modal/styles.css';
import '../styles/Model.css'
import { ColorRing } from 'react-loader-spinner';
import { MdMessage } from "react-icons/md";
import { TbReportAnalytics } from "react-icons/tb";

const ContactMessages = () => {
const [contactMessages, setContactMessages] = useState<IContactMessage[]>([]);
Expand Down Expand Up @@ -37,6 +38,27 @@ const ContactMessages = () => {
fetchMessages();
}, [token]);

const downloadContactMessagesReport = async () => {
try {
const response = await axios.get('/api/v1/admin/downloadcontactmessagereport', {
headers: {
Authorization: `Bearer ${token}`,
},
responseType: 'blob',
});

const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'StyleShare_Contact_Messages_Report.pdf');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
} catch (error) {
console.error('Error downloading the Contact Messages report:', error);
}
};

const handleOpenModal = (message: IContactMessage) => {
setSelectedMessage(message);
setOpen(true);
Expand Down Expand Up @@ -68,6 +90,7 @@ const ContactMessages = () => {
/>
</div>
:
<>
<div className="mx-5 lg:mr-11 overflow-x-auto shadow-md rounded-xl mb-5">
<table className="w-full rtl:text-right text-gray-500 dark:text-gray-400">
<thead className="text-xs md:text-sm text-white uppercase bg-sky-500 text-center">
Expand Down Expand Up @@ -112,6 +135,12 @@ const ContactMessages = () => {
</tbody>
</table>
</div>
<div className="mx-5 overflow-x-auto rounded-xl mb-5">
<button onClick={downloadContactMessagesReport} className="flex items-center py-2.5 px-4 rounded-lg transition duration-200 bg-yellow-500 hover:bg-yellow-600 text-gray-100"><TbReportAnalytics size={23} className='mr-3'/>
Download Messages
</button>
</div>
</>
}
</div>
<Modal open={open} onClose={handleCloseModal} center classNames={{ modal: 'customModal',overlay: 'customOverlay'}}>
Expand Down
29 changes: 29 additions & 0 deletions admin/src/pages/Favorites.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { tokenState } from "../store/atoms/auth";
import { IFavoritePost } from "../types";
import { ColorRing } from 'react-loader-spinner';
import { RiHeartsFill } from "react-icons/ri";
import { TbReportAnalytics } from "react-icons/tb";

const Favorites = () => {
const [favoritePosts, setFavoritePosts] = useState<IFavoritePost[]>([]);
Expand Down Expand Up @@ -32,6 +33,27 @@ const Favorites = () => {
fetchFavoritePosts();
}, [token]);

const downloadUsersFavoritesReport = async () => {
try {
const response = await axios.get('/api/v1/admin/downloadusersfavoritesreport', {
headers: {
Authorization: `Bearer ${token}`,
},
responseType: 'blob',
});

const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'StyleShare_Favorites_Report.pdf');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
} catch (error) {
console.error('Error downloading users favorites report:', error);
}
};

return (
<div>
<div className="flex-1 flex flex-col lg:ml-80">
Expand All @@ -53,6 +75,7 @@ const Favorites = () => {
/>
</div>
:
<>
<div className="mx-5 lg:mr-11 overflow-x-auto shadow-md rounded-xl mb-5">
<table className="w-full rtl:text-right text-gray-500 dark:text-gray-400">
<thead className="text-xs md:text-sm text-white uppercase bg-sky-500 text-center">
Expand Down Expand Up @@ -82,6 +105,12 @@ const Favorites = () => {
</tbody>
</table>
</div>
<div className="mx-5 overflow-x-auto rounded-xl mb-5">
<button onClick={downloadUsersFavoritesReport} className="flex items-center py-2.5 px-4 rounded-lg transition duration-200 bg-yellow-500 hover:bg-yellow-600 text-gray-100"><TbReportAnalytics size={23} className='mr-3'/>
Download Favorites Info
</button>
</div>
</>
}
</div>
</div>
Expand Down
29 changes: 29 additions & 0 deletions admin/src/pages/Posts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import toast from "react-hot-toast";
import { Link } from "react-router-dom";
import { ColorRing } from 'react-loader-spinner';
import { BsFillPostcardFill } from "react-icons/bs";
import { TbReportAnalytics } from "react-icons/tb";

const Posts = () => {
const [posts, setPosts] = useState<IPost[]>([]);
Expand Down Expand Up @@ -48,6 +49,27 @@ const Posts = () => {
}
};

const downloadPostsReport = async () => {
try {
const response = await axios.get('/api/v1/admin/downloadpostsreport', {
headers: {
Authorization: `Bearer ${token}`,
},
responseType: 'blob',
});

const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'StyleShare_Posts_Report.pdf');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
} catch (error) {
console.error('Error downloading the Posts report:', error);
}
};

return (
<div>
<div className="flex-1 flex flex-col lg:ml-80">
Expand All @@ -69,6 +91,7 @@ const Posts = () => {
/>
</div>
:
<>
<div className="mx-5 lg:mr-11 overflow-x-auto shadow-md rounded-xl mb-5">
<table className="w-full rtl:text-right text-gray-500 dark:text-gray-400">
<thead className="text-xs md:text-sm text-white uppercase bg-sky-500 text-center">
Expand Down Expand Up @@ -107,6 +130,12 @@ const Posts = () => {
</tbody>
</table>
</div>
<div className="mx-5 overflow-x-auto rounded-xl mb-5">
<button onClick={downloadPostsReport} className="flex items-center py-2.5 px-4 rounded-lg transition duration-200 bg-yellow-500 hover:bg-yellow-600 text-gray-100"><TbReportAnalytics size={23} className='mr-3'/>
Download Posts Info
</button>
</div>
</>
}
</div>
</div>
Expand Down
29 changes: 29 additions & 0 deletions admin/src/pages/Reactions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { tokenState } from "../store/atoms/auth";
import { ColorRing } from 'react-loader-spinner';
import { MdAddReaction } from "react-icons/md";
import { IReaction} from "../types";
import { TbReportAnalytics } from "react-icons/tb";

const Reactions = () => {
const [reactions, setReactions] = useState<IReaction[]>([]);
Expand Down Expand Up @@ -32,6 +33,27 @@ const Reactions = () => {
fetchReactions();
}, [token]);

const downloadUsersReactionsReport = async () => {
try {
const response = await axios.get('/api/v1/admin/downloadusersreactionreport', {
headers: {
Authorization: `Bearer ${token}`,
},
responseType: 'blob',
});

const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'StyleShare_Reactions_Report.pdf');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
} catch (error) {
console.error('Error downloading users reactions report:', error);
}
};

return (
<div>
<div className="flex-1 flex flex-col lg:ml-80">
Expand All @@ -53,6 +75,7 @@ const Reactions = () => {
/>
</div>
:
<>
<div className="mx-5 lg:mr-11 overflow-x-auto shadow-md rounded-xl mb-5">
<table className="w-full rtl:text-right text-gray-500 dark:text-gray-400">
<thead className="text-xs md:text-sm text-white uppercase bg-sky-500 text-center">
Expand Down Expand Up @@ -86,6 +109,12 @@ const Reactions = () => {
</tbody>
</table>
</div>
<div className="mx-5 overflow-x-auto rounded-xl mb-5">
<button onClick={downloadUsersReactionsReport} className="flex items-center py-2.5 px-4 rounded-lg transition duration-200 bg-yellow-500 hover:bg-yellow-600 text-gray-100"><TbReportAnalytics size={23} className='mr-3'/>
Download Reactions Info
</button>
</div>
</>
}
</div>
</div>
Expand Down
29 changes: 29 additions & 0 deletions admin/src/pages/Users.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import toast from "react-hot-toast";
import { IUser } from "../types";
import { ColorRing } from 'react-loader-spinner';
import { FaUsers } from "react-icons/fa";
import { TbReportAnalytics } from "react-icons/tb";

const Users = () => {
const [allUsers, setAllUsers] = useState<IUser[]>([]);
Expand Down Expand Up @@ -72,6 +73,27 @@ const Users = () => {
}
};

const downloadUsersReport = async () => {
try {
const response = await axios.get('/api/v1/admin/downloadusersreport', {
headers: {
Authorization: `Bearer ${token}`,
},
responseType: 'blob',
});

const url = window.URL.createObjectURL(new Blob([response.data]));
const link = document.createElement('a');
link.href = url;
link.setAttribute('download', 'StyleShare_Users_Report.pdf');
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
} catch (error) {
console.error('Error downloading the Users report:', error);
}
};

return (
<div>
<div className="flex-1 flex flex-col lg:ml-80">
Expand All @@ -93,6 +115,7 @@ const Users = () => {
/>
</div>
:
<>
<div className="mx-5 lg:mr-11 overflow-x-auto shadow-md rounded-xl mb-5">
<table className="w-full rtl:text-right text-gray-500 dark:text-gray-400">
<thead className="text-xs md:text-sm text-white uppercase bg-sky-500 text-center">
Expand Down Expand Up @@ -136,6 +159,12 @@ const Users = () => {
</tbody>
</table>
</div>
<div className="mx-5 overflow-x-auto rounded-xl mb-5">
<button onClick={downloadUsersReport} className="flex items-center py-2.5 px-4 rounded-lg transition duration-200 bg-yellow-500 hover:bg-yellow-600 text-gray-100"><TbReportAnalytics size={23} className='mr-3'/>
Download Users Info
</button>
</div>
</>
}
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion backend/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ PORT=3001
# EMAIL_USER=user_email_id
# EMAIL_PASS=16char_app_password
# SEND_EMAIL=true # Uncomment this to turn on email functionality on development
# API_KEY="your google gemini api key"
# API_KEY="your google gemini api key"
Loading

0 comments on commit e411334

Please sign in to comment.