Skip to content

Commit

Permalink
Co-authored-by: Emil <[email protected]>
Browse files Browse the repository at this point in the history
  • Loading branch information
BodySites committed Aug 20, 2023
2 parents ede2223 + ccd98f6 commit 40dca08
Show file tree
Hide file tree
Showing 7 changed files with 48 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .env.development
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ VITE_AUTH0_DOMAIN="dev-txpc5harm481cb6o.us.auth0.com"
VITE_AUTH0_CLIENT_ID="BOU97TMrp85ftAnrXSLTiYYiuifp9jfz"
VITE_API='https://network-class-server.ru'
VITE_WS_API='wss://network-class-server.ru'
VITE_VIDEOSDK_HREF=''
VITE_VIDEOSDK_APP='http://localhost:3000/react-rtc-demo'
2 changes: 1 addition & 1 deletion .env.production
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ VITE_AUTH0_DOMAIN="dev-txpc5harm481cb6o.us.auth0.com"
VITE_AUTH0_CLIENT_ID="fOB3CWsgCnNLI5q7OMWe9DfWaAXOme2o"
VITE_API='https://network-class-server.ru'
VITE_WS_API='wss://network-class-server.ru'
VITE_VIDEOSDK_HREF=''
VITE_VIDEOSDK_APP='https://network-class-videosdk-client.pages.dev'
2 changes: 1 addition & 1 deletion src/entities/room/ui/RoomCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ const RoomCard: React.FC<Props> = ({ room }) => {
<img src={callDisabled} alt="недоступен" />
)}
<Access>
<JoinButton href={`https://network-class-videosdk-client.pages.dev/?roomId=${room.id}&email=${user?.email}`} />
<JoinButton href={`${import.meta.env.VITE_VIDEOSDK_APP}/?roomId=${room.id}&email=${user?.email}`} />
<Tooltip active={tooltipActive} message="Ссылка скопирована!">
<Button onClick={copyLink}>
<svg
Expand Down
25 changes: 0 additions & 25 deletions src/entities/user/api/addUser.ts

This file was deleted.

34 changes: 34 additions & 0 deletions src/entities/user/api/useAddUser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { useState, useEffect } from 'react';

export const useAddUser = (fullname: any, photo_url: string, email: any) => {
const API = String(import.meta.env.VITE_API);
const [user, setUser] = useState({});

const newUser = {
full_name: fullname,
photo_url: photo_url,
email: email
}

async function createUser() {
await fetch(`${API}/users`, {
method : 'POST',
headers: {
'Content-type': 'application/json',
},
body : JSON.stringify(newUser),
})
.then(response => response.text())
.then(response => {
response = JSON.parse(response);
console.log(response);
setUser(response);
})
}

useEffect(() => {
createUser();
}, [])

return user;
}
4 changes: 2 additions & 2 deletions src/features/createRoom/model/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { IUser } from "../../../shared/api/models";
import { AddUserThunk } from "../../../entities/user/api/addUser";

export const CreateThunk = (event: any, title: string, isPublic: boolean, user: IUser) => {
event.preventDefault();
AddUserThunk(user?.name, 'test', user?.email);
const API = String(import.meta.env.VITE_API);

console.log(user?.email);

const newRoom = {
title: title,
url: 'https://network-class.pages.dev/joinlesson/1',
Expand Down
10 changes: 9 additions & 1 deletion src/pages/Join/Join.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,17 @@ import people from "../../../public/icons/people.svg";
import { EnterClassForm } from "../../features/EnterClass/index.ts";
import FunctionsList from "../../widgets/FunctionsList/FunctionsList.tsx";
import functions from "../../widgets/FunctionsList/functionsObject.tsx";
import ProfilePanel from "../../widgets/ProfilePanel/ProfilePanel.tsx";
import ProfilePanel from "../../widgets/ProfilePanel/ProfilePanel.tsx"
import { useAuth0 } from "@auth0/auth0-react";
import { useAddUser } from "../../entities/user/api/useAddUser.ts";

const Join: React.FC = () => {
const { isAuthenticated, user } = useAuth0();

if (isAuthenticated) {
useAddUser(user?.name, 'test', user?.email);
}

return (
<div className={styles.Join}>
<div className={styles.leftSide}>
Expand Down

0 comments on commit 40dca08

Please sign in to comment.