-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
498dbaa
commit 2b4a2bf
Showing
13 changed files
with
201 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,7 @@ function App() { | |
<div> | ||
<DatePicker/> | ||
</div> | ||
); | ||
); | ||
} | ||
|
||
export default App; |
2 changes: 1 addition & 1 deletion
2
frontend/src/components/Calendar.jsx → ...tend/src/components/Calendar/Calendar.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React, { useRef, useEffect, useState } from 'react'; | ||
import Flatpickr from 'flatpickr'; | ||
import weekSelect from 'flatpickr'; | ||
import 'flatpickr/dist/flatpickr.css'; | ||
import flatpickr from 'flatpickr'; | ||
|
||
const DatePicker = () => { | ||
const datePickerRef = useRef(null); | ||
|
||
const [dateOnCalendar, setDateOnCalendar] = useState("2024-09-19") | ||
const [weekNumber, setWeekNumber] = useState(null) | ||
|
||
useEffect(() => { | ||
flatpickr(datePickerRef.current, { | ||
"onChange": [() => { | ||
setWeekNumber(this.selectedDates[0] ? setWeekNumber(this.selectedDates[0]) : null) | ||
console.log(weekNumber); | ||
}] | ||
}); | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<input type="text" ref={datePickerRef} value={dateOnCalendar} onChange={(e) => setDateOnCalendar(e.target.value)}/> | ||
</div> | ||
); | ||
}; | ||
|
||
export default DatePicker; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useState } from "react" | ||
import { loginModeus } from "../../services/api/login" | ||
|
||
const ModeusLoginForm = () => { | ||
const [email, setEmail] = useState(null) | ||
const [password, setPassword] = useState(null) | ||
|
||
const onClickLogin = async() => { | ||
let response = await loginModeus(email, password) | ||
|
||
if (response.status !== 200) { | ||
alert("Ты лох, введи правильные креды") | ||
return; | ||
} | ||
|
||
localStorage.setItem('token', response.data?.token) | ||
} | ||
|
||
return ( | ||
<div> | ||
<p>Modeus Login</p><br/> | ||
<input id="email" type="email" onChange={(e) => setEmail(e.target.value)}/> | ||
<input id="password" type="password" onChange={(e) => setPassword(e.target.value)}/> | ||
<button id="login" onClick={onClickLogin}>Login</button> | ||
</div> | ||
) | ||
} | ||
|
||
export default ModeusLoginForm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,35 @@ | ||
import React from 'react'; | ||
import ReactDOM from 'react-dom/client'; | ||
import App from './App'; | ||
import { | ||
createBrowserRouter, | ||
RouterProvider, | ||
} from "react-router-dom"; | ||
|
||
import reportWebVitals from './reportWebVitals'; | ||
import LoginRoute from './routes/LoginRoute'; | ||
import CalendarRoute from './routes/CalendarRoute'; | ||
|
||
const root = ReactDOM.createRoot(document.getElementById('root')); | ||
const router = createBrowserRouter([ | ||
{ | ||
path: "/", | ||
element: <div>Hello world!</div>, | ||
}, | ||
{ | ||
path: "/login", | ||
element: <LoginRoute/>, | ||
}, | ||
{ | ||
path: "/calendar", | ||
element: <CalendarRoute/> | ||
} | ||
]); | ||
|
||
|
||
root.render( | ||
<React.StrictMode> | ||
<App /> | ||
<RouterProvider router={router} /> | ||
</React.StrictMode> | ||
); | ||
|
||
// If you want to start measuring performance in your app, pass a function | ||
// to log results (for example: reportWebVitals(console.log)) | ||
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals | ||
reportWebVitals(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import Calendar from "../components/Calendar/Calendar" | ||
import DataPicker from "../components/Calendar/DataPicker" | ||
|
||
const CalendarRoute = () => { | ||
return ( | ||
<div> | ||
<DataPicker/> | ||
</div> | ||
) | ||
} | ||
|
||
export default CalendarRoute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import ModeusLoginForm from "../components/Login/ModeusLoginForm" | ||
|
||
const LoginRoute = () => { | ||
return ( | ||
<div> | ||
<ModeusLoginForm/> | ||
</div> | ||
) | ||
} | ||
|
||
export default LoginRoute |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import axios from 'axios'; | ||
import { BACKEND_URL } from '../../variables'; | ||
|
||
|
||
export function getTokenFromLocalStorage() { | ||
return localStorage.getItem('token') | ||
} | ||
|
||
export async function loginModeus(username, password) { | ||
try { | ||
return await axios.post(`${BACKEND_URL}/api/modeus`, {username, password}); | ||
} catch (e) { | ||
return e.response; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const BACKEND_URL="http://localhost:8000" |