diff --git a/index.html b/index.html
index 89ae76b..57691c6 100644
--- a/index.html
+++ b/index.html
@@ -13,7 +13,7 @@
diff --git a/package-lock.json b/package-lock.json
index d763249..fe6e383 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -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",
diff --git a/package.json b/package.json
index b960c41..cce22a2 100644
--- a/package.json
+++ b/package.json
@@ -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"
diff --git a/postcss.config.cjs b/postcss.config.cjs
index bafe175..5f0853f 100644
--- a/postcss.config.cjs
+++ b/postcss.config.cjs
@@ -2,5 +2,5 @@ const autoprefixer = require('autoprefixer')
const tailwind = require('tailwindcss')
module.exports = {
- plugins: [tailwind(), autoprefixer()],
+ plugins: [tailwind(), autoprefixer()]
}
diff --git a/public/serviceworker.js b/public/serviceworker.js
index 4b2d31b..1565554 100644
--- a/public/serviceworker.js
+++ b/public/serviceworker.js
@@ -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'
diff --git a/src/__routes.svelte b/src/__routes.svelte
index 0f05871..396f755 100644
--- a/src/__routes.svelte
+++ b/src/__routes.svelte
@@ -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'),
+ }
]}
/>
diff --git a/src/lib/collections.ts b/src/lib/collections.ts
index b6272ae..605ac88 100644
--- a/src/lib/collections.ts
+++ b/src/lib/collections.ts
@@ -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,
}
diff --git a/src/lib/components/Categories/category.svelte b/src/lib/components/Categories/category.svelte
new file mode 100644
index 0000000..addf887
--- /dev/null
+++ b/src/lib/components/Categories/category.svelte
@@ -0,0 +1,55 @@
+
+
+
+
+
+
+
+
{name}
+
+
+
+
\ No newline at end of file
diff --git a/src/lib/components/Categories/category2InRow.svelte b/src/lib/components/Categories/category2InRow.svelte
new file mode 100644
index 0000000..e69de29
diff --git a/src/lib/components/Categories/category3InRow.svelte b/src/lib/components/Categories/category3InRow.svelte
new file mode 100644
index 0000000..e69de29
diff --git a/src/lib/components/Interests/Interests.svelte b/src/lib/components/Categories/interests.svelte
similarity index 98%
rename from src/lib/components/Interests/Interests.svelte
rename to src/lib/components/Categories/interests.svelte
index fd7f953..028cefa 100644
--- a/src/lib/components/Interests/Interests.svelte
+++ b/src/lib/components/Categories/interests.svelte
@@ -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
diff --git a/src/lib/router/Router.svelte b/src/lib/router/Router.svelte
index 18a457c..debe27b 100644
--- a/src/lib/router/Router.svelte
+++ b/src/lib/router/Router.svelte
@@ -33,3 +33,4 @@
{/if}
{/each}
+
diff --git a/src/lib/stores/game.js b/src/lib/stores/stores.js
similarity index 100%
rename from src/lib/stores/game.js
rename to src/lib/stores/stores.js
diff --git a/src/lib/utils/IdGenerator.js b/src/lib/utils/IdGenerator.js
index 3619eec..4ef1266 100644
--- a/src/lib/utils/IdGenerator.js
+++ b/src/lib/utils/IdGenerator.js
@@ -1,3 +1,3 @@
export const idGenerator = () => {
- return JSON.stringify(Date.now() * Math.floor(Math.random() * 100000))
+ return JSON.stringify(Date.now() * Math.floor(Math.random() * 100000))
}
diff --git a/src/lib/utils/api.js b/src/lib/utils/api.js
index f8e0019..2271932 100644
--- a/src/lib/utils/api.js
+++ b/src/lib/utils/api.js
@@ -1,55 +1,55 @@
-async function send({ method, path, body, token, headers }) {
- const opts = { method, headers: new Headers(), mode: 'cors' }
- opts.headers.append('Content-Type', 'application/json')
- opts.headers.append('Access-Control-Allow-Origin', '*')
+async function send ({ method, path, body, token, headers }) {
+ const opts = { method, headers: new Headers(), mode: 'cors' }
+ opts.headers.append('Content-Type', 'application/json')
+ opts.headers.append('Access-Control-Allow-Origin', '*')
- if (body) {
- opts.body = JSON.stringify(body)
- }
+ if (body) {
+ opts.body = JSON.stringify(body)
+ }
- if (headers) {
- for (const [k, v] of Object.entries(headers)) {
- opts.headers.append(k, v)
- }
- }
+ if (headers) {
+ for (const [k, v] of Object.entries(headers)) {
+ opts.headers.append(k, v)
+ }
+ }
- if (token) {
- opts.headers['Authorization'] = `Bearer ${token}`
- }
+ if (token) {
+ opts.headers.Authorization = `Bearer ${token}`
+ }
- const res = fetch(path, opts)
- .then(async (r) => {
- if (r.status >= 200 && r.status < 400) {
- return await r.text()
- } else {
- return await r.text()
- }
- })
- .then((str) => {
- try {
- return JSON.parse(str)
- } catch (err) {
- return str
- }
- })
+ const res = fetch(path, opts)
+ .then(async (r) => {
+ if (r.status >= 200 && r.status < 400) {
+ return await r.text()
+ } else {
+ return await r.text()
+ }
+ })
+ .then((str) => {
+ try {
+ return JSON.parse(str)
+ } catch (err) {
+ return str
+ }
+ })
- return res
+ return res
}
-export function get(path, token = null) {
- return send({ method: 'GET', path, body: null, token })
+export function get (path, token = null) {
+ return send({ method: 'GET', path, body: null, token })
}
-export function del(path, token = null) {
- return send({ method: 'DELETE', path, body: null, token })
+export function del (path, token = null) {
+ return send({ method: 'DELETE', path, body: null, token })
}
-export function post(path, body, token = null) {
- return send({ method: 'POST', path, body, token })
+export function post (path, body, token = null) {
+ return send({ method: 'POST', path, body, token })
}
-export function put(path, body, token = null, headers = []) {
- return send({ method: 'PUT', path, body, token, headers })
+export function put (path, body, token = null, headers = []) {
+ return send({ method: 'PUT', path, body, token, headers })
}
export const hostName = 'https://erant.cz/api'
diff --git a/src/lib/utils/database/game.ts b/src/lib/utils/database/experience.ts
similarity index 75%
rename from src/lib/utils/database/game.ts
rename to src/lib/utils/database/experience.ts
index 641795d..665bc86 100644
--- a/src/lib/utils/database/game.ts
+++ b/src/lib/utils/database/experience.ts
@@ -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 = []
// @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(true)
databases.listDocuments('63cef30d6da945dd4250', '63cef4bd210fdf2e5888', [Query.equal('ExpApproved', true)]).then(async ({ documents }) => {
let items: Array = []
- 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) => {}
+
+
+
+
+
diff --git a/src/lib/utils/database/preferences.ts b/src/lib/utils/database/preferences.ts
new file mode 100644
index 0000000..85ec74c
--- /dev/null
+++ b/src/lib/utils/database/preferences.ts
@@ -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;
+};
\ No newline at end of file
diff --git a/src/lib/utils/stores.js b/src/lib/utils/stores.js
index 8765b2e..8e1d5db 100644
--- a/src/lib/utils/stores.js
+++ b/src/lib/utils/stores.js
@@ -2,82 +2,82 @@ import { writable } from 'svelte/store'
import * as api from './api'
class FetchArray extends Array {
- constructor(items, caller = () => null) {
- super()
- this.push(...items)
- this.caller = caller
- }
+ constructor (items, caller = () => null) {
+ super()
+ this.push(...items)
+ this.caller = caller
+ }
- setFetch(caller) {
- this.caller = caller
- return this
- }
+ setFetch (caller) {
+ this.caller = caller
+ return this
+ }
- fetch(fetchBody = {}, then = () => null) {
- return this.caller(fetchBody, then)
- }
+ fetch (fetchBody = {}, then = () => null) {
+ return this.caller(fetchBody, then)
+ }
}
-export function fetchable(path, initBody = {}) {
- const { subscribe, set } = writable(null)
+export function fetchable (path, initBody = {}) {
+ const { subscribe, set } = writable(null)
- return {
- subscribe,
- fetch(fetchBody = {}, then = () => null) {
- const body = Object.assign(initBody, fetchBody)
+ return {
+ subscribe,
+ fetch (fetchBody = {}, then = () => null) {
+ const body = Object.assign(initBody, fetchBody)
- api.post(path, body).then((result) => {
- set(result)
- then(result)
- })
+ api.post(path, body).then((result) => {
+ set(result)
+ then(result)
+ })
- return this
- }
- }
+ return this
+ }
+ }
}
-export function loadable(path, initBody = {}) {
- const fetcher = fetchable(path, initBody)
- const fetchCaller = fetcher.fetch
+export function loadable (path, initBody = {}) {
+ const fetcher = fetchable(path, initBody)
+ const fetchCaller = fetcher.fetch
- const isFetching = writable(false)
+ const isFetching = writable(false)
- fetcher.fetch = (fetchBody = {}, then = () => null) => {
- isFetching.set(true)
+ fetcher.fetch = (fetchBody = {}, then = () => null) => {
+ isFetching.set(true)
- fetchCaller(fetchBody, (result) => {
- isFetching.set(false)
- then(result)
- })
+ fetchCaller(fetchBody, (result) => {
+ isFetching.set(false)
+ then(result)
+ })
- return new FetchArray([fetcher, isFetching], fetcher.fetch)
- }
+ return new FetchArray([fetcher, isFetching], fetcher.fetch)
+ }
- return new FetchArray([fetcher, isFetching], fetcher.fetch)
+ return new FetchArray([fetcher, isFetching], fetcher.fetch)
}
-export function mutable(path, callback = () => null) {
- const isFetching = writable(false)
- const { subscribe, set } = writable(null)
+export function mutable (path, callback = () => null) {
+ const isFetching = writable(false)
+ const { subscribe, set } = writable(null)
- const mutateCall = async (fetchBody = {}) => {
- isFetching.set(true)
+ const mutateCall = async (fetchBody = {}) => {
+ isFetching.set(true)
- const result = await api.post(path, fetchBody)
- set(result)
- isFetching.set(false)
+ const result = await api.post(path, fetchBody)
+ set(result)
+ isFetching.set(false)
- return result
- }
+ return result
+ }
- return [
- {
- subscribe,
- mutate(fetchBody = {}) {
- callback(mutateCall, fetchBody)
- return this
- }
- },
- isFetching
- ]
+ return [
+ {
+ subscribe,
+ mutate (fetchBody = {}) {
+ callback(mutateCall, fetchBody)
+ return this
+ }
+ },
+ isFetching
+ ]
}
diff --git a/src/locales/cz.json b/src/locales/cz.json
new file mode 100644
index 0000000..e69de29
diff --git a/src/locales/en.json b/src/locales/en.json
new file mode 100644
index 0000000..138fa74
--- /dev/null
+++ b/src/locales/en.json
@@ -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"
+ }
+ }
+}
\ No newline at end of file
diff --git a/src/locales/i18n.ts b/src/locales/i18n.ts
new file mode 100644
index 0000000..92e2923
--- /dev/null
+++ b/src/locales/i18n.ts
@@ -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 }
\ No newline at end of file
diff --git a/src/locales/languages.ts b/src/locales/languages.ts
new file mode 100644
index 0000000..7b3db53
--- /dev/null
+++ b/src/locales/languages.ts
@@ -0,0 +1,4 @@
+export default {
+ 'en': () => import('./en.json'),
+ 'cz': () => import('./cz.json')
+}
\ No newline at end of file
diff --git a/src/routes/authorization/register/register.svelte b/src/routes/authorization/register/register.svelte
index ce532ad..b9e5820 100644
--- a/src/routes/authorization/register/register.svelte
+++ b/src/routes/authorization/register/register.svelte
@@ -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 @@
{error}
{/if}