Commit e121f413 authored by johnnyloreano's avatar johnnyloreano
Browse files

save before merge

parent 6032333c
......@@ -13,7 +13,7 @@ function RedeHorarioCard({ mentoria }) {
const [open, setOpen] = React.useState(false);
const [timeInfo, setTimeInfo] = React.useState('');
const [dateInfo, setDateInfo] = React.useState('');
const [mentoriaSelect, setMentoriaSelect] = React.useState(mentoria);
const { enqueueSnackbar } = useSnackbar();
......@@ -21,11 +21,19 @@ function RedeHorarioCard({ mentoria }) {
enqueueSnackbar(msg, { variant, autoHideDuration });
};
const { dateTime } = mentoria;
const { dateTime } = mentoriaSelect;
const sortedTimes = dateTime.sort((dateTimeA, dateTimeB) => dateTimeA.dayOfTheMonth.split('/')[0] - dateTimeB.dayOfTheMonth.split('/')[0])
.sort((dateTimeA, dateTimeB) => dateTimeA.dayOfTheMonth.split('/')[1] - dateTimeB.dayOfTheMonth.split('/')[1]);
const timeInformation = sortedTimes.map((dt) => {
// Quebra o dia onde tiver a string /, e tira os espaços em branco
let dayOfTheMonth = dt.dayOfTheMonth.replace(/ /g, '').split('/');
// Loop dentro da data, se encontrar algum numero com tamanho 1, significa que precisa colocar o 0
// Por ex, mês 8 tem tamanho 1, precisa ficar 08
for (let i = 0; i < 2; i += 1) if (dayOfTheMonth[i].length === 1) dayOfTheMonth[i] = `0${dayOfTheMonth[i]}`;
// Junta o array, separando por /
dayOfTheMonth = dayOfTheMonth.join('/');
// eslint-disable-next-line max-len
const hours = dt.times.map((time) => (
<RedeHorarioButton
......@@ -40,10 +48,9 @@ function RedeHorarioCard({ mentoria }) {
/>
));
return (
<Details>
<Label>{dt.dayOfTheMonth}</Label>
<Label>{dayOfTheMonth}</Label>
<Hours>
{hours}
</Hours>
......@@ -52,17 +59,23 @@ function RedeHorarioCard({ mentoria }) {
});
function onConfirm(data) {
const newMentoria = { ...mentoriaSelect };
newMentoria.datetime.forEach(element => {
console.log(element);
});
console.log(data.date); // DIA DDO MES ANO DIA
console.log(data.hour); // HORARIO DO NEGÓCIO AHAAAAAAAAAAAAAAAA
const token = sessionStorage.getItem('token');
const headers = { headers: { Authorization: `Bearer ${token}` } };
marcarMentoria(headers, { idMentoria: mentoria.idMentoria, choice: data })
.then((res) => (
res.status === 200
? enqueue('Mentoria cadastrada com sucesso', 'success')
: console.log('Falha ao marcar mentoria. Código: ', res.status)))
.catch((err) => {
enqueue('Erro ao marcar mentoria');
console.error(err);
});
// marcarMentoria(headers, { idMentoria: mentoria.idMentoria, choice: data })
// .then((res) => (
// res.status === 200
// ? enqueue('Mentoria cadastrada com sucesso', 'success')
// : console.log('Falha ao marcar mentoria. Código: ', res.status)))
// .catch((err) => {
// enqueue('Erro ao marcar mentoria');
// console.error(err);
// });
}
return (
......@@ -70,19 +83,19 @@ function RedeHorarioCard({ mentoria }) {
<>
<RedeMarcarMentoria
opened={open}
image={`${urlFiles}/${mentoria.image}`}
title={mentoria.title}
userName={mentoria.mentorInfos.name}
userImage={`${urlFiles}/${mentoria.mentorInfos.image}`}
image={`${urlFiles}/${mentoriaSelect.image}`}
title={mentoriaSelect.title}
userName={mentoriaSelect.mentorInfos.name}
userImage={`${urlFiles}/${mentoriaSelect.mentorInfos.image}`}
date={dateInfo}
hour={timeInfo}
onClose={() => setOpen(false)}
onConfirm={(evt) => onConfirm(evt)}
/>
</>
<Details style={{ borderBottom: 'none' }}>
<Label>Data</Label>
<Label>Hora</Label>
<Details style={{ borderBottom: 'none', marginBottom: '15px', paddingTop: '10px' }}>
<Label>Datas</Label>
<Label style={{ width: '30%' }}>Horários</Label>
</Details>
{timeInformation}
</Container>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment