Skip to content

Commit

Permalink
Minor fixes on Sign up dialog, functions and home
Browse files Browse the repository at this point in the history
  • Loading branch information
resendegu committed Jan 18, 2024
1 parent 0cd157a commit 5139bce
Show file tree
Hide file tree
Showing 6 changed files with 76 additions and 27 deletions.
8 changes: 8 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
REACT_APP_API_KEY=""
REACT_APP_AUTH_DOMAIN=""
REACT_APP_DATABASE_URL=""
REACT_APP_PROJECT_ID=""
REACT_APP_STORAGE_BUCKET=""
REACT_APP_MESSAGING_SENDER_ID=000000000000
REACT_APP_APP_ID=""
REACT_APP_MEASUREMENT_ID=""
8 changes: 5 additions & 3 deletions .firebaserc
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{
"projects": {
"default": "projetoxagencia",
"default": "guresende",
"learnup-prod": "learnupschool",
"prox-prod": "projetoxagencia"
"prox-prod": "projetoxagencia",
"resende": "guresende"
},
"targets": {
"projetoxagencia": {
Expand All @@ -12,5 +13,6 @@
]
}
}
}
},
"etags": {}
}
9 changes: 6 additions & 3 deletions firebase.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,12 @@
"storage": {
"rules": "storage.rules"
},
"functions": {
"source": "functions"
},
"functions": [
{
"source": "functions",
"codebase": "default"
}
],
"remoteconfig": {
"template": "remoteconfig.template.json"
},
Expand Down
39 changes: 23 additions & 16 deletions functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,14 @@ const { auth } = require('firebase-admin');
const { HttpsError } = require('firebase-functions/lib/providers/https');
const { firebaseConfig } = require('firebase-functions');
const { https } = require('firebase-functions');
const { info } = require('firebase-functions/lib/logger');
const {
log,
info,
debug,
warn,
error,
write,
} = require("firebase-functions/logger");
const { Merchant } = require('steplix-emv-qrcps');
const { Constants } = Merchant;
const QRCode = require('qrcode');
Expand Down Expand Up @@ -185,7 +192,7 @@ exports.cadastroUser = functions.auth.user().onCreate((user) => {
let firestoreRef = admin.firestore().collection('mail');

admin.auth().generateEmailVerificationLink(user.email).then(value => {
functions.logger.log(value)
log(value)
let emailContent = {
to: user.email,
message: {
Expand All @@ -207,7 +214,7 @@ exports.cadastroUser = functions.auth.user().onCreate((user) => {
console.error(error)
})
}).catch(error => {
functions.logger.log(error)
log(error)
})

dadosNoBanco.set({
Expand Down Expand Up @@ -612,7 +619,7 @@ exports.cadastraAluno = functions.https.onCall(async (data, context) => {
admin.database().ref('sistemaEscolar/preMatriculas').child(preMatriculaKey).remove().then(() => {

}).catch((error) => {
functions.logger.log(error)
log(error)
})
}

Expand Down Expand Up @@ -1297,10 +1304,10 @@ exports.geraPix = functions.https.onCall((data, context) => {

exports.alteracaoDados = functions.database.ref('sistemaEscolar/alunos/{matricula}/{key}').onUpdate((snapshot, context) => {

functions.logger.log(context.params.key)
functions.logger.log(context.params.matricula)
functions.logger.log(snapshot.before.val())
functions.logger.log(snapshot.after.val())
log(context.params.key)
log(context.params.matricula)
log(snapshot.before.val())
log(snapshot.after.val())
})

exports.systemUpdate = functions.pubsub.schedule('0 2 * * 0').timeZone('America/Sao_Paulo').onRun((context) => {
Expand Down Expand Up @@ -2155,26 +2162,26 @@ exports.escutaFollowUp = functions.database.ref('sistemaEscolar/followUp/{id}').
// const metageneration = object.metageneration; // Number of times metadata has been generated. New objects have a value of 1.
// const metadata = object.metadata; // File metadata.
// // Exit if this is triggered on a file that is not an image.
// functions.logger.log(fileBucket)
// functions.logger.log(filePath);
// functions.logger.log(path.dirname(filePath));
// log(fileBucket)
// log(filePath);
// log(path.dirname(filePath));

// if (!contentType.startsWith('image/') && filePath.indexOf('alunos') == -1) {
// return functions.logger.log('This is not an image.');
// return log('This is not an image.');

// }
// // Get the file name.
// functions.logger.log("URL: ", url);
// log("URL: ", url);
// const fileName = path.basename(filePath);
// const matricula = path.dirname(filePath).split('/')[2];
// functions.logger.log(matricula);
// log(matricula);
// return admin.database().ref(`sistemaEscolar/alunos/${matricula}/fotoAluno`).set(url).then(() => {
// functions.logger.log("Foto adicionada com sucesso!");
// log("Foto adicionada com sucesso!");
// return {
// answer: 'Foto adicionada com sucesso.'
// }
// }).catch(error => {
// functions.logger.log(error);
// log(error);
// })


Expand Down
11 changes: 8 additions & 3 deletions src/home/Home.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { Container } from "@material-ui/core";

const Home = () => {
return (
<div>
<h1>Seja bem vindo ao Sistema Escolar!</h1>
</div>
<Container>
<h2>Bem-vindo ao sistema escolar.</h2>
<p>Este é um projeto em desenvolvimento. Qualquer dúvida, envie um e-mail para <a href="mailto:gustavo@resende.app">gustavo@resende.app</a></p>
<p style={{color: "red"}}>Este é um ambiente de desenvolvimento, não cadastre informações pessoais aqui.</p>
<p>Utilize as ferramentas do site 4devs.com.br para criar informações fictícias para testar o sistema.</p>
</Container>
);
}

Expand Down
28 changes: 26 additions & 2 deletions src/login/SignUpDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,30 @@ const SignUpDialog = (props) => {
const [ open, setOpen ] = useState(true);
const [ status, setStatus ] = useState(null)
const [ showSnack, setShowSnack ] = useState(false);
const errorCodes = {
"auth/wrong-password": (
<span>
Senha incorreta. Tente novamente ou clique em{" "}
<b>&quot;Esqueceu sua senha?&quot;</b> para redefini-la.
</span>
),
"auth/email-already-in-use": (
<span>
E-mail já cadastrado. Tente novamente ou clique em{" "}
<b>&quot;Esqueceu sua senha?&quot;</b> para redefini-la.
</span>
),
"auth/invalid-email": (
<span>
Digite um endereço de e-mail válido.
</span>
),
"auth/internal-error": (
<span>
Ocorreu um erro interno. Tente novamente e se o erro persistir entre em contato com o administrador.
</span>
),
}

const { passwordRecover, createUserWithEmailAndPassword, signOut } = useAuth();

Expand Down Expand Up @@ -91,6 +115,7 @@ const SignUpDialog = (props) => {

})




return (
Expand Down Expand Up @@ -149,8 +174,7 @@ const SignUpDialog = (props) => {
}
}}
helperText={
status === "auth/user-not-found" &&
"Verifique o endereço de e-mail."
status && errorCodes[status]
}
FormHelperTextProps={{ error: true }}
/>
Expand Down

0 comments on commit 5139bce

Please sign in to comment.