Skip to content

Commit

Permalink
Merge pull request #2 from julix14/feature/appCheck
Browse files Browse the repository at this point in the history
Feature/app check
  • Loading branch information
julix14 authored Apr 28, 2024
2 parents 7559fcf + 243b058 commit d60a233
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
23 changes: 18 additions & 5 deletions components/multiSelect.vue
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
<template>
<div class="flex flex-col">
<div class="flex flex-col w-fit">
<p>Categories</p>
<div class="flex gap-x-2">
<div
class="flex gap-x-2 shadow-sm ring-1 ring-inset ring-gray-300 rounded-md border-0 bg-white px-2.5 py-1.5 focus:ring-2 focus:ring-primary-500">
<div
class="flex items-center gap-x-2 bg-gray-200 p-2 rounded-md"
class="flex items-center gap-x-2 bg-gray-200 rounded-md"
v-for="category in selectedCategories">
<p>{{ category.name }}</p>
<UIcon
name="i-heroicons-x-mark"
@click="removeCategory(category)" />
</div>
<input
id="search"
type="text"
v-model="search"
@focus="showOptions = true"
@input="filterCategories"
placeholder="Search categories" />
</div>

<select
multiple
v-if="showOptions">
Expand All @@ -40,9 +42,17 @@
import { useCollection } from "vuefire";
import { collection } from "firebase/firestore";
import { v4 as uuidv4 } from "uuid";
const emits = defineEmits(["category-selected", "category-removed"]);
function handleOutsideClick(event) {
const inputElement = event.target.closest('input[id="search"]');
const optionElements = event.target.closest("select");
if (!inputElement && !optionElements) {
showOptions.value = false;
}
}
addEventListener("click", handleOutsideClick);
const { firestore } = useFirebaseClient();
const categories = useCollection(
collection(firestore, "categories").withConverter({
Expand Down Expand Up @@ -95,6 +105,9 @@
}
function createCategory() {
if (search.value.trim() === "") {
return;
}
const newCategory = {
id: uuidv4(),
name: capitalizeFirstLetter(search.value.trim()),
Expand Down
6 changes: 6 additions & 0 deletions nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ export default defineNuxtConfig({
appId: process.env.FIREBASE_APP_ID,
measurementId: process.env.FIREBASE_MEASUREMENT_ID,
},
appCheck: {
debug: process.env.NODE_ENV !== "production",
isTokenAutoRefreshEnabled: true,
provider: "ReCaptchaV3",
key: "6LctAsopAAAAAGPUQLCRKoxSjlMko-zRy17c8ikL",
},
},
nitro: {
firebase: {
Expand Down
18 changes: 12 additions & 6 deletions pages/add-attraction.vue
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
<template>
<div>
<div class="m-2">
<p class="font-bold text-xl">Add Attraction</p>

<form @submit.prevent="addAttraction">
<div class="flex flex-col gap-y-2 mb-2">
<div>
<div class="flex gap-x-2">
<p>Is it in Berlin?</p>
<UToggle v-model="isBerlin" />
<UCheckbox v-model="isBerlin" />
</div>
<div>
<div class="flex gap-x-2">
<p>Is it regionally?</p>
<UToggle v-model="isRegional" />
<UCheckbox v-model="isRegional" />
</div>
<div>
<p>Name</p>
Expand Down Expand Up @@ -97,7 +97,11 @@
:opening-hours="openingHours.sunday" />
</div>
</div>
<UButton type="submit">Save</UButton>
<UButton
type="submit"
class="m-2"
>Save</UButton
>
</form>
</div>
</template>
Expand Down Expand Up @@ -227,6 +231,8 @@
await batch.commit();
console.log("Attraction saved");
window.location.reload();
} catch (error) {
console.error("Error adding attraction:", error);
}
Expand Down

0 comments on commit d60a233

Please sign in to comment.