Skip to content

Commit

Permalink
fix creating classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Emil307 committed Aug 19, 2023
1 parent 8eb248d commit a906506
Show file tree
Hide file tree
Showing 7 changed files with 46 additions and 30 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
7 changes: 7 additions & 0 deletions src/pages/Join/Join.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,15 @@ 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 { 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}>
Expand Down

0 comments on commit a906506

Please sign in to comment.