diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1a3b8eb..6020c1f 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,8 +1,8 @@ on: push: - branches: [ "deploy/prod" ] + branches: ['deploy/prod'] pull_request: - branches: [ "deploy/prod" ] + branches: ['deploy/prod'] name: 🚀 Deploy website on push jobs: @@ -10,18 +10,18 @@ jobs: name: 🎉 Deploy runs-on: ubuntu-latest steps: - - name: 🚚 Get latest code - uses: actions/checkout@v3 - - - name: 🔨 Build Project - run: | - npm ci - npm run build - - - name: 📂 Sync files - uses: SamKirkland/FTP-Deploy-Action@4.3.2 - with: - server: 305244.w44.wedos.net - username: w305244_BOT007 - password: ${{ secrets.FTP_PASSWORD }} - local-dir: ./dist/ + - name: 🚚 Get latest code + uses: actions/checkout@v3 + + - name: 🔨 Build Project + run: | + npm ci + npm run build + + - name: 📂 Sync files + uses: SamKirkland/FTP-Deploy-Action@4.3.2 + with: + server: 305244.w44.wedos.net + username: w305244_BOT007 + password: ${{ secrets.FTP_PASSWORD }} + local-dir: ./dist/ diff --git a/package.json b/package.json index 4778b77..5d0396e 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "version": "0.0.0", "type": "module", "scripts": { - "dev": "vite", + "dev": "vite --host 0.0.0.0", "build": "vite build", "preview": "vite preview", "appwrite": "docker compose -f ./appwrite/docker-compose.yml up" diff --git a/src/__routes.svelte b/src/__routes.svelte index c18cc59..67c284e 100644 --- a/src/__routes.svelte +++ b/src/__routes.svelte @@ -40,8 +40,8 @@ component: () => import('$routes/profile/profile.svelte'), }, { - path: '/profile/payment_history', - component: () => import('$routes/profile/payment_history.svelte'), + path: '/profile/:function', + component: () => import('$routes/profile/profile-functions.svelte'), }, { path: '/legal/terms_of_service', diff --git a/src/lib/components/Inputs/Hidden_Input_type2.svelte b/src/lib/components/Inputs/Hidden_Input_type2.svelte new file mode 100644 index 0000000..0a9da7f --- /dev/null +++ b/src/lib/components/Inputs/Hidden_Input_type2.svelte @@ -0,0 +1,56 @@ + + +
+ + +
+ + diff --git a/src/lib/svg/ArrowBack.svelte b/src/lib/svg/ArrowBack.svelte new file mode 100644 index 0000000..4c7d971 --- /dev/null +++ b/src/lib/svg/ArrowBack.svelte @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/lib/svg/CookieMonster.svelte b/src/lib/svg/CookieMonster.svelte new file mode 100644 index 0000000..81291e3 --- /dev/null +++ b/src/lib/svg/CookieMonster.svelte @@ -0,0 +1,11 @@ + + + + + + + + + + + \ No newline at end of file diff --git a/src/lib/svg/Logout.svelte b/src/lib/svg/Logout.svelte index 4216c04..fcf4d13 100644 --- a/src/lib/svg/Logout.svelte +++ b/src/lib/svg/Logout.svelte @@ -1,26 +1,3 @@ - - - - - - - - - - - - - - - - - - - - - + + + diff --git a/src/lib/svg/Pen.svelte b/src/lib/svg/Pen.svelte new file mode 100644 index 0000000..41ce96b --- /dev/null +++ b/src/lib/svg/Pen.svelte @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/lib/svg/Sun.svelte b/src/lib/svg/Sun.svelte new file mode 100644 index 0000000..026fb6e --- /dev/null +++ b/src/lib/svg/Sun.svelte @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/lib/utils/game.ts b/src/lib/utils/database/game.ts similarity index 55% rename from src/lib/utils/game.ts rename to src/lib/utils/database/game.ts index 7800b15..a997e30 100644 --- a/src/lib/utils/game.ts +++ b/src/lib/utils/database/game.ts @@ -1,20 +1,31 @@ import { databases } from '$lib/appwrite' import { Query } from 'appwrite' import database from 'svelte-appwrite-client/src/lib/database' +import { getLocationDataFromLatAndLong } from '../locations' export const load = async (pathName: string) => { const checkPoints = [] const game = (await databases.listDocuments('63cef30d6da945dd4250', '63cef4bd210fdf2e5888', [Query.equal('ExpURL', pathName)])).documents[0] - + const checkPointsIds = game.ExpCPsID for (const checkPointId of checkPointsIds) { checkPoints.push(await databases.getDocument('63cef30d6da945dd4250', '63cef84d908acf805758', checkPointId)) } + const rating = await getRating(game.$id) + console.log(rating) + + game['rating'] = rating game['checkPoints'] = checkPoints return game } +const getRating = async (expId: string) => { + const { documents } = await databases.listDocuments('63cef30d6da945dd4250', '63ee6353ebb174cf815d', [Query.equal('ExpID', expId)]) + const sum = documents.reduce((accumulator, rating) => accumulator + rating.ExpUserRating, 0) + return sum / documents.length +} + export const answer = async (checkPointId: string, answer: any) => { const checkPoint = await databases.getDocument('63cef30d6da945dd4250', '63cef84d908acf805758', checkPointId) console.log({ checkPoint }) @@ -24,3 +35,17 @@ 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')).documents + let items: Array<{ location: string; name: string; link: string }> = [] + for (const expirience of expiriences) { + items.push({ + location: (await getLocationDataFromLatAndLong(expirience.ExpLocation[0], expirience.ExpLocation[1])).city, + name: expirience.ExpName, + link: `${expirience.ExpURL}`, + }) + } + + return items +} diff --git a/src/lib/utils/locations.ts b/src/lib/utils/locations.ts new file mode 100644 index 0000000..0082a11 --- /dev/null +++ b/src/lib/utils/locations.ts @@ -0,0 +1,8 @@ +export const getLocationDataFromLatAndLong = async (latitude: number, longitude: number) => { + const response = await fetch(`https://nominatim.openstreetmap.org/reverse?lat=${latitude}&lon=${longitude}&format=json`) + const data = await response.json() + return { + city: data.address.town || data.address.city || data.address.village, + state: data.address.country, + } +} diff --git a/src/routes/explore/explore.svelte b/src/routes/explore/explore.svelte index 04a23ad..6654498 100644 --- a/src/routes/explore/explore.svelte +++ b/src/routes/explore/explore.svelte @@ -2,12 +2,11 @@ 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 Loading from '$lib/components/Common/Loading.svelte' let Search: string - function search(value: string) { - return [value, value, value] - } @@ -15,9 +14,16 @@
- {#each search(Search) as result} - - {/each} + {#await getExpiriences()} +
+ +
+ {:then expiriences} + {#each expiriences as result} + + {/each} + {/await} +
diff --git a/src/routes/game/Components/Layout.svelte b/src/routes/game/Components/Layout.svelte index 5e132d6..9b529af 100644 --- a/src/routes/game/Components/Layout.svelte +++ b/src/routes/game/Components/Layout.svelte @@ -1,9 +1,10 @@ - @@ -23,7 +24,7 @@
- {#if control !== null} + {#if control !== null || control === 'not-control'} {:else} @@ -31,9 +32,11 @@
- {#if control} + {#if control === 'not-control' || control === null} + + {:else if control} správně - {:else if control !== null} + {:else} špatně {/if}
diff --git a/src/routes/game/Forms/Info.svelte b/src/routes/game/Forms/Info.svelte new file mode 100644 index 0000000..6a407b2 --- /dev/null +++ b/src/routes/game/Forms/Info.svelte @@ -0,0 +1,27 @@ + + + { + nextQuestion() + myAnswer = '' + }} +> + {name} + {@html checkPoint.CPText} + + + diff --git a/src/routes/game/Forms/MultiChoiceForm.svelte b/src/routes/game/Forms/MultiChoiceForm.svelte index 09d20c6..5e89dfd 100644 --- a/src/routes/game/Forms/MultiChoiceForm.svelte +++ b/src/routes/game/Forms/MultiChoiceForm.svelte @@ -2,7 +2,7 @@ import Layout from '../Components/Layout.svelte' import CheckBox from '../../../lib/components/Inputs/Checkbox.svelte' import { checkPoint } from '$lib/TStypes/expiriences' - import { answer } from '$lib/utils/game' + import { answer } from '$lib/utils/database/game' export let data: { name: string; checkPoint: checkPoint } const { checkPoint, name } = data diff --git a/src/routes/game/Forms/NumberForm.svelte b/src/routes/game/Forms/NumberForm.svelte index fd890ea..b86146e 100644 --- a/src/routes/game/Forms/NumberForm.svelte +++ b/src/routes/game/Forms/NumberForm.svelte @@ -2,7 +2,7 @@ import Layout from '../Components/Layout.svelte' import Input from '../../../lib/components/Inputs/Input.svelte' import { checkPoint } from '$lib/TStypes/expiriences' - import { answer } from '$lib/utils/game' + import { answer } from '$lib/utils/database/game' export let data: { name: string; checkPoint: checkPoint } const { checkPoint, name } = data diff --git a/src/routes/game/Forms/Renderer.svelte b/src/routes/game/Forms/Renderer.svelte index e6b9a5b..728e32b 100644 --- a/src/routes/game/Forms/Renderer.svelte +++ b/src/routes/game/Forms/Renderer.svelte @@ -10,6 +10,7 @@ import Finish from './Finish.svelte' import { data } from '$lib/stores/game' import Erantmap from '$lib/components/Map/Erantmap.svelte' + import Info from './Info.svelte' const components = { TEXT: TextForm, @@ -18,10 +19,11 @@ CHECKBOX: MultiplyForm, interval: IntervalForm, qrcode: QrCode, + INFO: Info, } let control = null // if true => spravne if false spatne - let view: 'question' | 'map' = 'question' + let view: 'question' | 'map' = 'map' export let gameData: any = {} //data $: console.log(gameData) @@ -54,6 +56,8 @@ let user = { lat: null, lng: null } + $: console.log(page, gameData.checkPoints[clientAnswers.pos].CPType) + /* //set user to localstorage $: if (clientAnswers.pos !== clientAnswers.end && clientAnswers.pos !== 0) { //nastaví diff --git a/src/routes/game/Forms/SingleChoiceForm.svelte b/src/routes/game/Forms/SingleChoiceForm.svelte index 73bc3cf..e364d50 100644 --- a/src/routes/game/Forms/SingleChoiceForm.svelte +++ b/src/routes/game/Forms/SingleChoiceForm.svelte @@ -2,7 +2,7 @@ import Radio from '../../../lib/components/Inputs/Radio.svelte' import Layout from '../Components/Layout.svelte' import { checkPoint } from '$lib/TStypes/expiriences' - import { answer } from '$lib/utils/game' + import { answer } from '$lib/utils/database/game' export let data: { name: string; checkPoint: checkPoint } const { checkPoint, name } = data diff --git a/src/routes/game/Forms/TextForm.svelte b/src/routes/game/Forms/TextForm.svelte index 945a06f..ae6104e 100644 --- a/src/routes/game/Forms/TextForm.svelte +++ b/src/routes/game/Forms/TextForm.svelte @@ -2,7 +2,7 @@ import Layout from '../Components/Layout.svelte' import Input from '../../../lib/components/Inputs/Input.svelte' import { checkPoint } from '$lib/TStypes/expiriences' - import { answer } from '$lib/utils/game' + import { answer } from '$lib/utils/database/game' export let data: { name: string; checkPoint: checkPoint } const { checkPoint, name } = data diff --git a/src/routes/game/game.svelte b/src/routes/game/game.svelte index e665f22..5a562b6 100644 --- a/src/routes/game/game.svelte +++ b/src/routes/game/game.svelte @@ -16,7 +16,8 @@ import collections from '$lib/collections' import { Query } from 'appwrite' import { onMount } from 'svelte' - import { load } from '$lib/utils/game' + import { load } from '$lib/utils/database/game' + import { getLocationDataFromLatAndLong } from '$lib/utils/locations' export let params: { gameurl: string } @@ -28,13 +29,14 @@ $data = await load(params.gameurl) loading = false }) + $: console.log($data) $: assets = $data?.questions ?.filter((q) => q.thumbnail !== null) ?.slice(0, 8) ?.map((q) => q.thumbnail) - let view: 'game-play' | 'game-loading' = 'game-play' + let view: 'game-play' | 'game-loading' = 'game-loading' //is user already in game //const userInGame = JSON.parse(localStorage.getItem(location.pathname)) @@ -54,11 +56,13 @@
- {$data.ExpRating} + {$data.rating} - {'$data.district'} + {#await getLocationDataFromLatAndLong($data.ExpLocation[0], $data.ExpLocation[1]) then { city }} + {city} + {/await}
@@ -79,7 +83,7 @@
- + {#each $data.checkPoints as { CPLocation: [lat, lng] }} {/each} diff --git a/src/routes/homepage/Components/Comparment.svelte b/src/routes/homepage/Components/Comparment.svelte index 4cb417c..c00e3e7 100644 --- a/src/routes/homepage/Components/Comparment.svelte +++ b/src/routes/homepage/Components/Comparment.svelte @@ -1,22 +1,25 @@
- + -
- {#each items as item } - - {/each} -
+
+ {#each items as item} + navigate(`${item.link}`)} price={item.price} location={item.location} name={item.name} image={item.image} /> + {/each} +
\ No newline at end of file + diff --git a/src/routes/homepage/Components/Compartment_Item.svelte b/src/routes/homepage/Components/Compartment_Item.svelte index 6d7d5e1..fcccf7b 100644 --- a/src/routes/homepage/Components/Compartment_Item.svelte +++ b/src/routes/homepage/Components/Compartment_Item.svelte @@ -1,47 +1,61 @@ -
+
+

{name}

+
+ + + + + + + + + -
-

{name}

-
- - - - - - - - - - - {location} -
-
+ {location} +
+
diff --git a/src/routes/homepage/homepage.svelte b/src/routes/homepage/homepage.svelte index 5a5f78b..be58e57 100644 --- a/src/routes/homepage/homepage.svelte +++ b/src/routes/homepage/homepage.svelte @@ -6,41 +6,39 @@ 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 Loading from '$lib/components/Common/Loading.svelte' + let fitstTime = false onMount(() => { - if (localStorage.getItem("ErantFirstTime") == null){ + if (localStorage.getItem('ErantFirstTime') == null) { fitstTime = true setTimeout(() => { fitstTime = false - localStorage.setItem('ErantFirstTime', "false"); + localStorage.setItem('ErantFirstTime', 'false') }, 11000) } }) - let city = ""; - let state = ""; + let city = '' + let state = '' - if ("geolocation" in navigator) { - navigator.geolocation.getCurrentPosition(async position => { - const latitude = position.coords.latitude; - const longitude = position.coords.longitude; - const response = await fetch( - `https://nominatim.openstreetmap.org/reverse?lat=${latitude}&lon=${longitude}&format=json` - ); - const data = await response.json(); - - city = data.address.town || data.address.city || data.address.village; - state = ", "+data.address.country; - }); + if ('geolocation' in navigator) { + navigator.geolocation.getCurrentPosition(async (position) => { + const latitude = position.coords.latitude + const longitude = position.coords.longitude + const response = await fetch(`https://nominatim.openstreetmap.org/reverse?lat=${latitude}&lon=${longitude}&format=json`) + const data = await response.json() + city = data.address.town || data.address.city || data.address.village + state = ', ' + data.address.country + }) } - {#if !fitstTime} - + @@ -48,13 +46,13 @@ - + {#await getExpiriences()} +
+ +
+ {:then expiriences} + + {/await}
{:else}
@@ -64,7 +62,7 @@ \ No newline at end of file diff --git a/src/routes/profile/functions/Profile-Update.svelte b/src/routes/profile/functions/Profile-Update.svelte new file mode 100644 index 0000000..fde0b10 --- /dev/null +++ b/src/routes/profile/functions/Profile-Update.svelte @@ -0,0 +1,92 @@ + + +
+
+
+ +
+ +
+ +
+ + + + + + + + +
+ + \ No newline at end of file diff --git a/src/routes/profile/functions/Setting.svelte b/src/routes/profile/functions/Setting.svelte new file mode 100644 index 0000000..1a70eab --- /dev/null +++ b/src/routes/profile/functions/Setting.svelte @@ -0,0 +1,31 @@ + + + +
+ {#each items as { title, itms }} + {#if title !== ""} +
{title}
+ {/if} + {#each itms as { icon, text, link}} + + + {text} + + + {/each} + {/each} +
+ diff --git a/src/routes/profile/payment_history.svelte b/src/routes/profile/payment_history.svelte deleted file mode 100644 index badfc15..0000000 --- a/src/routes/profile/payment_history.svelte +++ /dev/null @@ -1,78 +0,0 @@ - - - -
- -

Payment History

-
- -
- {#each items as { title, itms }} - {#if title !== ""} -
{title}
- {/if} - {#each itms as { icon, text, link}} - - - {text} - - - {/each} - {/each} -
-
- - diff --git a/src/routes/profile/profile-functions.svelte b/src/routes/profile/profile-functions.svelte new file mode 100644 index 0000000..1ae8297 --- /dev/null +++ b/src/routes/profile/profile-functions.svelte @@ -0,0 +1,63 @@ + + + +
+ +

{data.display_name}

+
+ + + + + +
+ + \ No newline at end of file diff --git a/src/routes/profile/profile.svelte b/src/routes/profile/profile.svelte index 332420b..4bd4617 100644 --- a/src/routes/profile/profile.svelte +++ b/src/routes/profile/profile.svelte @@ -4,11 +4,11 @@ import Line from '$lib/components/Common/Line.svelte' import SettingRow from '$lib/components/Common/SettingRow.svelte' import Profile from '$lib/svg/Profile.svelte' - import Wallet from '$lib/svg/Wallet.svelte' + import Pen from '$lib/svg/Pen.svelte' import Setting2 from '$lib/svg/Setting2.svelte' import { Link } from 'svelte-routing' import NavigationBarLayout from '../../lib/components/Layouts/NavigationBarLayout.svelte' - import Earth from '$lib/svg/Earth.svelte' + import CookieMonster from '$lib/svg/CookieMonster.svelte' import Warning from '$lib/svg/Warning.svelte' import PointSmall from '$lib/svg/PointSmall.svelte' import InputPicture from '$lib/components/Inputs/InputPicture.svelte' @@ -20,20 +20,22 @@ { title: 'Account', itms: [ - { icon: Profile, text: 'Your Profile', link:"/"}, - { icon: Wallet, text: 'Payment History', link:"/profile/payment_history"}, - { icon: Setting2, text: 'Preferences', link:"/"}, + { icon: Profile, text: 'Update Your Profile', link:"/profile/profile_update"}, + { icon: Pen, text: 'Update Your Interests', link:"/profile/interests_update"}, ], }, { title: 'Settings', - itms: [{ icon: Earth, text: 'Language', link:"/"}], + itms: [ + { icon: Setting2, text: 'Setting', link:"/profile/settings"}, + { icon: CookieMonster, text: 'Cookies', link:"/profile/cookies"} + ], }, { title: 'Legal', itms: [ { icon: Help, text: 'Help', link:"/"}, - { icon: Warning, text: 'Terms of Service', link:"/"}, + { icon: Warning, text: 'Terms & Condition', link:"/"}, { icon: Logout, text: 'Log out', link: () => user.deleteSessions() },, ], },