diff --git a/index.html b/index.html index 4217eae8..df075f3a 100644 --- a/index.html +++ b/index.html @@ -9,6 +9,7 @@ Utopia Game + diff --git a/package-lock.json b/package-lock.json index e6c21b7e..b6d69bf4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -8,13 +8,13 @@ "name": "utopia-game", "version": "0.0.0", "dependencies": { - "@directus/sdk": "^11.0.3", + "@directus/sdk": "^12.0.1", "@heroicons/react": "^2.0.17", "@types/geojson": "^7946.0.10", "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^6.11.2", - "utopia-ui": "^3.0.0-alpha.27" + "utopia-ui": "^3.0.0-alpha.39" }, "devDependencies": { "@types/react": "^18.0.28", @@ -121,12 +121,12 @@ } }, "node_modules/@babel/generator": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.21.5.tgz", - "integrity": "sha512-SrKK/sRv8GesIW1bDagf9cCG38IOMYZusoe1dfg0D8aiUe3Amvoj1QtjTPAWcfrZFvIwlleLb0gxzQidL9w14w==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.23.0.tgz", + "integrity": "sha512-lN85QRR+5IbYrMWM6Y4pE/noaQtg4pNiqeNGX60eqOfo6gtEj6uw/JagelB8vVztSd7R6M5n1+PQkDbHbBRU4g==", "dev": true, "dependencies": { - "@babel/types": "^7.21.5", + "@babel/types": "^7.23.0", "@jridgewell/gen-mapping": "^0.3.2", "@jridgewell/trace-mapping": "^0.3.17", "jsesc": "^2.5.1" @@ -259,22 +259,22 @@ } }, "node_modules/@babel/helper-environment-visitor": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.5.tgz", - "integrity": "sha512-XGmhECfVA/5sAt+H+xpSg0mfrHq6FzNr9Oxh7PSEBBRUb/mL7Kz3NICXb194rCqAEdxkhPT1a88teizAFyvk8Q==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-environment-visitor/-/helper-environment-visitor-7.22.20.tgz", + "integrity": "sha512-zfedSIzFhat/gFhWfHtgWvlec0nqB9YEIVrpuwjruLlXfUSnA8cJB0miHKwqDnQ7d32aKo2xt88/xZptwxbfhA==", "dev": true, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/helper-function-name": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.22.5.tgz", - "integrity": "sha512-wtHSq6jMRE3uF2otvfuD3DIvVhOsSNshQl0Qrd7qC9oQJzHvOL4qQXlQn2916+CXGywIjpGuIkoyZRRxHPiNQQ==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.23.0.tgz", + "integrity": "sha512-OErEqsrxjZTJciZ4Oo+eoZqeW9UIiOcuYKRJA4ZAgV9myA+pOXhhmpfNCKjEH/auVfEYVFJ6y1Tc4r0eIApqiw==", "dev": true, "dependencies": { - "@babel/template": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/template": "^7.22.15", + "@babel/types": "^7.23.0" }, "engines": { "node": ">=6.9.0" @@ -436,9 +436,9 @@ } }, "node_modules/@babel/helper-validator-identifier": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.5.tgz", - "integrity": "sha512-aJXu+6lErq8ltp+JhkJUfk1MTGyuA4v7f3pA+BJ5HLfNC6nAQ0Cpi9uOquUj8Hehg0aUiHzWQbOVJGao6ztBAQ==", + "version": "7.22.20", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.22.20.tgz", + "integrity": "sha512-Y4OZ+ytlatR8AI+8KZfKuL5urKp7qey08ha31L8b3BwewJAoJamTzyvxPR/5D+KkdJCGPq/+8TukHBlY10FX9A==", "dev": true, "engines": { "node": ">=6.9.0" @@ -496,9 +496,9 @@ } }, "node_modules/@babel/parser": { - "version": "7.22.14", - "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.22.14.tgz", - "integrity": "sha512-1KucTHgOvaw/LzCVrEOAyXkr9rQlp0A1HiHRYnSUE9dmb8PvPW7o5sscg+5169r54n3vGlbx6GevTE/Iw/P3AQ==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.0.tgz", + "integrity": "sha512-vvPKKdMemU85V9WE/l5wZEmImpCtLqbnTvqDS2U1fJ96KrxoW7KrXhNsNCblQlg8Ck4b85yxdTyelsMUgFUXiw==", "dev": true, "bin": { "parser": "bin/babel-parser.js" @@ -1724,33 +1724,33 @@ } }, "node_modules/@babel/template": { - "version": "7.22.5", - "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.5.tgz", - "integrity": "sha512-X7yV7eiwAxdj9k94NEylvbVHLiVG1nvzCV2EAowhxLTwODV1jl9UzZ48leOC0sH7OnuHrIkllaBgneUykIcZaw==", + "version": "7.22.15", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.22.15.tgz", + "integrity": "sha512-QPErUVm4uyJa60rkI73qneDacvdvzxshT3kksGqlGWYdOTIUOwJ7RDUL8sGqslY1uXWSL6xMFKEXDS3ox2uF0w==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.22.5", - "@babel/parser": "^7.22.5", - "@babel/types": "^7.22.5" + "@babel/code-frame": "^7.22.13", + "@babel/parser": "^7.22.15", + "@babel/types": "^7.22.15" }, "engines": { "node": ">=6.9.0" } }, "node_modules/@babel/traverse": { - "version": "7.21.5", - "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.21.5.tgz", - "integrity": "sha512-AhQoI3YjWi6u/y/ntv7k48mcrCXmus0t79J9qPNlk/lAsFlCiJ047RmbfMOawySTHtywXhbXgpx/8nXMYd+oFw==", + "version": "7.23.2", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.23.2.tgz", + "integrity": "sha512-azpe59SQ48qG6nu2CzcMLbxUudtN+dOM9kDbUqGq3HXUJRlo7i8fvPoxQUzYgLZ4cMVmuZgm8vvBpNeRhd6XSw==", "dev": true, "dependencies": { - "@babel/code-frame": "^7.21.4", - "@babel/generator": "^7.21.5", - "@babel/helper-environment-visitor": "^7.21.5", - "@babel/helper-function-name": "^7.21.0", - "@babel/helper-hoist-variables": "^7.18.6", - "@babel/helper-split-export-declaration": "^7.18.6", - "@babel/parser": "^7.21.5", - "@babel/types": "^7.21.5", + "@babel/code-frame": "^7.22.13", + "@babel/generator": "^7.23.0", + "@babel/helper-environment-visitor": "^7.22.20", + "@babel/helper-function-name": "^7.23.0", + "@babel/helper-hoist-variables": "^7.22.5", + "@babel/helper-split-export-declaration": "^7.22.6", + "@babel/parser": "^7.23.0", + "@babel/types": "^7.23.0", "debug": "^4.1.0", "globals": "^11.1.0" }, @@ -1759,13 +1759,13 @@ } }, "node_modules/@babel/types": { - "version": "7.22.11", - "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.22.11.tgz", - "integrity": "sha512-siazHiGuZRz9aB9NpHy9GOs9xiQPKnMzgdr493iI1M67vRXpnEq8ZOOKzezC5q7zwuQ6sDhdSp4SD9ixKSqKZg==", + "version": "7.23.0", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.23.0.tgz", + "integrity": "sha512-0oIyUfKoI3mSqMvsxBdclDwxXKXAUA8v/apZbc+iSyARYou1o8ZGDxbUYyLFoW2arqS2jDGqJuZvv1d/io1axg==", "dev": true, "dependencies": { "@babel/helper-string-parser": "^7.22.5", - "@babel/helper-validator-identifier": "^7.22.5", + "@babel/helper-validator-identifier": "^7.22.20", "to-fast-properties": "^2.0.0" }, "engines": { @@ -1773,9 +1773,9 @@ } }, "node_modules/@directus/sdk": { - "version": "11.0.3", - "resolved": "https://registry.npmjs.org/@directus/sdk/-/sdk-11.0.3.tgz", - "integrity": "sha512-fHvHFcDhl8AY5quRP4cgLMHTU6F4c4ynmMpXRsi8dnSd38mIvciFyYmOVOh34Wp2N+a1YNYpXPU+NsHkfIheHw==", + "version": "12.0.1", + "resolved": "https://registry.npmjs.org/@directus/sdk/-/sdk-12.0.1.tgz", + "integrity": "sha512-AOTOfoJpnaWxQnSRwZeyNZPju7AJgoifZ3jKNqKmZHdJHdKLrx9BTL5KXIL5vBUEpRsHGxecarsk2OH9L3pnlw==", "engines": { "node": ">=18.0.0" }, @@ -2400,9 +2400,9 @@ "dev": true }, "node_modules/@types/offscreencanvas": { - "version": "2019.7.1", - "resolved": "https://registry.npmjs.org/@types/offscreencanvas/-/offscreencanvas-2019.7.1.tgz", - "integrity": "sha512-+HSrJgjBW77ALieQdMJvXhRZUIRN1597L+BKvsyeiIlHHERnqjcuOLyodK3auJ3Y3zRezNKtKAhuQWYJfEgFHQ==" + "version": "2019.7.3", + "resolved": "https://registry.npmjs.org/@types/offscreencanvas/-/offscreencanvas-2019.7.3.tgz", + "integrity": "sha512-ieXiYmgSRXUDeOntE1InxjWyvEelZGP63M+cGuquuRLuIKKT1osnkXjxev9B7d1nXSug5vpunx+gNlbVxMlC9A==" }, "node_modules/@types/prop-types": { "version": "15.7.5", @@ -5470,6 +5470,15 @@ "node": ">=0.10.0" } }, + "node_modules/react-colorful": { + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/react-colorful/-/react-colorful-5.6.1.tgz", + "integrity": "sha512-1exovf0uGTGyq5mXQT0zgQ80uvj2PCwvF8zY1RN9/vbJVSjSo3fsB/4L3ObbF7u70NduSiK4xu4Y6q1MHoUGEw==", + "peerDependencies": { + "react": ">=16.8.0", + "react-dom": ">=16.8.0" + } + }, "node_modules/react-dom": { "version": "18.2.0", "resolved": "https://registry.npmjs.org/react-dom/-/react-dom-18.2.0.tgz", @@ -5747,9 +5756,9 @@ } }, "node_modules/rollup": { - "version": "3.26.3", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.26.3.tgz", - "integrity": "sha512-7Tin0C8l86TkpcMtXvQu6saWH93nhG3dGQ1/+l5V2TDMceTxO7kDiK6GzbfLWNNxqJXm591PcEZUozZm51ogwQ==", + "version": "3.29.4", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-3.29.4.tgz", + "integrity": "sha512-oWzmBZwvYrU0iJHtDmhsm662rC15FRXmcjCk1xD771dFDx5jJ02ufAQQTn0etB2emNk4J9EZg/yWKpsn9BWGRw==", "dev": true, "bin": { "rollup": "dist/bin/rollup" @@ -6336,9 +6345,9 @@ } }, "node_modules/tw-elements": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/tw-elements/-/tw-elements-1.0.0.tgz", - "integrity": "sha512-pD2bA1bTGzvigU79dz4pGvO207CCOpzhwlxzb7hswx40SMMkJISOkoDxU2ot3OQ7LTZM5GwuLDkZ+dquK0wdYQ==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/tw-elements/-/tw-elements-1.1.0.tgz", + "integrity": "sha512-IUr9YW2l99oTVZxuVjQg6rpuCpo6VZqbaKGYmZUNVVsoSVU/ljPpkJAY2Pn/morlXwKPhP9MTPNQMlWosqHL4w==", "dependencies": { "@popperjs/core": "^2.6.0", "chart.js": "^3.7.1", @@ -6698,14 +6707,15 @@ "integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==" }, "node_modules/utopia-ui": { - "version": "3.0.0-alpha.27", - "resolved": "https://registry.npmjs.org/utopia-ui/-/utopia-ui-3.0.0-alpha.27.tgz", - "integrity": "sha512-RpCPXgGt55MTvwiqcnqU/r0KTcvnT74s86ziIxOHWrn/2BgXmgS9ikdjj2q1KAa+/9cFubWkibWhDSQoZL60zg==", + "version": "3.0.0-alpha.39", + "resolved": "https://registry.npmjs.org/utopia-ui/-/utopia-ui-3.0.0-alpha.39.tgz", + "integrity": "sha512-O/uO/qGPjuFOL5VCzeeDyo09SXezAGZMtEP9XXHNSOwNxJcY0z7bjN0ECuhyjHgIKsEBo8lJ6y6VKWKEvpsu/Q==", "dependencies": { "@heroicons/react": "^2.0.17", "@types/offscreencanvas": "^2019.7.1", "leaflet": "^1.9.4", "prop-types": "^15.8.1", + "react-colorful": "^5.6.1", "react-image-crop": "^10.1.8", "react-leaflet": "^4.2.1", "react-leaflet-cluster": "^2.1.0", @@ -6721,14 +6731,14 @@ } }, "node_modules/vite": { - "version": "4.4.4", - "resolved": "https://registry.npmjs.org/vite/-/vite-4.4.4.tgz", - "integrity": "sha512-4mvsTxjkveWrKDJI70QmelfVqTm+ihFAb6+xf4sjEU2TmUCTlVX87tmg/QooPEMQb/lM9qGHT99ebqPziEd3wg==", + "version": "4.5.1", + "resolved": "https://registry.npmjs.org/vite/-/vite-4.5.1.tgz", + "integrity": "sha512-AXXFaAJ8yebyqzoNB9fu2pHoo/nWX+xZlaRwoeYUxEqBO+Zj4msE5G+BhGBll9lYEKv9Hfks52PAF2X7qDYXQA==", "dev": true, "dependencies": { "esbuild": "^0.18.10", - "postcss": "^8.4.25", - "rollup": "^3.25.2" + "postcss": "^8.4.27", + "rollup": "^3.27.1" }, "bin": { "vite": "bin/vite.js" diff --git a/package.json b/package.json index 55705414..1882c371 100644 --- a/package.json +++ b/package.json @@ -10,13 +10,13 @@ "preview": "vite preview" }, "dependencies": { - "@directus/sdk": "^11.0.3", + "@directus/sdk": "^12.0.1", "@heroicons/react": "^2.0.17", "@types/geojson": "^7946.0.10", "react": "^18.2.0", "react-dom": "^18.2.0", "react-router-dom": "^6.11.2", - "utopia-ui": "^3.0.0-alpha.27" + "utopia-ui": "^3.0.0-alpha.39" }, "devDependencies": { "@types/react": "^18.0.28", diff --git a/src/App.tsx b/src/App.tsx index 8b233f2e..65fc59dd 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -8,6 +8,7 @@ import { userApi } from './api/userApi' import Projects from './pages/Projects' import { ProjectView } from './pages/ProjectView' import { assetsApi } from './api/assetsApi' +import { ModalContent } from './ModalContent' @@ -19,7 +20,9 @@ function App() { - + + + diff --git a/src/ModalContent.tsx b/src/ModalContent.tsx new file mode 100644 index 00000000..f07f544b --- /dev/null +++ b/src/ModalContent.tsx @@ -0,0 +1,125 @@ +import { useEffect, useState } from 'react' + +type ChapterProps = { + clickAction?: () => void +} + + +export function Welcome1({ clickAction }: ChapterProps) { + return ( + <> +

Welcome, glad you are here!

+ +

+ In the 21st century, humanity is at a special point in its history. +

+

+ On the one hand, the people of Planet Earth are facing a multitude of fundamental crises. +

+

+ On the other hand, we have all the knowledge and technology to heal the planet and live in harmony with Mother Earth.

+
+ + +
+ + ) +} + +export function Welcome2({ clickAction }: ChapterProps) { + return ( + <> +

Hypnosis and Disillusion

+ +

+ Most people are still stuck in old ways of thinking and living.

+ + +

+ Hypnotised, they sit in front of screens in concrete blocks, flooded and disillusioned by irrelevant information. +

+ +

+ From an early age, they are trained to do alienated work and consume unhealthy and meaningless products. +

+
+ +
+ + ) +} + +export function Welcome3({ clickAction }: ChapterProps) { + return ( + <> +

But Consciousness is rising

+

+ More and more people are waking up to what's really happening.

+

+ They are in the process of understanding the potential that is within themselves and within the whole mankind. +

+ + +

+ Starting to reconnect with our Mother Earth and beginning to question things that long times have been taken for granted. +

+
+ +
+ + ) +} + +export function Welcome4({ clickAction }: ChapterProps) { + return ( + <> +

Gemeinsam erschaffen wir Strukturen

+
    +
  • 🥕 Essen & Trinken
  • +
  • 🏡 Wohn- & Lebensraum
  • +
  • 💬 Kommunikation
  • +
  • 💡 Energie
  • +
  • 🚐 Mobilität
  • +
+
+ +
+ + ) +} + +const close = () => { + window.my_modal_3.close(); +} + +export const ModalContent = () => { + + const [chapter, setChapter] = useState(1); + //const setQuestsOpen = useSetQuestOpen() + + + + const ActiveChapter = () => { + switch (chapter) { + case 1: + return { setChapter(2) }} /> + case 2: + return { setChapter(3) }} /> + case 3: + return { + + close(); + setTimeout(() => { + // setQuestsOpen(true); + setChapter(1); + }, 1000); + + }} /> + default: return <> + }; + }; + + return ( + + ) +} diff --git a/src/api/directus.ts b/src/api/directus.ts index 1d63f44c..56c43be0 100644 --- a/src/api/directus.ts +++ b/src/api/directus.ts @@ -1,8 +1,6 @@ import { createDirectus, rest, authentication, AuthenticationData, AuthenticationStorage } from '@directus/sdk'; import { Point } from 'geojson' - - export type Place = { id: string; name: string; @@ -33,9 +31,27 @@ export type Place = { end: Date; }; + export type Update = { + id: string; + text: string; + position?: Point; + user_created: string; + date_created: string; + } + + type CustomUserFields = { + position: Point; + }; + + export type MyCollections = { - places: Place; - events: Event; + places: Place[]; + events: Event[]; + updates: Update[]; + tags: Tag[]; + projects: Project[]; + directus_users: CustomUserFields[]; + }; @@ -64,7 +80,6 @@ export type Place = { } export const directusClient = createDirectus("https://api.utopia-lab.org/") - .with(authentication()) .with(rest()) .with(authentication('json', { // add this if you want to use authentication, json is important, it's type of your authentication usage, here JWT storage: authLocalStorage(), // here set the storage previously created diff --git a/src/api/itemsApi.ts b/src/api/itemsApi.ts index c6a10770..33864eee 100644 --- a/src/api/itemsApi.ts +++ b/src/api/itemsApi.ts @@ -14,7 +14,7 @@ export class itemsApi implements ItemsApi{ async getItems() { try { - return await directusClient.request(readItems(this.collectionName as never, { limit: 500 })); + return await directusClient.request(readItems(this.collectionName as never, { fields: ['*', { user_created: ['*'] }], limit: 500 })); } catch (error: any) { console.log(error); if (error.errors[0]?.message) diff --git a/src/api/updatesApi.ts b/src/api/updatesApi.ts new file mode 100644 index 00000000..3928d0b1 --- /dev/null +++ b/src/api/updatesApi.ts @@ -0,0 +1,53 @@ +import { readItems,updateItem} from '@directus/sdk'; +import { directusClient } from './directus'; +import { Point } from 'geojson'; + + +export class updatesApi{ + + collectionName: string; + + constructor(collectionName: string) { + this.collectionName = collectionName; + } + + async getItems() { + try { + return await directusClient.request(readItems("updates",{ + fields: ['*', { user_created: ['*'] }], + })); + } catch (error: any) { + console.log(error); + if (error.errors[0]?.message) + throw error.errors[0].message; + else throw error; + } + } + + + + //setting geoposition + async createItem(item: T & { id?: string, position?: Point }) { + try { + return await directusClient.request(updateItem("updates",item.id!,{position: item.position})) + } catch (error: any) { + console.log(error); + if (error.errors[0]?.message) + throw error.errors[0].message; + else throw error; + } + } + + + //setting geoposition to null + async deleteItem(id: string) { + try { + return await directusClient.request(updateItem("updates",id,{position: undefined})) + } catch (error: any) { + console.log(error); + if (error.errors[0].message) + throw error.errors[0].message; + else throw error; + } + } +} \ No newline at end of file diff --git a/src/pages/MapContainer.tsx b/src/pages/MapContainer.tsx index e7628ce0..6077e73c 100644 --- a/src/pages/MapContainer.tsx +++ b/src/pages/MapContainer.tsx @@ -1,5 +1,5 @@ -import { UtopiaMap, Tags, Layer, ItemForm, ItemView, PopupTextAreaInput, PopupStartEndInput, TextView, StartEndView, Permissions } from 'utopia-ui' -import { itemsApi } from '../api/itemsApi' +import { UtopiaMap, Tags, Layer, ItemForm, ItemView, PopupTextAreaInput, PopupTextInput, PopupStartEndInput, TextView, StartEndView, Permissions } from 'utopia-ui' +import { itemsApi } from '../api/itemsApi'; import { permissionsApi } from '../api/permissionsApi'; import { Place, Event, Tag } from '../api/directus'; import { useEffect, useState } from 'react'; @@ -11,6 +11,7 @@ function MapContainer() { const [eventsApi, setEventsApi] = useState>(); const [tagsApi, setTagsApi] = useState>(); const [permissionsApiInstance, setPermissionsApiInstance] = useState(); + const [updatesApiInstance, setUpdatesApiInstance] = useState>(); @@ -21,15 +22,9 @@ function MapContainer() { setEventsApi(new itemsApi('events')); setTagsApi(new itemsApi('tags')); setPermissionsApiInstance(new permissionsApi()); - - - + setUpdatesApiInstance(new itemsApi('updates')); }, []); - - - - return ( @@ -42,9 +37,9 @@ function MapContainer() { markerShape='square' markerDefaultColor='#777' // data={events} - api={eventsApi} - > + api={eventsApi}> + @@ -52,7 +47,6 @@ function MapContainer() { - + api={placesApi} /> + + + + + + + + diff --git a/src/pages/ProfileView.tsx b/src/pages/ProfileView.tsx new file mode 100644 index 00000000..170d2c65 --- /dev/null +++ b/src/pages/ProfileView.tsx @@ -0,0 +1,42 @@ +import { useState, useEffect } from "react"; +import { itemsApi } from "../api/itemsApi"; +import { Project } from '../api/directus' +import { useLocation } from "react-router-dom"; +import { CardPage } from "utopia-ui"; + +export const ProjectView = () => { + + const [projectsApi, setProjectsApi] = useState>(); + const [project, setProject] = useState(); + + let location = useLocation(); + + + const loadProject = async () => { + const project: unknown = await projectsApi?.getItem(location.pathname.split("/")[2]); + setProject(project as Project); + + } + + useEffect(() => { + setProjectsApi(new itemsApi('projects')); + }, []) + + useEffect(() => { + loadProject(); + }, [projectsApi]) + + return ( + + {project && + <> + +

{project?.subname}

+

{project?.text}

+ + + } + +
+ ) +} diff --git a/src/pages/Projects.tsx b/src/pages/Projects.tsx index 650c41df..6763d14b 100644 --- a/src/pages/Projects.tsx +++ b/src/pages/Projects.tsx @@ -1,4 +1,4 @@ -import { TitleCard, useAuth } from 'utopia-ui' +import { TitleCard } from 'utopia-ui' import { useEffect, useState } from 'react' import { Link } from 'react-router-dom' import { itemsApi } from '../api/itemsApi' @@ -16,7 +16,6 @@ export default function Projects() { const loadProjects = async () => { const projects = await projectsApi?.getItems(); setProjects(projects as Project[]); - } useEffect(() => { @@ -28,8 +27,6 @@ export default function Projects() { loadProjects(); }, [projectsApi]) -const {token,isAuthenticated} = useAuth(); - return (
@@ -56,7 +53,7 @@ const {token,isAuthenticated} = useAuth(); return ( - +

{i.subname}

{i.text}