From 20a95efb8f8de45e286831434358242679a5cc73 Mon Sep 17 00:00:00 2001 From: Rituraj Singh <2300520140055@ietlucknow.ac.in> Date: Mon, 2 Sep 2024 22:50:17 +0530 Subject: [PATCH 1/2] little little --- backend/src/controller/auth.js | 4 ++-- frontend/src/pages/CreatePost.jsx | 29 +++++++++++++++++++++-------- frontend/src/pages/Overview.jsx | 2 +- 3 files changed, 24 insertions(+), 11 deletions(-) diff --git a/backend/src/controller/auth.js b/backend/src/controller/auth.js index 6c5be6c..790e6be 100644 --- a/backend/src/controller/auth.js +++ b/backend/src/controller/auth.js @@ -216,7 +216,7 @@ const varifyOtp = async (req, res) => { return res .cookie(updateUser.userID, token, { path: "/", - expires: new Date(Date.now() + 1000 * 1 * 24 * 60 * 60), + expires: new Date(Date.now() + 1000 * 7 * 24 * 60 * 60), httpOnly: true, sameSite: "lax", }) @@ -334,7 +334,7 @@ const signin = async (req, res) => { res .cookie(user.userID, token, { path: "/", - expires: new Date(Date.now() + 1000 * 1 * 24 * 60 * 60), + expires: new Date(Date.now() + 1000 * 7 * 24 * 60 * 60), httpOnly: true, sameSite: "lax", }) diff --git a/frontend/src/pages/CreatePost.jsx b/frontend/src/pages/CreatePost.jsx index 58c9309..3ac4e98 100644 --- a/frontend/src/pages/CreatePost.jsx +++ b/frontend/src/pages/CreatePost.jsx @@ -17,6 +17,8 @@ const CreatePost = ({ setShowCP, onNewPost, roomTitle, setPost }) => { const [description, setDescription] = useState(''); const [image, setImage] = useState(null); const [Btnloading, setLoading] = useState(false); + const [mediaLoading, setmediaLoading] = useState(false) + const [disable, setdisable] = useState(false) const location = useLocation(); const selectFile = useRef(null); @@ -37,14 +39,19 @@ const [error, seterror] = useState("") const handleChange = async (e) => { const file = e.target.files[0]; - - // Check if file exists + if (!file) return; + setmediaLoading(true) + setdisable(true) // Check file size - if (file.size <= 3 * 1024 * 1024) { + console.log(file); + + if (file.size <= 3 * 1024 * 1024) {3,145,728 // File size is less than or equal to 3MB, no need to compress setImage(file); + setdisable(false) + setmediaLoading(false) return; } @@ -61,8 +68,13 @@ const [error, seterror] = useState("") } catch (error) { console.error('Error compressing image:', error); } + setmediaLoading(false) + setdisable(false) }; + + + const handleSelectChange = (event) => { setSelectedOption(event.target.value); }; @@ -210,19 +222,20 @@ const [error, seterror] = useState("") Image
{image?.name}
-
- + {mediaLoading && }
handleChange(e)} accept='image/*' ref={selectFile} type="file" name="media" id="media" hidden /> {/* Submit Button */} - diff --git a/frontend/src/pages/Overview.jsx b/frontend/src/pages/Overview.jsx index 243b616..2effc70 100644 --- a/frontend/src/pages/Overview.jsx +++ b/frontend/src/pages/Overview.jsx @@ -102,7 +102,7 @@ const Overview = () => { const fetchMoreData = () => { if (isLoading || !hasMore) return; - setPage(prevPage => prevPage + 1); + setPage(prevPage => prevPage + 1); }; return ( From 7720d3e0644f8a9d50f51c2433c68ea33e727bd6 Mon Sep 17 00:00:00 2001 From: Rituraj Singh <2300520140055@ietlucknow.ac.in> Date: Mon, 2 Sep 2024 23:13:32 +0530 Subject: [PATCH 2/2] ok --- frontend/src/assets/cficon.ico | Bin 0 -> 1406 bytes frontend/src/components/ProfileLayout.jsx | 43 ++++++++++++++-------- 2 files changed, 27 insertions(+), 16 deletions(-) create mode 100644 frontend/src/assets/cficon.ico diff --git a/frontend/src/assets/cficon.ico b/frontend/src/assets/cficon.ico new file mode 100644 index 0000000000000000000000000000000000000000..0eaac6b931584839ce38a035665a322b4807682e GIT binary patch literal 1406 zcmeH_YfzMB6vuz-1@Y2~$Yt4OWl1Qtyk7gK?}TKg$u(S*-WIgf zYMg1NrVlhz&gcy4fFl^?r5Fw%&V&A?piLD`6cv!3%KK|xZRi&jYlDRcrCXYYMj~7ZwORmNG zgTk@0pK$k9QB(a3$*l@)H&r?-%yfOeh^pPA7#i%MAlFH}={&A>H+E?OmDd#du6elH z^cl+=WcGF`e0w0A>>Z70gTFxb^mA2K(T9Ca$B8($rFBr0dxb_zEGK(qZny)qNE7h% zwbAx*B9Wmsw!8eSb;zjd4GOz`#7{d#Mw%U)ZGa_p3e8p%btNO1l?B#92B|F2om5QT;wHy8V1#7{mHzQR5LKQDLX4-V;Q# zWIz{MK|sFAuigN)1qQM@WzL`Lqs6Kvr_+zU#7JgpGt*;E^Ifiv#)DC$w94dU*=Z;? zGAZaw{Juf#)&y2H`Pk%?+0vn~zgs5GREhm?EUsHBd0js7Z>3;6gQGN>`eKvd?ZNeF z0?txVgJfc;{}S49mFT8^LuaEpQ5fnFZ3{S zQE0K+q2N54#O5}Ior2p{ks8Z*0-TT}t%c6re&fjr#(w1k6^kE0G zch8B*TAQD*d)=}$Z}oa9d)uma{ZO>Z|O7B1UTFRTxK3-T*eq{Q~_rD{} zdn5Fb7o+wanwV%weqqf{Y1f#UTVr26yy>CDkj&HvW~_@3K5^&NakKWXoc5u$_=A$N yVX}p}kFC&{7d)Mj{@w`bu_v~Vdek_QCzzhUOS^m|*W5k+_``on{~`Rh-S`8lM`Y6g literal 0 HcmV?d00001 diff --git a/frontend/src/components/ProfileLayout.jsx b/frontend/src/components/ProfileLayout.jsx index 7653a0e..05b8e32 100644 --- a/frontend/src/components/ProfileLayout.jsx +++ b/frontend/src/components/ProfileLayout.jsx @@ -15,6 +15,7 @@ import LeetCode from './LeetCode'; import LeetCodeLogo from '../assets/LeetCodeLogo' import Codeforces from './Codeforces'; import { setBgImg, setDp } from '../redux/profile'; +import cficon from '../assets/cficon.ico' axios.defaults.withCredentials = true @@ -37,7 +38,7 @@ const ProfileLayout = ({ isLoading, user }) => { const currentPath = location.pathname.split('/').pop(); - + const handleClickOutside = (event) => { @@ -96,7 +97,7 @@ const ProfileLayout = ({ isLoading, user }) => {
- +
@@ -112,32 +113,42 @@ const ProfileLayout = ({ isLoading, user }) => {
- Profile + Profile
{userInfo?.username === user.username && }
-
-
{user.username}
+
+
{user.username}
u/{user.username}
{userInfo?.bio}
- {user?.showCf&&
} +
-
+
+ {user.showLC && + + } + { } +
+ {user?.showCf &&
+ +
} - {user.showLC &&
+ {/* {user.showLC &&
-
} +
} */} {showLCard &&
@@ -172,9 +183,9 @@ const ProfileLayout = ({ isLoading, user }) => { export default ProfileLayout; -export const handleDpChange = async ({dpLoc, setBtnLoading, dispatch,setIsOpen}) => { +export const handleDpChange = async ({ dpLoc, setBtnLoading, dispatch, setIsOpen }) => { - if(!dpLoc){ + if (!dpLoc) { return; } const formData = new FormData(); @@ -190,7 +201,7 @@ export const handleDpChange = async ({dpLoc, setBtnLoading, dispatch,setIsOpen}) if (res.status == 202) { console.log(res); - + dispatch(setUserInfo(res.data)); dispatch(setDp(res.data.dp)) toast.success("Profile Picture Updated !")