diff --git a/ask.html b/ask.html index a390cb48..42213643 100644 --- a/ask.html +++ b/ask.html @@ -120,7 +120,7 @@

Qual é a sua experiência em academia?

Envie uma foto sua para o perfil

- +
diff --git a/configs.html b/configs.html index 0747a3c5..81dee75f 100644 --- a/configs.html +++ b/configs.html @@ -165,6 +165,6 @@

UGYM

- + \ No newline at end of file diff --git a/exercicices.html b/exercicices.html index 50ae183f..dc44c54b 100644 --- a/exercicices.html +++ b/exercicices.html @@ -126,7 +126,6 @@

UGYM

- @@ -142,6 +141,6 @@

Exercícios

- + diff --git a/perf.html b/perf.html index 397485a5..69acd77c 100644 --- a/perf.html +++ b/perf.html @@ -129,15 +129,15 @@

Olá, ''''

-

· Altura

+

·Altura

Não informado

-

· Peso

+

·Peso

Não informado

-

· IMC

+

·IMC

Não informado

@@ -145,15 +145,15 @@

· IMC

-

· Doenças crônicas

+

·Doenças crônicas

Não informado

-

· Necessidades Especiais

+

·Necessidades Especiais

Não informado

-

· Meta

+

·Meta

Não informado

diff --git a/src/css/styles.css b/src/css/styles.css index 101a31d2..fb0b1542 100644 --- a/src/css/styles.css +++ b/src/css/styles.css @@ -596,7 +596,7 @@ button[type="button"] { color: red; } .ask-form-container { - width: 320px; + width: 360px; background: white; padding: 20px; border-radius: 10px; @@ -1315,4 +1315,8 @@ input#file-upload-button { padding-right: 10%; } + input[type="date"]::-webkit-inner-spin-button, + input[type="date"]::-webkit-calendar-picker-indicator { + display: none; + -webkit-appearance: none;} } diff --git a/src/javascript/askscript.js b/src/javascript/askscript.js index e95c6d42..215b31a1 100644 --- a/src/javascript/askscript.js +++ b/src/javascript/askscript.js @@ -1,23 +1,16 @@ document.addEventListener('DOMContentLoaded', () => { - // Obtém todos os elementos dos passos do formulário e armazena em um array const steps = Array.from(document.querySelectorAll('.ask-form-step')); - // Obtém todos os botões de continuação do formulário const continueButtons = document.querySelectorAll('.ask-continue-button'); - // Obtém o botão de voltar const backButton = document.querySelector('.ask-back-button'); - // Obtém todos os passos da barra de progresso const progressBarSteps = document.querySelectorAll('.ask-progress-bar .ask-step'); - let currentStep = 0; // Armazena o índice do passo atual - // Obtém as respostas salvas do localStorage ou inicializa um objeto vazio + let currentStep = 0; let responses = JSON.parse(localStorage.getItem('userResponses')) || {}; - // Função para mostrar um passo específico do formulário function showStep(index, isNext) { const currentFormStep = steps[currentStep]; const nextFormStep = steps[index]; - // Adiciona animação de transição entre passos currentFormStep.style.opacity = '0'; currentFormStep.style.transform = isNext ? 'translateX(-100%)' : 'translateX(100%)'; backButton.style.opacity = '0'; @@ -32,7 +25,6 @@ document.addEventListener('DOMContentLoaded', () => { nextFormStep.style.transform = 'translateX(0)'; progressBarSteps[index].classList.add('active'); - // Mostra o botão de voltar se não estiver no primeiro passo if (index > 0) { backButton.classList.add('active'); setTimeout(() => { @@ -43,48 +35,36 @@ document.addEventListener('DOMContentLoaded', () => { backButton.classList.remove('active'); } - currentStep = index; // Atualiza o passo atual + currentStep = index; }, 500); } - // Função para salvar as respostas do formulário function saveResponses() { const currentStepElement = steps[currentStep]; - - // Salva as respostas com base no passo atual - if (currentStep === 0) { // Etapa 1: Nome - const signupName = currentStepElement.querySelector('input#singupname').value; - responses.signupName = signupName; - } else if (currentStep === 1) { // Etapa 2: Meta - const meta = currentStepElement.querySelector('input[placeholder="Digite sua meta"]').value; - responses.meta = meta; - } else if (currentStep === 2) { // Etapa 3: Peso e Altura - const weight = currentStepElement.querySelector('input[placeholder="Insira seu peso"]').value; - const height = currentStepElement.querySelector('input[placeholder="Insira sua altura"]').value; - responses.weight = weight; - responses.height = height; - } else if (currentStep === 3) { // Etapa 4: Dias de treino - const trainingDays = currentStepElement.querySelector('input[placeholder="De 1 a 7 dias"]').value; - responses.trainingDays = trainingDays; - } else if (currentStep === 4) { // Etapa 5: Doença - const disease = currentStepElement.querySelector('input#disease-input').value; - responses.disease = disease; - } else if (currentStep === 5) { // Etapa 6: Condição especial - const specialCondition = currentStepElement.querySelector('input#special-condition-input').value; - responses.specialCondition = specialCondition; - } else if (currentStep === 6) { // Etapa 7: Número de celular - const phoneNumber = currentStepElement.querySelector('input[type="tel"]').value; - responses.phoneNumber = phoneNumber; - } else if (currentStep === 7) { // Etapa 8: Data de nascimento - const birthDate = currentStepElement.querySelector('input[type="date"]').value; - responses.birthDate = birthDate; - } else if (currentStep === 8) { // Etapa 9: Gênero - const gender = Array.from(currentStepElement.querySelectorAll('.ask-option-button.selected')).map(btn => btn.textContent).join(', '); - responses.gender = gender; - } else if (currentStep === 9) { // Etapa 10: Experiência - const experience = Array.from(currentStepElement.querySelectorAll('.ask-option-button.selected')).map(btn => btn.textContent).join(', '); - responses.experience = experience; - } else if (currentStep === 10) { // Etapa 11: Foto de perfil + + // Ajuste para pegar os valores corretamente + if (currentStep === 0) { + responses.signupName = currentStepElement.querySelector('input#singupname').value; + } else if (currentStep === 1) { + responses.meta = currentStepElement.querySelector('input[placeholder="Digite sua meta"]').value; + } else if (currentStep === 2) { + responses.weight = currentStepElement.querySelector('input[placeholder="Insira seu peso"]').value; + responses.height = currentStepElement.querySelector('input[placeholder="Insira sua altura"]').value; + } else if (currentStep === 3) { + responses.trainingDays = currentStepElement.querySelector('input[placeholder="De 1 a 7 dias"]').value; + } else if (currentStep === 4) { + responses.disease = currentStepElement.querySelector('input#disease-input').value; + } else if (currentStep === 5) { + responses.specialCondition = currentStepElement.querySelector('input#special-condition-input').value; + } else if (currentStep === 6) { + responses.phoneNumber = currentStepElement.querySelector('input[type="tel"]').value; + } else if (currentStep === 7) { + responses.birthDate = currentStepElement.querySelector('input[type="date"]').value; + } else if (currentStep === 8) { + responses.gender = Array.from(currentStepElement.querySelectorAll('.ask-option-button.selected')).map(btn => btn.textContent).join(', '); + } else if (currentStep === 9) { + responses.experience = Array.from(currentStepElement.querySelectorAll('.ask-option-button.selected')).map(btn => btn.textContent).join(', '); + } else if (currentStep === 10) { const fileInput = currentStepElement.querySelector('input#ask-profile-image'); if (fileInput.files.length > 0) { const file = fileInput.files[0]; @@ -93,7 +73,6 @@ document.addEventListener('DOMContentLoaded', () => { const imageUrl = e.target.result; responses.profileImage = imageUrl; localStorage.setItem('userResponses', JSON.stringify(responses)); - // Atualiza a visualização da imagem de perfil const profileAvatar = document.getElementById('profile-avatar'); if (profileAvatar) { profileAvatar.src = imageUrl; @@ -101,95 +80,86 @@ document.addEventListener('DOMContentLoaded', () => { }; reader.readAsDataURL(file); } else { - // Caso não haja arquivo selecionado, mantenha o valor antigo responses.profileImage = responses.profileImage || ''; localStorage.setItem('userResponses', JSON.stringify(responses)); } } - // Salva as respostas no localStorage localStorage.setItem('userResponses', JSON.stringify(responses)); } - // Função para submeter o formulário function submitForm() { - // Certifique-se de que todas as etapas foram concluídas e as respostas foram salvas saveResponses(); - // Envia os dados para o servidor - fetch(`${URL_API}/users/me`, { // Atualize a URL conforme necessário - method: "PUT", // Ou POST se estiver criando um novo usuário + fetch(`${URL_API}/users/me`, { + method: "PUT", headers: { "Content-Type": "application/json", - "Authorization": `Bearer ${yourAuthToken}` // Inclua o token de autenticação se necessário }, body: JSON.stringify(responses) }) - .then(response => response.json()) // Converte a resposta para JSON + .then(response => { + if (!response.ok) { + throw new Error(`HTTP deu erro! status: ${response.status}`); + } + return response.json(); + }) .then(data => { - console.log(data); // Exibe os dados recebidos no console - alert("Informações atualizadas com sucesso!"); // Exibe uma mensagem de sucesso - window.location.href = "https://ifpi-picos.github.io/projeto-integrador-ugym/perf.html"; // Redireciona para a página de perfil + console.log(data); + alert("Informações atualizadas com sucesso!"); + window.location.href = "https://ifpi-picos.github.io/projeto-integrador-ugym/perf.html"; }) .catch(error => { - console.error("Erro ao atualizar informações:", error); // Exibe o erro no console - alert("Erro ao atualizar informações!"); // Exibe uma mensagem de erro + console.error("Erro ao atualizar informações:", error); + alert("Erro ao atualizar informações!"); }); } - // Adiciona eventos de clique aos botões de continuação continueButtons.forEach(button => { button.addEventListener('click', () => { - saveResponses(); // Salva as respostas antes de mudar de etapa + saveResponses(); if (currentStep < steps.length - 1) { - showStep(currentStep + 1, true); // Mostra o próximo passo + showStep(currentStep + 1, true); } else { - // Se for a última etapa, submete o formulário submitForm(); } }); }); - // Adiciona evento de clique ao botão de voltar backButton.addEventListener('click', () => { if (currentStep > 0) { - showStep(currentStep - 1, false); // Mostra o passo anterior + showStep(currentStep - 1, false); } }); - // Adiciona eventos de clique aos botões de opção const optionButtons = document.querySelectorAll(".ask-option-button"); optionButtons.forEach(button => { button.addEventListener("click", () => { - optionButtons.forEach(btn => btn.classList.remove("selected")); // Remove a seleção de todas as opções - button.classList.add("selected"); // Adiciona a seleção ao botão clicado + optionButtons.forEach(btn => btn.classList.remove("selected")); + button.classList.add("selected"); }); }); }); -// Função para levar o usuário para a próxima página, no caso a de perfil function proxpage() { window.location.href = "https://ifpi-picos.github.io/projeto-integrador-ugym/perf.html"; } -// Função para mostrar o input de doença function showInput() { const input = document.getElementById('disease-input'); - input.style.display = 'block'; // Torna o input visível + input.style.display = 'block'; } -// Função para ocultar o input de doença function hideInput() { const input = document.getElementById('disease-input'); - input.style.display = 'none'; // Torna o input invisível + input.style.display = 'none'; } -// Função para manipular a mudança de opções e exibir ou ocultar inputs function handleOptionChange(option, inputId) { const inputElement = document.getElementById(inputId); if (option === 'Sim') { - inputElement.style.display = 'block'; // Torna o input visível se a opção for 'Sim' + inputElement.style.display = 'block'; } else { - inputElement.style.display = 'none'; // Torna o input invisível se a opção não for 'Sim' + inputElement.style.display = 'none'; } } diff --git a/src/javascript/scriptaskreturninfo.js b/src/javascript/scriptaskreturninfo.js index f723e736..adce4e76 100644 --- a/src/javascript/scriptaskreturninfo.js +++ b/src/javascript/scriptaskreturninfo.js @@ -17,13 +17,10 @@ document.addEventListener('DOMContentLoaded', () => { document.getElementById('profile-imc').textContent = imc || 'Não informado'; function calculateIMC(weight, height) { - // Convert weight from kg to grams + const weightInGrams = weight * 1000; - // Convert height from cm to meters const heightInMeters = height / 100; - // Calculate the IMC const imc = weightInGrams / (heightInMeters * heightInMeters); - // Round the IMC to two decimal places return imc.toFixed(2); } document.getElementById('profile-meta').textContent = userResponses.meta || 'Não informado'; diff --git a/src/javascript/singin-signup.js b/src/javascript/singin-signup.js index 79a8b26f..6e370c02 100644 --- a/src/javascript/singin-signup.js +++ b/src/javascript/singin-signup.js @@ -2,9 +2,9 @@ const URL_API = location.hostname === "localhost" || location.hostname === "127. "http://localhost:3000" : "https://ugym-backend.onrender.com" -/* if(localStorage.getItem("token")){ +if(localStorage.getItem("token")){ window.location.href = "https://ifpi-picos.github.io/projeto-integrador-ugym/home.html"; -} */ +} function cadastro(){