MVP #6.1 #82
|
@ -13,7 +13,7 @@
|
|||
<!-- Serviceworker registration -->
|
||||
<script>
|
||||
if (typeof navigator.serviceWorker !== 'undefined') {
|
||||
navigator.serviceWorker.register('sw.js')
|
||||
navigator.serviceWorker.register('servicewworker.js')
|
||||
}
|
||||
</script>
|
||||
|
||||
|
|
|
@ -39,9 +39,10 @@
|
|||
"eslint-plugin-promise": "^6.1.1",
|
||||
"flowbite-svelte": "^0.28.11",
|
||||
"postcss": "^8.4.19",
|
||||
"sass": "^1.56.1",
|
||||
"sass": "^1.59.3",
|
||||
"svelte": "^3.52.0",
|
||||
"svelte-preprocess": "^4.10.7",
|
||||
"svelte-preprocess-sass": "^2.0.1",
|
||||
"tailwindcss": "^3.2.4",
|
||||
"typescript": "^4.9.5",
|
||||
"vite": "^3.2.3"
|
||||
|
@ -5823,6 +5824,24 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"node_modules/svelte-preprocess-filter": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/svelte-preprocess-filter/-/svelte-preprocess-filter-1.0.0.tgz",
|
||||
"integrity": "sha512-92innv59nyEx24xbfcSurB5ocwC8qFdDtGli/JVMHzJsxyvV2yjQKIcbUqU9VIV5mKUWO2PoY93nncS2yF4ULQ==",
|
||||
"dev": true
|
||||
},
|
||||
"node_modules/svelte-preprocess-sass": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/svelte-preprocess-sass/-/svelte-preprocess-sass-2.0.1.tgz",
|
||||
"integrity": "sha512-0y4FjRsRWcN7rJeNJnSfZ7LVAz6S7/j9Dg24XFRelr/rjMMjXORdEvXy4r38fUYmyk9Y7yjwlHCiqyGxMHhEbg==",
|
||||
"dev": true,
|
||||
"dependencies": {
|
||||
"svelte-preprocess-filter": "^1.0.0"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"sass": "^1.35.2"
|
||||
}
|
||||
},
|
||||
"node_modules/svelte-preprocess/node_modules/magic-string": {
|
||||
"version": "0.25.9",
|
||||
"resolved": "https://registry.npmjs.org/magic-string/-/magic-string-0.25.9.tgz",
|
||||
|
@ -10417,6 +10436,21 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"svelte-preprocess-filter": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/svelte-preprocess-filter/-/svelte-preprocess-filter-1.0.0.tgz",
|
||||
"integrity": "sha512-92innv59nyEx24xbfcSurB5ocwC8qFdDtGli/JVMHzJsxyvV2yjQKIcbUqU9VIV5mKUWO2PoY93nncS2yF4ULQ==",
|
||||
"dev": true
|
||||
},
|
||||
"svelte-preprocess-sass": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/svelte-preprocess-sass/-/svelte-preprocess-sass-2.0.1.tgz",
|
||||
"integrity": "sha512-0y4FjRsRWcN7rJeNJnSfZ7LVAz6S7/j9Dg24XFRelr/rjMMjXORdEvXy4r38fUYmyk9Y7yjwlHCiqyGxMHhEbg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"svelte-preprocess-filter": "^1.0.0"
|
||||
}
|
||||
},
|
||||
"svelte-routing": {
|
||||
"version": "1.6.0",
|
||||
"resolved": "https://registry.npmjs.org/svelte-routing/-/svelte-routing-1.6.0.tgz",
|
||||
|
|
|
@ -22,9 +22,10 @@
|
|||
"eslint-plugin-promise": "^6.1.1",
|
||||
"flowbite-svelte": "^0.28.11",
|
||||
"postcss": "^8.4.19",
|
||||
"sass": "^1.56.1",
|
||||
"sass": "^1.59.3",
|
||||
"svelte": "^3.52.0",
|
||||
"svelte-preprocess": "^4.10.7",
|
||||
"svelte-preprocess-sass": "^2.0.1",
|
||||
"tailwindcss": "^3.2.4",
|
||||
"typescript": "^4.9.5",
|
||||
"vite": "^3.2.3"
|
||||
|
|
|
@ -2,5 +2,5 @@ const autoprefixer = require('autoprefixer')
|
|||
const tailwind = require('tailwindcss')
|
||||
|
||||
module.exports = {
|
||||
plugins: [tailwind(), autoprefixer()],
|
||||
plugins: [tailwind(), autoprefixer()]
|
||||
}
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
// This is the service worker with the combined offline experience (Offline page + Offline copy of pages)
|
||||
import { workbox } from 'https://storage.googleapis.com/workbox-cdn/releases/5.1.4/workbox-sw.js'
|
||||
import workbox from 'workbox-sw'
|
||||
|
||||
const CACHE = 'pwabuilder-offline-page'
|
||||
|
||||
importScripts('https://storage.googleapis.com/workbox-cdn/releases/5.1.4/workbox-sw.js')
|
||||
|
||||
// TODO: replace the following with the correct offline fallback page i.e.: const offlineFallbackPage = "offline.html";
|
||||
const offlineFallbackPage = '/offline.html'
|
||||
|
||||
|
|
|
@ -76,7 +76,7 @@
|
|||
},
|
||||
{
|
||||
path: '/:gameurl',
|
||||
component: () => import('$routes/game/game.svelte'),
|
||||
component: () => import('$root/src/routes/game/experience.svelte'),
|
||||
},
|
||||
{
|
||||
path: '/terms-and-conditions',
|
||||
|
@ -94,5 +94,9 @@
|
|||
path: '/forgot-pswd',
|
||||
component: () => import('$routes/authorization/forgottonPassword/forgot-pswd.svelte'),
|
||||
},
|
||||
{
|
||||
path: '/preferences',
|
||||
component: () => import('$root/src/routes/onboarding/interestsPage.svelte'),
|
||||
}
|
||||
]}
|
||||
/>
|
||||
|
|
|
@ -2,8 +2,10 @@ import { Collection } from './appwrite'
|
|||
|
||||
const experiences = new Collection('63cef30d6da945dd4250', '63cef4bd210fdf2e5888')
|
||||
const users = new Collection('63ded6c18e8493bffc83', 'Users')
|
||||
const categories = new Collection('63cef30d6da945dd4250', '63cef4bd210fdf2e5888')
|
||||
|
||||
export default {
|
||||
experiences,
|
||||
users,
|
||||
categories,
|
||||
}
|
||||
|
|
|
@ -0,0 +1,55 @@
|
|||
<!-- This component is imported to display a category to (de)select-->
|
||||
<script lang="ts">
|
||||
export let name;
|
||||
export let image;
|
||||
export let selected = false;
|
||||
export let onToggle = () => {};
|
||||
|
||||
const handleClick = () => {
|
||||
onToggle();
|
||||
};
|
||||
</script>
|
||||
|
||||
<div class="category" class:selected={selected} on:click={handleClick}>
|
||||
<div class="image">
|
||||
<img src={image} alt={name} />
|
||||
</div>
|
||||
<div class="name">{name}</div>
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
.category {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
width: 120px;
|
||||
margin: 10px;
|
||||
cursor: pointer;
|
||||
|
||||
.image {
|
||||
width: 100%;
|
||||
padding-top: 100%;
|
||||
position: relative;
|
||||
|
||||
img {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
}
|
||||
}
|
||||
|
||||
.name {
|
||||
margin-top: 5px;
|
||||
font-size: 14px;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
&.selected {
|
||||
border: 2px solid blue;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
|
|
@ -3,6 +3,7 @@
|
|||
import collections from '$lib/collections'
|
||||
import { Query } from 'appwrite'
|
||||
import { navigate } from 'svelte-routing'
|
||||
import Category from "$lib/components/Categories/category.svelte";
|
||||
|
||||
export let current_state = 1
|
||||
|
|
@ -33,3 +33,4 @@
|
|||
{/if}
|
||||
{/each}
|
||||
</Router>
|
||||
|
||||
|
|
|
@ -14,7 +14,7 @@ async function send({ method, path, body, token, headers }) {
|
|||
}
|
||||
|
||||
if (token) {
|
||||
opts.headers['Authorization'] = `Bearer ${token}`
|
||||
opts.headers.Authorization = `Bearer ${token}`
|
||||
}
|
||||
|
||||
const res = fetch(path, opts)
|
||||
|
|
|
@ -5,6 +5,7 @@ import { getLocationDataFromLatAndLong } from '../locations'
|
|||
import { writable } from 'svelte/store'
|
||||
import { CheckPoint, Experience } from '$lib/TStypes/experiences'
|
||||
|
||||
//Loading of checkpoints and rating is done in the same function to prevent multiple requests to the database
|
||||
export const load = async (pathName: string, previewQuestionsCount?: number, preview?: Function) => {
|
||||
const checkPoints: Array<CheckPoint> = []
|
||||
// @ts-ignore
|
||||
|
@ -30,13 +31,13 @@ export const load = async (pathName: string, previewQuestionsCount?: number, pre
|
|||
|
||||
return experience
|
||||
}
|
||||
|
||||
//Fetch of Rating
|
||||
const getRating = async (expId: string) => {
|
||||
const { documents, total } = await databases.listDocuments('63cef30d6da945dd4250', '63ee6353ebb174cf815d', [Query.equal('ExpID', expId)])
|
||||
const sum = documents.reduce((accumulator, rating) => accumulator + rating.ExpUserRating, 0)
|
||||
return sum / total || 0
|
||||
}
|
||||
|
||||
// Fetch of answers to the checkpoints
|
||||
export const answer = async (checkPointId: string, answer: any) => {
|
||||
const checkPoint = await databases.getDocument('63cef30d6da945dd4250', '63cef84d908acf805758', checkPointId)
|
||||
console.log({ checkPoint })
|
||||
|
@ -46,29 +47,29 @@ export const answer = async (checkPointId: string, answer: any) => {
|
|||
if (CPType === 'CHECKBOX') return JSON.stringify(answer) === JSON.stringify(correctAnswer)
|
||||
if (CPType === 'RADIO' || CPType === 'NUMBER' || CPType === 'TEXT') return answer === correctAnswer[0]
|
||||
}
|
||||
|
||||
export const getExpiriences = async () => {
|
||||
const expiriences = (await databases.listDocuments('63cef30d6da945dd4250', '63cef4bd210fdf2e5888', [Query.equal('ExpApproved', true)])).documents
|
||||
// Fetch of all experiences
|
||||
export const getExperiences = async () => {
|
||||
const experiences = (await databases.listDocuments('63cef30d6da945dd4250', '63cef4bd210fdf2e5888', [Query.equal('ExpApproved', true)])).documents
|
||||
let items = []
|
||||
for (const expirience of expiriences) {
|
||||
for (const experience of experiences) {
|
||||
items.push({
|
||||
city: (await getLocationDataFromLatAndLong(expirience.ExpLocation[0], expirience.ExpLocation[1])).city,
|
||||
...expirience,
|
||||
city: (await getLocationDataFromLatAndLong(experience.ExpLocation[0], experience.ExpLocation[1])).city,
|
||||
...experience,
|
||||
})
|
||||
}
|
||||
|
||||
return items
|
||||
}
|
||||
|
||||
export const getExpiriencesAsStore = () => {
|
||||
// Fetch of all experiences as store
|
||||
export const getExperiencesAsStore = () => {
|
||||
const store = writable([])
|
||||
const loading = writable<boolean>(true)
|
||||
databases.listDocuments('63cef30d6da945dd4250', '63cef4bd210fdf2e5888', [Query.equal('ExpApproved', true)]).then(async ({ documents }) => {
|
||||
let items: Array<any> = []
|
||||
for (const expirience of documents) {
|
||||
for (const experience of documents) {
|
||||
items.push({
|
||||
city: (await getLocationDataFromLatAndLong(expirience.ExpLocation[0], expirience.ExpLocation[1])).city,
|
||||
...expirience,
|
||||
city: (await getLocationDataFromLatAndLong(experience.ExpLocation[0], experience.ExpLocation[1])).city,
|
||||
...experience,
|
||||
})
|
||||
}
|
||||
loading.set(false)
|
||||
|
@ -77,3 +78,10 @@ export const getExpiriencesAsStore = () => {
|
|||
|
||||
return [store, loading] as const
|
||||
}
|
||||
|
||||
// !pridat trideni podle kategorie! export const getExperiencesByCategory = async (category: string) => {}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,25 @@
|
|||
import { databases } from '$lib/appwrite';
|
||||
import { Query } from 'appwrite';
|
||||
|
||||
export const getPreferences = async () => {
|
||||
const { documents } = await databases.listDocuments('6417cf1de159d094b370', '6417cf29f2118829b3b4', [
|
||||
Query.orderAsc('Name')
|
||||
]);
|
||||
|
||||
const preferences = documents.map(({ Name, Image }) => ({ name: Name, img: Image }));
|
||||
|
||||
return preferences;
|
||||
};
|
||||
|
||||
export const addSelectedPreferences = async (userId, preferences) => {
|
||||
const { document: user } = await databases.getDocument('63ded6c18e8493bffc83', 'Users', userId);
|
||||
|
||||
const updatedUser = {
|
||||
...user,
|
||||
userPreferences: preferences
|
||||
};
|
||||
|
||||
await databases.updateDocument('6417cf1de159d094b370', 'user-collection', user.$id, updatedUser);
|
||||
|
||||
return updatedUser;
|
||||
};
|
|
@ -0,0 +1,13 @@
|
|||
{
|
||||
"page": {
|
||||
"home": {
|
||||
"title": "Discover the best Travel Experiences"
|
||||
},
|
||||
"Map": {
|
||||
"title": "Map the best Travel Experiences"
|
||||
},
|
||||
"register": {
|
||||
"title": "Register to the best Travel Experiences"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
import { register, init, getLocaleFromNavigator, isLoading, locale, locales } from 'svelte-i18n'
|
||||
import registers from './languages'
|
||||
|
||||
Object.entries(registers).forEach(([key, file]) => register(key, file))
|
||||
|
||||
export const i18n = () => init({
|
||||
fallbackLocale: 'en',
|
||||
initialLocale: getLocaleFromNavigator(),
|
||||
})
|
||||
|
||||
export { isLoading, locale, locales }
|
|
@ -0,0 +1,4 @@
|
|||
export default {
|
||||
'en': () => import('./en.json'),
|
||||
'cz': () => import('./cz.json')
|
||||
}
|
|
@ -10,11 +10,11 @@
|
|||
import { Helper } from 'flowbite-svelte'
|
||||
import Button from '$lib/components/Buttons/Button.svelte'
|
||||
|
||||
let email = 'dfsafads'
|
||||
let password = 'aaaaaaaaa'
|
||||
let repeatPassword = 'aaaaaaaaa'
|
||||
let name = 'fdsafsda'
|
||||
let erantId = 'dfsafdsa'
|
||||
let email = ''
|
||||
let password = ''
|
||||
let repeatPassword = ''
|
||||
let name = ''
|
||||
let erantId = ''
|
||||
|
||||
let state: 'email-sent' | 'register' | 'loading' = 'register'
|
||||
let error: string | null = null
|
||||
|
@ -26,7 +26,7 @@
|
|||
state = 'loading'
|
||||
error = null
|
||||
if (await getUserByErantId(erantId)) {
|
||||
const err = new Error('fdjsaůl')
|
||||
const err = new Error('Erant ID is already taken')
|
||||
err['code'] = 1001
|
||||
throw err
|
||||
}
|
||||
|
@ -57,8 +57,8 @@
|
|||
<Helper class="ml-4" color="red">{error}</Helper>
|
||||
{/if}
|
||||
<div class="inform">
|
||||
<input bind:value={name} type="text" placeholder="Name" autocomplete="full-name" required />
|
||||
<input bind:value={email} type="text" placeholder="E-mail" autocomplete="email" required />
|
||||
<input bind:value={name} type="text" placeholder="Your name" autocomplete="full-name" required />
|
||||
<input bind:value={email} type="text" placeholder="Your e-mail" autocomplete="email" required />
|
||||
<input bind:value={erantId} type="text" placeholder="@your_nickname" autocomplete="email" required />
|
||||
<HiddenInput bind:value={password} placeholder="Password" />
|
||||
<HiddenInput bind:value={repeatPassword} placeholder="Re-type password" />
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import NavigationBarLayout from '../../lib/components/Layouts/NavigationBarLayout.svelte'
|
||||
import Result from './Components/Result.svelte'
|
||||
import Top from './Components/Top.svelte'
|
||||
import { getExpiriences } from '$lib/utils/database/game'
|
||||
import { getExperiences } from '$lib/utils/database/experience'
|
||||
import Loading from '$lib/components/Common/Loading.svelte'
|
||||
import Comparment from '../homepage/Components/Comparment.svelte'
|
||||
|
||||
|
@ -14,7 +14,7 @@
|
|||
<Top bind:search_value={Search} />
|
||||
|
||||
<div class="results">
|
||||
{#await getExpiriences()}
|
||||
{#await getExperiences()}
|
||||
<div class="w-full h-24 flex items-center justify-center">
|
||||
<Loading />
|
||||
</div>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import Layout from '../Components/Layout.svelte'
|
||||
import CheckBox from '../../../lib/components/Inputs/Checkbox.svelte'
|
||||
import { CheckPoint } from '$lib/TStypes/experiences'
|
||||
import { answer } from '$lib/utils/database/game'
|
||||
import { answer } from '$lib/utils/database/experience'
|
||||
|
||||
export let checkPoint: CheckPoint
|
||||
export let myAnswer
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
<script lang="ts">
|
||||
import Input from '../../../lib/components/Inputs/Input.svelte'
|
||||
import { CheckPoint } from '$lib/TStypes/experiences'
|
||||
import { answer } from '$lib/utils/database/experience'
|
||||
|
||||
export let myAnswer = ''
|
||||
export let clear: false | true = false
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
import IntervalForm from './IntervalForm.svelte'
|
||||
import QrCode from './QrCode.svelte'
|
||||
import Finish from './Finish.svelte'
|
||||
import { data } from '$lib/stores/game'
|
||||
import { data } from '$lib/stores/stores'
|
||||
import Erantmap from '$lib/components/Map/Erantmap.svelte'
|
||||
import Info from './Info.svelte'
|
||||
import { Experience } from '$lib/TStypes/experiences'
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import Radio from '../../../lib/components/Inputs/Radio.svelte'
|
||||
import Layout from '../Components/Layout.svelte'
|
||||
import { CheckPoint } from '$lib/TStypes/experiences'
|
||||
import { answer } from '$lib/utils/database/game'
|
||||
import { answer } from '$lib/utils/database/experience'
|
||||
|
||||
export let checkPoint: CheckPoint
|
||||
export let myAnswer = ''
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
import Layout from '../Components/Layout.svelte'
|
||||
import Input from '../../../lib/components/Inputs/Input.svelte'
|
||||
import { CheckPoint } from '$lib/TStypes/experiences'
|
||||
import { answer } from '$lib/utils/database/game'
|
||||
import { answer } from '$lib/utils/database/experience'
|
||||
|
||||
export let myAnswer = ''
|
||||
export let clear: false | true = false
|
||||
|
|
|
@ -6,12 +6,13 @@
|
|||
import IconStar from '../../lib/svg/Star.svelte'
|
||||
import IconPoint from '../../lib/svg/Point.svelte'
|
||||
import Loading from '../../lib/components/Common/Loading.svelte'
|
||||
import { data } from '../../lib/stores/game'
|
||||
import { data } from '../../lib/stores/stores'
|
||||
import GeolocateControl from '@beyonk/svelte-mapbox/src/lib/map/controls/GeolocateControl.svelte'
|
||||
import Map from '../../lib/components/Map/Map.svelte'
|
||||
import Renderer from './Forms/Renderer.svelte'
|
||||
import Marker from '../../lib/components/Map/Marker.svelte'
|
||||
import { onMount } from 'svelte'
|
||||
import { load } from '$lib/utils/database/game'
|
||||
import { load } from '$lib/utils/database/experience'
|
||||
import { getLocationDataFromLatAndLong } from '$lib/utils/locations'
|
||||
import { navigate } from '$lib/router'
|
||||
|
||||
|
@ -21,8 +22,9 @@
|
|||
try {
|
||||
$data = await load(params.gameurl, 10, (preview) => {
|
||||
$data = preview
|
||||
view = 'game-preview'
|
||||
view = 'experience-preview'
|
||||
})
|
||||
view = 'experience-preview'
|
||||
} catch (error) {
|
||||
navigate('/error')
|
||||
}
|
||||
|
@ -33,19 +35,19 @@
|
|||
?.slice(0, 8)
|
||||
?.map((q) => q.thumbnail)*/
|
||||
|
||||
let view: 'game-play' | 'game-loading' | 'game-preview' = 'game-loading'
|
||||
let view: 'experience-play' | 'experience-loading' | 'experience-preview' = 'experience-loading'
|
||||
|
||||
//is user already in game
|
||||
//const userInGame = JSON.parse(localStorage.getItem(location.pathname))
|
||||
//$: if ($data && userInGame) view = 'game-play'
|
||||
</script>
|
||||
|
||||
{#if view === 'game-loading'}
|
||||
{#if view === 'experience-loading'}
|
||||
<h1 class="flex items-center justify-center flex-col">
|
||||
<span>Experience is loading...</span>
|
||||
<Loading />
|
||||
</h1>
|
||||
{:else if view === 'game-preview'}
|
||||
{:else if view === 'experience-preview'}
|
||||
<Overlay shareData={{ url: window.location.href }} img={$data.ExpImage}>
|
||||
<div>
|
||||
<span class="text-[36px]">{$data.ExpName}</span>
|
||||
|
@ -93,7 +95,7 @@
|
|||
<Button on:click={() => (view = 'game-play')} primary>Hrát</Button>
|
||||
{/if}
|
||||
</Overlay>
|
||||
{:else if view === 'game-play'}
|
||||
{:else if view === 'experience-play'}
|
||||
<Renderer gameData={$data} />
|
||||
{/if}
|
||||
|
|
@ -6,7 +6,7 @@
|
|||
import Comparment from './Components/Comparment.svelte' //do budoucna bych to udělal pomocí komponent
|
||||
import { onMount } from 'svelte'
|
||||
import Animation from './Components/Animation.svelte'
|
||||
import { getExpiriences } from '$lib/utils/database/game'
|
||||
import { getExperiences } from '$lib/utils/database/experience'
|
||||
import Loading from '$lib/components/Common/Loading.svelte'
|
||||
|
||||
let fitstTime = false
|
||||
|
@ -45,12 +45,12 @@
|
|||
|
||||
<Categories />
|
||||
|
||||
{#await getExpiriences()}
|
||||
{#await getExperiences()}
|
||||
<div class="w-full h-24 flex items-center justify-center">
|
||||
<Loading />
|
||||
</div>
|
||||
{:then expiriences}
|
||||
<Comparment items={expiriences} />
|
||||
{:then experiences}
|
||||
<Comparment items={experiences} />
|
||||
{/await}
|
||||
{:else}
|
||||
<div class="content">
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
import LocationRequest from '$lib/components/Map/LocationRequest.svelte'
|
||||
import Marker from '$lib/components/Map/Marker.svelte'
|
||||
import { navigate } from '$lib/router'
|
||||
import { getExpiriencesAsStore } from '$lib/utils/database/game'
|
||||
import { getExpiriencesAsStore } from '$lib/utils/database/experience'
|
||||
import { onMount } from 'svelte'
|
||||
|
||||
let user: { lat: number; lng: number } = { lat: 0, lng: 0 }
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
<script lang="ts">
|
||||
import Loading from './../../lib/components/Common/Loading.svelte';
|
||||
// Import necessary modules and components
|
||||
import { user } from '$lib/appwrite';
|
||||
import collections from '$lib/collections';
|
||||
import Loading from '$lib/components/Common/Loading.svelte';
|
||||
import Category2InRow from '$lib/components/categories/Category2InRow.svelte';
|
||||
import Category3InRow from '$lib/components/categories/Category3InRow.svelte';
|
||||
import { getPreferences, addSelectedPreferences } from '$lib/utils/database/preferences';
|
||||
import { navigate } from '$lib/router'
|
||||
import { onMount } from 'svelte';
|
||||
|
||||
|
||||
// Define a variable to store the preferences
|
||||
let preferences = [];
|
||||
// Define a variable to store the selected preferences
|
||||
let selectedPreferences = [];
|
||||
|
||||
onMount(async () => {
|
||||
preferences = await getPreferences();
|
||||
});
|
||||
|
||||
function updateSelectedPreferences(preference) {
|
||||
if (selectedPreferences.includes(preference)) {
|
||||
selectedPreferences = selectedPreferences.filter((item) => item !== preference);
|
||||
} else {
|
||||
selectedPreferences = [...selectedPreferences, preference];
|
||||
}
|
||||
}
|
||||
// Define a function to handle the form submission
|
||||
async function submitPreferences() {
|
||||
await addSelectedPreferences(user, selectedPreferences);
|
||||
selectedPreferences = [];
|
||||
}
|
||||
</script>
|
||||
|
||||
{#if preferences.length > 0}
|
||||
<div class="preferences-page">
|
||||
<div class="progress-bar"></div>
|
||||
<h2>What are your interests?</h2>
|
||||
<Category3InRow
|
||||
preferences={preferences.slice(0, 3)}
|
||||
on:preferenceSelect={updateSelectedPreferences}
|
||||
/>
|
||||
<h2>Who do you like to travel with?</h2>
|
||||
<Category2InRow
|
||||
preferences={preferences.slice(3, 5)}
|
||||
on:preferenceSelect={updateSelectedPreferences}
|
||||
/>
|
||||
<h2>What brought you to our app?</h2>
|
||||
<Category3InRow
|
||||
preferences={preferences.slice(5)}
|
||||
on:preferenceSelect={updateSelectedPreferences}
|
||||
/>
|
||||
<button on:click={submitPreferences}>Submit Preferences</button>
|
||||
</div>
|
||||
{:else}
|
||||
<Loading>
|
||||
{/if}
|
|
@ -1,5 +1,5 @@
|
|||
<script lang="ts">
|
||||
import Interests from "$lib/components/Interests/Interests.svelte"
|
||||
import Interests from "$lib/components/Categories/interests.svelte"
|
||||
|
||||
let current_state = 1
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue