diff --git a/.firebaserc b/.firebaserc new file mode 100644 index 0000000..339cd1a --- /dev/null +++ b/.firebaserc @@ -0,0 +1,5 @@ +{ + "projects": { + "default": "skatabend0" + } +} diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml new file mode 100644 index 0000000..eee87f2 --- /dev/null +++ b/.github/workflows/firebase-hosting-merge.yml @@ -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 diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml new file mode 100644 index 0000000..3de4e94 --- /dev/null +++ b/.github/workflows/firebase-hosting-pull-request.yml @@ -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 diff --git a/firebase.json b/firebase.json new file mode 100644 index 0000000..340ed5b --- /dev/null +++ b/firebase.json @@ -0,0 +1,16 @@ +{ + "hosting": { + "public": "build", + "ignore": [ + "firebase.json", + "**/.*", + "**/node_modules/**" + ], + "rewrites": [ + { + "source": "**", + "destination": "/index.html" + } + ] + } +} diff --git a/src/App.js b/src/App.js index 398c977..db08d14 100644 --- a/src/App.js +++ b/src/App.js @@ -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() {
- setEmail(e.target.value))} /> + setEmail(e.target.value))} value={email}/>