-{privateRoom&&!joined?
:
-
}
- endMessage={hotposts.length > 0 ?
{"You've reached the end of the page!"}
:
No posts available to display!
}
- >
- {/*
*/}
-
-
- ( refresh() )} className=' bg-[#eff1d3] rounded-full p-1'>
- {isSkelton ? : }
-
-
-
- { (hotposts.length == 0 && isSkelton) ? (
-
- ) : (
- hotposts.map((post) => (
-
- )
- )
- )}
-
-
-}
+
+ {privateRoom && !joined ?
:
+
}
+ endMessage={hotposts.length > 0 ?
{"You've reached the end of the page!"}
:
No posts available to display!
}
+ >
+ {/*
*/}
+
+
+ (refresh())} className=' bg-[#eff1d3] rounded-full p-1'>
+ {isSkelton ? : }
+
+
+
+
+ {(hotposts.length == 0 && isSkelton) ? (
+
+ ) : (
+ hotposts.map((post) => (
+
+ )
+ )
+ )}
+
+
+ }
>
)
diff --git a/frontend/src/pages/Signin.jsx b/frontend/src/pages/Signin.jsx
index 7b3ed76..425b9be 100644
--- a/frontend/src/pages/Signin.jsx
+++ b/frontend/src/pages/Signin.jsx
@@ -14,6 +14,7 @@ import toast from 'react-hot-toast';
import { setUserInfo } from '../redux/user';
import { setSkeltonLoader } from '../redux/skelton';
import baseAddress from "../utils/localhost";
+import { getUserData } from '../App';
@@ -34,21 +35,7 @@ const Signin = () => {
const passref = useRef();
- const getUserData=async(email)=>{
- // dispatch(loading())
- dispatch(setSkeltonLoader())
-
- try {
- const res= await axios.get(`${baseAddress}u/${email}`, {withCredentials:true});
- if(res.status==200){
- dispatch(setUserInfo(res.data.user));
- }
- } catch (error) {
- console.log(error);
- }
- // dispatch(loading())
- dispatch(setSkeltonLoader())
- }
+
const sendRequest = async () => {
@@ -60,17 +47,20 @@ const Signin = () => {
if (res.status == 202) {
toast.dismiss()
Navigate("/")
- await getUserData(res.data);
+ await getUserData({email:res.data, dispatch});
toast.dismiss()
- toast.success("Logged In successfully !")
+ toast.success("Logged In succesfully!")
dispatch(login())
}
}
else {
const res = await axios.post(`${baseAddress}auth/signin`, { username: form.user, password: form.password });
+ console.log(res);
+
if (res.status == 202) {
+ toast.dismiss()
+ await getUserData({email:res.data, dispatch});
Navigate("/")
- await getUserData(res.data);
toast.dismiss()
toast.success("Logged In succesfully!")
dispatch(login())
@@ -162,3 +152,6 @@ const Signin = () => {
}
export default Signin
+
+
+
diff --git a/frontend/src/pages/Signup.jsx b/frontend/src/pages/Signup.jsx
index 3dba8bc..fc1cab2 100644
--- a/frontend/src/pages/Signup.jsx
+++ b/frontend/src/pages/Signup.jsx
@@ -14,6 +14,10 @@ import toast from 'react-hot-toast';
import { FiRefreshCcw } from "react-icons/fi";
import SmallLoader from '../components/SmallLoader';
import baseAddress from "../utils/localhost";
+import { login } from '../redux/login';
+import { getUserData } from '../App';
+import { show } from '../redux/welcome';
+
@@ -37,8 +41,45 @@ const Signup = () => {
const [eye, setEye] = useState(false)
const [usrnmList, setUsrnmList] = useState([]);
const passref = useRef();
+ const [isLoading, setisLoading] = useState(false)
+ const [loading, setLoading] = useState(false)
+
+
+ const usernameRef = useRef(null);
+
+ const handleClick = () => {
+ generateUsername();
+ }
+
+ const generateUsername = async () => {
+ setisLoading(true);
+ try {
+ const res = await axios.get(`${baseAddress}auth/generateusername`);
+
+ setUsrnmList(res.data.usernames);
+
+ } catch (error) {
+
+ }
+ setisLoading(false)
+ }
+
+ const handleSelect = (username) => {
+ usernameRef.current.value = username;
+ setForm({ ...form, username: username });
+
+ }
+
+
+
+ useEffect(() => {
+ generateUsername();
+ }, [])
+
+
+
+
-
useEffect(() => {
let timer;
if (timeLeft > 0) {
@@ -55,7 +96,7 @@ const Signup = () => {
setErrorPass(null)
setOnSave(true)
setForm({ ...form, [e.target.name]: e.target.value });
-
+
}
const handleOtp = async (e) => {
@@ -65,15 +106,19 @@ const Signup = () => {
}
const sendOtp = async () => {
+ setLoading(true)
try {
+ toast.loading("Sending OTP")
const res = await axios.post(`${baseAddress}auth/signup`, form);
if (res.status == 202) {
+ toast.dismiss();
setVarifyOtpData({ ...varifyOtpData, userID: res.data.userID, email: res.data.email });
toast.success("Your OTP is on its way !");
setOtpsent(true);
}
} catch (error) {
+ toast.dismiss()
if (error.response.status == 500) {
toast.error("Some error occured! Try Again.")
} else if (error.response.status == 400) {
@@ -81,12 +126,13 @@ const Signup = () => {
}
console.log(error)
}
+ setLoading(false)
}
const handleSubmit = async (e) => {
e.preventDefault();
-
+
if ((form.username.length < 3)) {
setOnSave(false)
setErrorUsername("* username must contain more than 3 characters");
@@ -100,9 +146,8 @@ const Signup = () => {
setErrorPass('* Password must include a-z,A-Z,0-9,symbols and min-length of 8')
}
else {
- dispatch(loading());
+
await sendOtp();
- dispatch(loading());
setdisable(true);
setTimeLeft(60)
@@ -138,14 +183,19 @@ const Signup = () => {
}
const varifyOtp = async () => {
- dispatch(loading())
+ setLoading(true)
try {
const res = await axios.post(`${baseAddress}auth/varifyotp`, varifyOtpData);
+ console.log(res);
+
if (res.status == 202) {
- toast.success("Sign Up Successful!");
- Navigate("/signin");
+ Navigate("/")
+ dispatch(show())
+ await getUserData({ email: res.data, dispatch });
+ toast.dismiss()
+ dispatch(login())
}
} catch (error) {
console.log(error);
@@ -162,7 +212,7 @@ const Signup = () => {
}
- dispatch(loading())
+ setLoading(false)
}
@@ -206,117 +256,81 @@ const Signup = () => {
-
- return (
-
- )
-}
-export default Signup
-
+ return (
+ <>
+
+
-export const Layout = ({ form,setForm, passref, eye, handleChange, handleCloseEye, handleEye, handleSubmit, errorUsername, errorEmail, errorPass, onSave, otp, otpsent, resendOTP, handleOtp,usrnmList, setUsrnmList, varifyOtp, errorOtp, timeLeft, disable }) =>{
+
- >
-)
-}
diff --git a/frontend/src/redux/store.js b/frontend/src/redux/store.js
index 73b67f3..3ecda23 100644
--- a/frontend/src/redux/store.js
+++ b/frontend/src/redux/store.js
@@ -15,6 +15,7 @@ import roomReducer from './roomSlice'
import userRoomsReducer from './userRooms'
import PageReducer from './Page'
import { roomsApi } from '../pages/RoomApis'
+import welcomeStateReducer from './welcome'
export const store = configureStore({
reducer: {
@@ -33,6 +34,7 @@ export const store = configureStore({
room:roomReducer,
rooms:userRoomsReducer,
page:PageReducer,
+ welcome: welcomeStateReducer,
roomsApi:roomsApi.reducer
},
diff --git a/frontend/src/redux/welcome.js b/frontend/src/redux/welcome.js
new file mode 100644
index 0000000..ae06aa7
--- /dev/null
+++ b/frontend/src/redux/welcome.js
@@ -0,0 +1,22 @@
+import { createSlice } from '@reduxjs/toolkit'
+
+const initialState = {
+ value: false,
+}
+
+export const welcomeState = createSlice({
+ name: 'welcome',
+ initialState,
+ reducers: {
+ show: (state) => {
+ state.value = true;
+ },
+ hide: (state) => {
+ state.value = false;
+ },
+ },
+})
+
+export const { show, hide} = welcomeState.actions
+
+export default welcomeState.reducer
\ No newline at end of file
diff --git a/frontend/tailwind.config.js b/frontend/tailwind.config.js
index ddb2dc3..b844f3c 100644
--- a/frontend/tailwind.config.js
+++ b/frontend/tailwind.config.js
@@ -30,12 +30,21 @@ export const theme = {
'0%, 100%': { boxShadow: '0 0 5px #f9ff86, 0 0 10px #f9ff86, 0 0 20px #f9ff86' },
'50%': { boxShadow: '0 0 15px #f9ff86, 0 0 20px #f9ff86, 0 0 30px #f9ff86' },
},
+ slideInFromBehind: {
+ '0%': { transform: 'scale(0.5) translateZ(-200px)', opacity: '0' },
+ '100%': { transform: 'scale(1) translateZ(0)', opacity: '1' },
+ },
},
transitionDuration: {
'400': '400ms', // 2 seconds
},
animation: {
glow: 'glow 2s infinite',
+ slideInFromBehind: 'slideInFromBehind 0.8s ease-out forwards',
+ },
+ fontFamily: {
+ roboto: ["Roboto", 'sans-serif'],
+ ubuntu:["Ubuntu", "sans-serif"]
},
},
// colors:{