forked from b00tc4mp/isdi-parttime-202309
-
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.
add new pages: Profile (Email & Password), Upload and Download | Crea…
…te routes to API from diferents pages b00tc4mp#382
- Loading branch information
Abel Prieto
authored and
Abel Prieto
committed
Mar 7, 2024
1 parent
903e7b0
commit 09b3b58
Showing
27 changed files
with
477 additions
and
189 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,5 @@ | ||
import { createContext } from 'react' | ||
|
||
const Context = createContext() | ||
|
||
export default Context |
75 changes: 75 additions & 0 deletions
75
staff/abel-prieto/PROYECT/HiInit/src/components/Download.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
import { useState, useEffect, useContext } from "react" | ||
import { useNavigate } from "react-router-dom" | ||
import Context from "../Context" | ||
import { CommandBar, Pointer } from "../utils" | ||
|
||
function Download() { | ||
|
||
// POINTER, UKNOWN COMMAND & POINTER STATE | ||
const [commandText, setCommandText] = useState('') | ||
const [uknownCommand, setUknownCommand] = useState(false) | ||
const { pointer } = Pointer() | ||
|
||
// VIEWS | ||
const navigate = useNavigate() | ||
const { handleError } = useContext(Context) | ||
|
||
// ESCUCHA TECLADO, ERROR Y ESCRITURA | ||
useEffect(() => { | ||
const handleKeyPress = (event) => { | ||
let commandText = document.getElementById('command').value | ||
|
||
if ((commandText === 'desktop' || commandText === 'DESKTOP') && event.key === 'Enter') { | ||
setUknownCommand(false) | ||
navigate('/desktop') | ||
} else if ((commandText === 'EXIT' || commandText === 'exit') && event.key === 'Enter') { | ||
handleLogout() | ||
} else if (event.key === 'Enter') { | ||
setUknownCommand(!uknownCommand) | ||
} | ||
} | ||
|
||
const handleKeyDown = () => { | ||
setUknownCommand(false) | ||
} | ||
|
||
document.addEventListener('keypress', handleKeyPress) | ||
document.addEventListener('keydown', handleKeyDown) | ||
|
||
return () => { | ||
document.removeEventListener('keypress', handleKeyPress) | ||
document.removeEventListener('keydown', handleKeyDown) | ||
} | ||
}, [navigate, uknownCommand]) | ||
|
||
return <> | ||
<div className="container"> | ||
|
||
<p>~$</p> | ||
<p id="client-error-upload">Entry 'ls' command to list all your save files: </p> | ||
|
||
<br /> | ||
|
||
<div className="command-bar"> | ||
<CommandBar /> | ||
<div id="command-form"> | ||
<input id="command" type="text" contentEditable="true" autoFocus autoComplete="off" value={commandText} onChange={(event) => setCommandText(event.target.value)} | ||
style={{ width: `${Math.max(10, commandText.length * 8)}px` }} /> | ||
</div> | ||
<p>{pointer}</p> | ||
</div> | ||
|
||
<br /> | ||
|
||
{uknownCommand && ( | ||
<> | ||
<span> | ||
<p>shell: command not found: '{commandText}'. Entry desktop, ls or exit</p> | ||
</span> | ||
</> | ||
)} | ||
</div> | ||
</> | ||
} | ||
|
||
export default Download |
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
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
Oops, something went wrong.