Füge Validierung für E-Mail und benutzerdefinierte Eingaben hinzu; aktualisiere Firebase-Konfigurationsdateien

This commit is contained in:
Luis
2025-05-20 20:36:45 +02:00
parent 4c0398dd79
commit 7d3214e6be
5 changed files with 79 additions and 4 deletions

5
.firebaserc Normal file
View File

@@ -0,0 +1,5 @@
{
"projects": {
"default": "skatabend0"
}
}

View File

@@ -0,0 +1,20 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools
name: Deploy to Firebase Hosting on merge
on:
push:
branches:
- master
jobs:
build_and_deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm run build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_SKATABEND0 }}
channelId: live
projectId: skatabend0

View File

@@ -0,0 +1,21 @@
# This file was auto-generated by the Firebase CLI
# https://github.com/firebase/firebase-tools
name: Deploy to Firebase Hosting on PR
on: pull_request
permissions:
checks: write
contents: read
pull-requests: write
jobs:
build_and_preview:
if: ${{ github.event.pull_request.head.repo.full_name == github.repository }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- run: npm ci && npm run build
- uses: FirebaseExtended/action-hosting-deploy@v0
with:
repoToken: ${{ secrets.GITHUB_TOKEN }}
firebaseServiceAccount: ${{ secrets.FIREBASE_SERVICE_ACCOUNT_SKATABEND0 }}
projectId: skatabend0

16
firebase.json Normal file
View File

@@ -0,0 +1,16 @@
{
"hosting": {
"public": "build",
"ignore": [
"firebase.json",
"**/.*",
"**/node_modules/**"
],
"rewrites": [
{
"source": "**",
"destination": "/index.html"
}
]
}
}

View File

@@ -3,7 +3,7 @@ import './App.css';
function App() {
const formSectionRef = useRef(null);
const [customNumber, setCustomNumber] = useState();
const [customNumber, setCustomNumber] = useState(false);
const [email, setEmail] = useState("");
@@ -24,11 +24,24 @@ function App() {
setCustomNumber(e.target.value === 'custom' ? '' : e.target.value);
};
const emailIsValid = (email1) => {
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email1)
}
const submit = (e) => {
e.preventDefault(); // Verhindert das Standardverhalten des Formulars
if (email === ""){
if (!emailIsValid(email)){
alert("Bitte eine gültige E-Mailadresse eintrgen");
return;
}
if(!customNumber){
alert("Bitte angeben wie viele Personen mitkommen");
return;
}
// send data
alert("Anmeldung gesendet.")
setEmail("")
setCustomNumber(false)
}
return (
@@ -54,7 +67,7 @@ function App() {
<div id="form-section" ref={formSectionRef}>
<form>
<label>E-Mail:</label>
<input type="email" name="email" placeholder="Deine E-Mail-Adresse" onChange={(e => setEmail(e.target.value))} />
<input type="email" name="email" placeholder="Deine E-Mail-Adresse" onChange={(e => setEmail(e.target.value))} value={email}/>
<br />
<label>Anzahl der Personen</label>
<div className="radio-group">