diff --git a/frontend/app/api/phonebook/[userId]/route.js b/frontend/app/api/phonebook/[userId]/route.js new file mode 100644 index 00000000..55e17659 --- /dev/null +++ b/frontend/app/api/phonebook/[userId]/route.js @@ -0,0 +1,19 @@ +import axios from "axios"; +import { NextResponse } from "next/server"; + +const getUserPhoneBook = async (route) => { + try { + const backendURL = process.env.BACKEND_URL || "http://localhost:5000"; + const userId = (route.url.split('/').reverse()[0]) + console.log(backendURL + "/api/v1/phonebook/user/" + userId) + const {data} = await axios.get(backendURL + "/api/v1/phonebook/user/" + userId); + console.log(data) + return NextResponse.json(data); + } catch (error) { + return NextResponse.error(error); + } +} + +export { + getUserPhoneBook as GET +} \ No newline at end of file diff --git a/frontend/app/api/phonebook/route.js b/frontend/app/api/phonebook/route.js index addd71b5..7c1f86bc 100644 --- a/frontend/app/api/phonebook/route.js +++ b/frontend/app/api/phonebook/route.js @@ -3,8 +3,12 @@ import { NextResponse } from "next/server"; const getAllContacts = async () => { try { - const backendURL = process.env.NEXT_PUBLIC_BACKEND_URL || "http://localhost:5000"; - const {data} = await axios.get(backendURL + "/api/phonebook"); + const backendURL = process.env.BACKEND_URL; + console.log("in") + console.log(backendURL + "/api/v1/phonebook") + const {data} = await axios.get(backendURL + "/api/v1/phonebook"); + console.log(data) + console.log("in") return NextResponse.json(data); } catch (error) { return NextResponse.error(error); @@ -13,9 +17,9 @@ const getAllContacts = async () => { const addContact = async (request) => { try { - const backendURL = process.env.NEXT_PUBLIC_BACKEND_URL || "http://localhost:5000"; + const backendURL = process.env.BACKEND_URL || "http://localhost:5000"; const req = await request.json(); - const {data} = await axios.post(backendURL + "/api/phonebook", req); + const {data} = await axios.post(backendURL + "/api/v1/phonebook", req); return NextResponse.json(data); } catch (error) { return NextResponse.error(error); diff --git a/frontend/app/api/users/route.js b/frontend/app/api/users/route.js new file mode 100644 index 00000000..1767ec48 --- /dev/null +++ b/frontend/app/api/users/route.js @@ -0,0 +1,32 @@ +import axios from "axios"; +import { NextResponse } from "next/server"; + +const login = async (request) => { + try { + const backendURL = process.env.BACKEND_URL || "http://localhost:5000"; + const req = await request.json(); + console.log(backendURL + "/api/v1/users/login") + console.log(req) + const {data} = await axios.post(backendURL + "/api/v1/users/login", req); + console.log(data) + return NextResponse.json(data); + } catch (error) { + return NextResponse.error(error); + } +} + +const register = async (request) => { + try { + const backendURL = process.env.BACKEND_URL || "http://localhost:5000"; + const req = await request.json(); + const {data} = await axios.post(backendURL + "/api/v1/users/", req); + return NextResponse.json(data); + } catch (error) { + return NextResponse.error(error); + } +} + +export { + login as POST, + register as PUT +} \ No newline at end of file diff --git a/frontend/app/login/page.jsx b/frontend/app/login/page.jsx index 5a222fa2..1b5e23cd 100644 --- a/frontend/app/login/page.jsx +++ b/frontend/app/login/page.jsx @@ -15,7 +15,7 @@ const Login = () => { const [ethAddress, setEthAddress] = useState(""); const router = useRouter() const handleLogin = async () => { - const { data } = await axios.post('/api/nest/users/login', { + const { data } = await axios.post('/api/users/', { email, password, ethAddress @@ -23,7 +23,7 @@ const Login = () => { if (data?.ethAddress) { setLogin(true) setUser(data) - router.push('/schedule') + router.push('/schedule-meets') } else { alert("Something went wrong"); } diff --git a/frontend/app/meeting/components/meeting/Controls.jsx b/frontend/app/meeting/components/meeting/Controls.jsx index 30bffa15..af7ce82d 100644 --- a/frontend/app/meeting/components/meeting/Controls.jsx +++ b/frontend/app/meeting/components/meeting/Controls.jsx @@ -19,24 +19,43 @@ const Controls = ({ URL }) => { const { isStarting, inProgress, isStopping, data } = useRecording(); const isMuteOnJoin = useMeetingStore(state => state.isMuteOnJoin); const isDisableVideoOnJoin = useMeetingStore(state => state.isDisableVideoOnJoin); - const recorder = new RecordRTC_Extension(); var screenShareStream = null; + var recorder; + + if (typeof RecordRTC_Extension === 'undefined') { + recorder = null; + } else { + recorder = new RecordRTC_Extension(); + } + const startRecording = async () => { - if (!recorder) { - alert("RecordRTC chrome extension is either disabled or not installed. Install the extension to record the screen") - } else { - recorder.startRecording({ - enableScreen: true, - enableMicrophone: true, - enableSpeakers: true - }); + try { + if (recorder == undefined || recorder == null) { + alert("RecordRTC chrome extension is either disabled or not installed. Install the extension to record the screen") + } else { + recorder.startRecording({ + enableScreen: true, + enableMicrophone: true, + enableSpeakers: true + }); + } + } catch (e) { + console.log(e); } } + const stopRecording = async () => { - recorder.stopRecording(function (blob) { + // console.log(recorder) + recorder.stopRecording(function (blob, error) { console.log("blob", blob) + console.log("error", error) + recorder = null; + if (blob == false) { + alert("RecordRTC chrome extension is either disabled or not installed. Install the extension to record the screen") + return; + } const link = document.createElement('a'); - link.href = window.URL.createObjectURL(blob); + link.href = window.URL?.createObjectURL(blob); link.download = `recording-${+new Date()}.webm`; link.click(); }); diff --git a/frontend/app/phonebook/components/AddContact.jsx b/frontend/app/phonebook/components/AddContact.jsx index 7c45af9b..c1205956 100644 --- a/frontend/app/phonebook/components/AddContact.jsx +++ b/frontend/app/phonebook/components/AddContact.jsx @@ -1,4 +1,3 @@ -import { TextField } from "@mui/material"; import React from "react"; const AddContact = ({addContact, setAddContact, addContactHandler}) => { diff --git a/frontend/app/phonebook/components/GroupsContacts.jsx b/frontend/app/phonebook/components/GroupsContacts.jsx index 930c0817..62164cdf 100644 --- a/frontend/app/phonebook/components/GroupsContacts.jsx +++ b/frontend/app/phonebook/components/GroupsContacts.jsx @@ -1,9 +1,32 @@ -import React from "react"; +"use client"; + +import React, { useEffect } from "react"; import { FiPlusSquare } from "react-icons/fi"; import Image from "next/image"; const GroupsContacts = ({addContact, setAddContact, addGroup, setAddGroup, phonebookData }) => { console.log(phonebookData) + const [filteredData, setFilteredData] = React.useState(phonebookData); + const [search, setSearch] = React.useState(""); + console.log(filteredData) + useEffect(() => { + const data = filterData(); + console.log(data) + setFilteredData(data); + }, [search]); + + useEffect(() => { + if (filteredData.length > 0) return; + setFilteredData(phonebookData); + }, [phonebookData]); + + const filterData = () => { + const newData = phonebookData.filter((contact) => { + return contact.name.toLowerCase().includes(search.toLowerCase()) || contact.address.toLowerCase().includes(search.toLowerCase()); + }); + setFilteredData(newData.length > 0 ? newData : phonebookData); + return newData; + } return (