Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
2961d22
react and redux insatallation
zivll1991 Jan 1, 2024
5e9f83e
client instal
zivll1991 Jan 7, 2024
857b38a
install server
zivll1991 Jan 7, 2024
b9d4251
delete nave's folder
zivll1991 Jan 7, 2024
ed4fd5b
register&homepage components
zivll1991 Jan 7, 2024
6633642
install ts-audio
zivll1991 Jan 8, 2024
dfd7e46
Merge branch 'music-player-test' of https://github.com/talyaron/fulls…
zivll1991 Jan 8, 2024
7ef96cd
temp
zivll1991 Jan 9, 2024
f97cc3c
server setup
zivll1991 Jan 10, 2024
9e6f7c5
establishing the server + post api
zivll1991 Jan 10, 2024
3b66956
temp
zivll1991 Jan 10, 2024
22165c4
.
zivll1991 Jan 11, 2024
163fbaf
Merge pull request #150 from talyaron/buttons-component
zivll1991 Jan 11, 2024
ab213c2
l61 start follwoup
itahTamar Jan 1, 2024
f40e8ce
l-61 follwoup finish
itahTamar Jan 2, 2024
65de38f
update
itahTamar Jan 2, 2024
aea478f
fix css-exam
itahTamar Jan 3, 2024
f0113aa
update
itahTamar Jan 4, 2024
f500248
Update npm_start_code.md
itahTamar Jan 3, 2024
775f120
WIP
GiliEllen Jan 3, 2024
5624501
restore files
GiliEllen Jan 3, 2024
625f78f
WIP
GiliEllen Jan 3, 2024
a4775ea
WIP
GiliEllen Jan 3, 2024
b3ef1b0
created followips
GiliEllen Jan 3, 2024
b543067
Update npm_start_code.md
itahTamar Jan 3, 2024
1a9adf1
bug in btn edit and delete
itahTamar Jan 4, 2024
7b88bed
WIP
GiliEllen Jan 7, 2024
624f285
WIP
GiliEllen Jan 7, 2024
023340e
WIP
GiliEllen Jan 9, 2024
ba89524
register&homepage components
zivll1991 Jan 7, 2024
f78dabe
push
navered Jan 10, 2024
bf25fb2
nave
navered Jan 13, 2024
fb29693
PUSH REGISTER NAVE
navered Jan 13, 2024
0a20b1b
Merge branch 'main' into register-component
navered Jan 13, 2024
2e13284
Merge branch 'music-player-test' into register-component
navered Jan 13, 2024
a4d8277
push
navered Jan 13, 2024
f18528b
push
navered Jan 14, 2024
d2e541c
push
navered Jan 14, 2024
eb3030d
push
navered Jan 15, 2024
6850a85
push
navered Jan 15, 2024
dee25d7
push
navered Jan 15, 2024
b2ff516
delete some import unuseful
navered Jan 15, 2024
80b6eb3
push
navered Jan 17, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9,419 changes: 9,419 additions & 0 deletions 06-React/14-practice/class-task/music-player/client/package-lock.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@
"type-check": "tsc"
},
"dependencies": {
"@emotion/react": "^11.11.3",
"@emotion/styled": "^11.11.0",
"@mui/material": "^5.15.3",
"@reduxjs/toolkit": "^1.8.1",
"axios": "^1.6.5",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.0.1"
"react-redux": "^8.0.1",
"react-router-dom": "^6.21.1",
"sass": "^1.69.7",
"ts-audio": "^0.7.4"
},
"devDependencies": {
"@testing-library/dom": "^9.2.0",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import axios from "axios";

export const BASE_URL = "/API/users";

interface RegistrationData {
user_name: string;
password: string;
}

export const registerUser = async (registrationData: RegistrationData): Promise<boolean> => {
try {
const response = await axios.post(`${BASE_URL}/register-user`, registrationData);
console.log("Registration response:", response.data);
return true;
} catch (error) {
console.error("Error during user registration:", error);
return false;
}
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import url(../src/components/scss/register.scss);
15 changes: 15 additions & 0 deletions 06-React/14-practice/class-task/music-player/client/src/App.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

import "./App.scss"
import RegisterPage from "./pages/RegisterPage"
import Buttons from "./components/Buttons"

function App() {
return (
<div >
<RegisterPage/>
<Buttons />
</div>
)
}

export default App
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { configureStore, ThunkAction, Action } from "@reduxjs/toolkit"
import userReducer from "../features/user/userSlice"
import songReducer from "../features/song/songSlice"
import setPassword from "../components/Password"

export const store = configureStore({
reducer: {
user: userReducer,
song: songReducer,
},
})

export type AppDispatch = typeof store.dispatch;
export type RootState = ReturnType<typeof store.getState>;
export type AppThunk<ReturnType = void> = ThunkAction<ReturnType, RootState, unknown, Action<string>>;
export { setPassword }

Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React from 'react'
import { Audio } from 'ts-audio';
import Sia from "../music/Sia - Bird Set Free.mp3"

const audio = Audio({
file: Sia,
loop: true,
volume: 0.2,
})

const play = () => {
audio.play()
}

const pause = () => {
audio.pause()
}

const stop = () => {
audio.stop()
}


const Buttons = () => {
// const play = () => { };
// const pause = () => { };
return (
<div className='audio-buttons'>
<button onClick={play}>Play</button>
<button onClick={pause}>Pause</button>
<button onClick={stop}>Stop</button>
<p>{Sia}</p>
</div>
)
}

export default Buttons


Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// Password.tsx
import React, { useState, useEffect, Dispatch, SetStateAction } from "react";
import { useDispatch } from "react-redux";
import { setPassword } from "../app/store"

interface Props {
password: string,
setPassword: Dispatch<SetStateAction<string>>,
match: boolean,
setMatch: Dispatch<SetStateAction<boolean>>
}
const Password = ({password, setPassword, match, setMatch}:Props) => {
const dispatch = useDispatch();
// const [password, setPasswordValue] = useState<string>("");
const [confirmPassword, setConfirmPassword] = useState<string>("");
const [visible, setVisbile] = useState(false);
// const [match, setMatch] = useState(false);

const validate = () => {
if (password === confirmPassword) {
setMatch(true);
} else {
setMatch(false);
}
};

useEffect(() => {
validate();
}, [confirmPassword, password]);

const handlePasswordInput = (value: string) => {
setPassword(value);
// dispatch(setPassword(value));
};

const handleVisibilityToggle = () => {
setVisbile(!visible);
};

return (
<div>
<input
type={visible ? "text" : "password"} className="inputPassword"
placeholder="password"
value={password}
onChange={(e) => handlePasswordInput(e.target.value)}
/>
<button type="button" className="showBtn" onClick={handleVisibilityToggle}>
{visible ? "Hide" : "Show"} Password
</button>
<input
type="password" className="inputPassword"
placeholder="confirm password"
value={confirmPassword}
onChange={(e) => setConfirmPassword(e.target.value)}
/>
<p className="match">{match ? "Passwords match!" : "Passwords do not match!"}</p>
</div>
);
};

export default Password;
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
import React, { useState } from "react";
import { useDispatch } from "react-redux";
import { useAppSelector } from "../app/hooks";
import { userSelector } from "../features/user/userSlice";
import Password from "./Password";
import { registerUser } from "../API/registerApi/registerApi";
import myImg from "../images/Happy girl wearing headphones.jpg"

const RegisterForm: React.FC = () => {
const dispatch = useDispatch();
const user = useAppSelector(userSelector)
const [user_name, setUsername] = useState("")
const [password, setPassword] = useState("")
const [match, setMatch] = useState(false);

const handleSubmit = async () => {
console.log(user_name)
console.log(password)
console.log(match)
if (match) {
const success = await registerUser({user_name, password});

if (success) {
console.log("Registration successful!");
} else {
console.error("Registration failed.");
}
}}



return (



<div className="registerDiv">
<div className="formContainer">
<p className="appName">Multi Musix</p>
<h2 className="loginHeader">Login</h2>
<form
className="registerForm"
action=""
onSubmit={(event) => {
event.preventDefault();
handleSubmit();
}}
>
<input
type="text"
className="inputUserName"
placeholder="username"
value={user_name}
onInput={(ev) => setUsername((ev.target as HTMLInputElement).value)}
/>
<Password password={password} setPassword={setPassword} setMatch={setMatch} match={match} />
<button className="registerBtn" type="submit">
Register
</button>
</form>
<p className="decoration">-------------------- o ---------------------</p>
<button className="signupBtn">Signup</button>
</div>
<div className="imageContainer">
<img src={myImg} className="imgRegister" alt="My Image" />
</div>
</div>
);
};

export default RegisterForm;
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
.registerDiv {
display: flex;
flex-wrap: wrap;

.formContainer {
flex: 1;
text-align: center;
align-content: center;
margin: 70px 120px 0px 120px ;

.appName,
.loginHeader {
padding: 0px 0px 5px 0px;
margin: 0px;
font-size: 1.2em;
color: #6467d4;
}

.loginHeader {
color: #000000;
}

.inputPassword,
.inputUserName {
padding: 0px 10px;
display: block;
height: 40px;
margin: 10px 0px;
width: 97%; // נעשה שינוי כדי שהתיבות יתמלאו את רוחב הקונטיינר
border: 1px solid #c3c3c3;
border-radius: 2px;
color: gray;
}

.inputPassword {
margin: 0px 0px;
}

.password-input-wrapper {
height: 40px;
width: 98%;
}

.inputPassword:focus,
.inputEmail:focus {
border: none;
border-color: none;
}

.inputPassword::placeholder,
.inputEmail::placeholder {
color: #aeacac;
}

.registerBtn, .signupBtn {
width: 100%;
background-color: #6467d4;
border-radius: 2px;
color: white;
padding: 15px;
border: none;
}

.signupBtn{
background-color: white;
color: #6467d4;
border: solid 1px #6467d4;


}
}

.showBtn{
width: 40%;
background-color: #6467d4;
color: white;
margin: 5px 0px;
border: none;
padding: 5px;
}
.imageContainer {
flex: 2;
display: flex;
justify-content: center;
align-items: center;

}

.imgRegister {
max-width: 100%; // נעשה שינוי כדי שהתמונה תמלא את רוחב הקונטיינר
max-height: 80%; // נעשה שינוי כדי שהתמונה תמלא את גובה הקונטיינר
}
}
@media (max-width: 768px) {
.registerDiv {
flex-direction: column;


.formContainer {
margin: 20px 30px 20px 20px;


}}}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { createSlice } from "@reduxjs/toolkit"

const initialState = {
song: null,
isLoading: false,
error: null,
}

const userSlice = createSlice({
name: "song",
initialState,
reducers: {
setSong(state, action) {
state.song = action.payload
},
setLoading(state, action) {
state.isLoading = action.payload
},
setError(state, action) {
state.error = action.payload
},
clearSong(state) {
state.song = null
},
},
})

export const { setSong, setLoading, setError, clearSong } = userSlice.actions

export default userSlice.reducer
Loading