Skip to content

Commit

Permalink
Refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
basshamut committed Jun 25, 2024
1 parent 2de0fa5 commit 785d1e7
Show file tree
Hide file tree
Showing 3 changed files with 181 additions and 53 deletions.
105 changes: 99 additions & 6 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@
"react-dom": "^18.2.0",
"react-router-dom": "^6.23.1",
"react-stripe-js": "^1.1.5",
"stripe": "^15.12.0"
"stripe": "^15.12.0",
"styled-components": "^6.1.11"
},
"devDependencies": {
"@types/react": "^18.2.66",
Expand Down
126 changes: 80 additions & 46 deletions frontend/src/components/forms/meet/MeetRegisterForm.jsx
Original file line number Diff line number Diff line change
@@ -1,76 +1,110 @@
import {InputText} from "primereact/inputtext"
import {Button} from "primereact/button"
import {useState} from "react"
import {Calendar} from "primereact/calendar"
import { InputText } from "primereact/inputtext";
import { Button } from "primereact/button";
import { useState } from "react";
import { Calendar } from "primereact/calendar";
import styled from 'styled-components';

const RegisterContainer = styled.div`
background-image: radial-gradient(circle at left top, var(--primary-400), var(--primary-700));
color: white;
padding: 20px;
text-align: center;
width: 90%;
max-width: 600px;
margin: 0 auto;
border-radius: 10px;
@media (max-width: 600px) {
padding: 10px;
}
`;

const Label = styled.label`
text-align: left;
color: var(--primary-50);
font-weight: 600;
@media (max-width: 600px) {
font-size: 14px;
}
`;

const StyledInputText = styled(InputText)`
background-color: rgba(255, 255, 255, 0.2);
border: none;
padding: 12px;
color: var(--primary-50);
width: 100%;
@media (max-width: 600px) {
padding: 8px;
}
`;

const StyledButton = styled(Button)`
padding: 12px;
width: 100%;
color: var(--primary-50);
border: 1px solid rgba(255, 255, 255, 0.3);
&:hover {
background-color: rgba(255, 255, 255, 0.1);
}
`;

export default function MeetRegisterForm() {
const today = new Date()
const [date, setDate] = useState(today)
const [url, setUrl] = useState('')
const [price, setPrice] = useState(0)
const today = new Date();
const [date, setDate] = useState(today);
const [url, setUrl] = useState('');
const [price, setPrice] = useState(0);
// const domain = "http://localhost:5000"
const domain = "http://86.38.204.61"
const domain = "http://86.38.204.61";

function saveMeet() {
fetch(domain + '/api/meets', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({meetUrl: url, meetDate: date, price: price})
body: JSON.stringify({ meetUrl: url, meetDate: date, price: price })
})
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok')
throw new Error('Network response was not ok');
}
return response.json()
return response.json();
})
.then(() => {
setUrl('')
setDate(today)
setUrl('');
setDate(today);
})
.catch(error => {
console.error('There was a problem with the fetch operation:', error)
})
console.error('There was a problem with the fetch operation:', error);
});
}

return (
<div id="register" style={{
backgroundImage: 'radial-gradient(circle at left top, var(--primary-400), var(--primary-700))',
color: 'white',
padding: '20px',
textAlign: 'center'
}}>
<div className="inline-flex flex-column gap-2">
<label htmlFor="url" className="text-primary-50 font-semibold">
Dirección de la Reunión Online
</label>
<InputText id="url" label="Url" placeholder={"https://meet.google.com/..."}
className="bg-white-alpha-20 border-none p-3 text-primary-50"
onChange={event => setUrl(event.target.value)} value={url}
<RegisterContainer>
<div className="inline-flex flex-column gap-2" style={{ marginBottom: '15px' }}>
<Label htmlFor="url">Dirección de la Reunión Online</Label>
<StyledInputText id="url" label="Url" placeholder={"https://meet.google.com/..."}
onChange={event => setUrl(event.target.value)} value={url}
/>
</div>
<div className="inline-flex flex-column gap-2">
<label htmlFor="price" className="text-primary-50 font-semibold">
Costo (€)
</label>
<InputText id="price" label="Costo" placeholder={"0.0"}
className="bg-white-alpha-20 border-none p-3 text-primary-50"
onChange={event => setPrice(parseFloat(event.target.value))}
<div className="inline-flex flex-column gap-2" style={{ marginBottom: '15px' }}>
<Label htmlFor="price">Costo (€)</Label>
<StyledInputText id="price" label="Costo" placeholder={"0.0"}
onChange={event => setPrice(parseFloat(event.target.value))}
/>
</div>
<div className="inline-flex flex-column gap-2">
<label htmlFor="meetDate" className="text-primary-50 font-semibold">
Fecha de la Reunión
</label>
<div className="inline-flex flex-column gap-2" style={{ marginBottom: '15px' }}>
<Label htmlFor="meetDate">Fecha de la Reunión</Label>
<Calendar id="meetDate" value={date} onChange={(e) => setDate(e.value)} dateFormat="dd/mm/yy"
minDate={today} showTime hourFormat="24"/>
minDate={today} showTime hourFormat="24" style={{ width: '100%' }}
/>
</div>
<div className="flex align-items-center gap-2">
<Button label="Registrar" onClick={saveMeet} text
className="p-3 w-full text-primary-50 border-1 border-white-alpha-30 hover:bg-white-alpha-10"/>
<StyledButton label="Registrar" onClick={saveMeet} />
</div>
</div>

)
</RegisterContainer>
);
}

0 comments on commit 785d1e7

Please sign in to comment.