updated to utopia-ui@3.0.0-alpha.14

This commit is contained in:
Anton 2023-09-14 13:56:30 +02:00
parent 055b285704
commit c8c4c6875a
9 changed files with 132 additions and 87 deletions

View File

@ -1,16 +1,19 @@
<!DOCTYPE html>
<html lang="en" data-theme="light">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta
name="description"
content="Utopia is a cooperative real life manifestation game">
<title>Utopia Game</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="Utopia is a cooperative real life manifestation game">
<title>Utopia Game</title>
<meta property="og:title" content="Utopia Game" />
<meta property="og:description" content="Utopia is a cooperative real life manifestation game" />
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

40
package-lock.json generated
View File

@ -14,7 +14,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.11.2",
"utopia-ui": "^3.0.0-alpha.8"
"utopia-ui": "^3.0.0-alpha.14"
},
"devDependencies": {
"@types/react": "^18.0.28",
@ -2341,11 +2341,11 @@
}
},
"node_modules/@remix-run/router": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.6.2.tgz",
"integrity": "sha512-LzqpSrMK/3JBAVBI9u3NWtOhWNw5AMQfrUFYB0+bDHTSw17z++WJLsPsxAuK+oSddsxk4d7F/JcdDPM1M5YAhA==",
"version": "1.9.0",
"resolved": "https://registry.npmjs.org/@remix-run/router/-/router-1.9.0.tgz",
"integrity": "sha512-bV63itrKBC0zdT27qYm6SDZHlkXwFL1xMBuhkn+X7l0+IIhNaH5wuuvZKp6eKhCD4KFhujhfhCT1YxXW6esUIA==",
"engines": {
"node": ">=14"
"node": ">=14.0.0"
}
},
"node_modules/@surma/rollup-plugin-off-main-thread": {
@ -5399,29 +5399,29 @@
}
},
"node_modules/react-router": {
"version": "6.11.2",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-6.11.2.tgz",
"integrity": "sha512-74z9xUSaSX07t3LM+pS6Un0T55ibUE/79CzfZpy5wsPDZaea1F8QkrsiyRnA2YQ7LwE/umaydzXZV80iDCPkMg==",
"version": "6.16.0",
"resolved": "https://registry.npmjs.org/react-router/-/react-router-6.16.0.tgz",
"integrity": "sha512-VT4Mmc4jj5YyjpOi5jOf0I+TYzGpvzERy4ckNSvSh2RArv8LLoCxlsZ2D+tc7zgjxcY34oTz2hZaeX5RVprKqA==",
"dependencies": {
"@remix-run/router": "1.6.2"
"@remix-run/router": "1.9.0"
},
"engines": {
"node": ">=14"
"node": ">=14.0.0"
},
"peerDependencies": {
"react": ">=16.8"
}
},
"node_modules/react-router-dom": {
"version": "6.11.2",
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.11.2.tgz",
"integrity": "sha512-JNbKtAeh1VSJQnH6RvBDNhxNwemRj7KxCzc5jb7zvDSKRnPWIFj9pO+eXqjM69gQJ0r46hSz1x4l9y0651DKWw==",
"version": "6.16.0",
"resolved": "https://registry.npmjs.org/react-router-dom/-/react-router-dom-6.16.0.tgz",
"integrity": "sha512-aTfBLv3mk/gaKLxgRDUPbPw+s4Y/O+ma3rEN1u8EgEpLpPe6gNjIsWt9rxushMHHMb7mSwxRGdGlGdvmFsyPIg==",
"dependencies": {
"@remix-run/router": "1.6.2",
"react-router": "6.11.2"
"@remix-run/router": "1.9.0",
"react-router": "6.16.0"
},
"engines": {
"node": ">=14"
"node": ">=14.0.0"
},
"peerDependencies": {
"react": ">=16.8",
@ -6458,16 +6458,16 @@
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
},
"node_modules/utopia-ui": {
"version": "3.0.0-alpha.8",
"resolved": "https://registry.npmjs.org/utopia-ui/-/utopia-ui-3.0.0-alpha.8.tgz",
"integrity": "sha512-a8w7mJxNPoVcG8GPbQNaIj64Sbj69lWtaxh7W62hpmg/PxgFmmU1pwxuRunUqalEUh3WYMvQIJxzNlHISZyIsg==",
"version": "3.0.0-alpha.14",
"resolved": "https://registry.npmjs.org/utopia-ui/-/utopia-ui-3.0.0-alpha.14.tgz",
"integrity": "sha512-kKXucX6Ahe5NBSyTlFN4LP7BBS0dLYFj5zVdxXSLbIY8Au9KSI8O5q4mTprb1WoR3U3lbThf6QkD3PcdeKkrQw==",
"dependencies": {
"@heroicons/react": "^2.0.17",
"leaflet": "^1.9.4",
"prop-types": "^15.8.1",
"react-leaflet": "^4.2.1",
"react-leaflet-cluster": "^2.1.0",
"react-router-dom": "^6.11.2",
"react-router-dom": "^6.16.0",
"react-string-replace": "^1.1.1",
"react-toastify": "^9.1.3",
"tributejs": "^5.1.3",

View File

@ -16,7 +16,7 @@
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.11.2",
"utopia-ui": "^3.0.0-alpha.8"
"utopia-ui": "^3.0.0-alpha.14"
},
"devDependencies": {
"@types/react": "^18.0.28",

View File

@ -1,4 +1,4 @@
import { AppShell, SideBar, Content, AuthProvider, useAuth, Settings, Modal, LoginPage, SignupPage } from 'utopia-ui'
import { AppShell, SideBar, Content, AuthProvider, Settings, Modal, LoginPage, SignupPage } from 'utopia-ui'
import { routes } from './routes/sidebar'
import { Route, Routes } from 'react-router-dom'
import MapContainer from "./pages/MapContainer"
@ -7,23 +7,22 @@ import Concept from './pages/Concept'
import { userApi } from './api/userApi'
function App() {
return (
<div className="App overflow-x-hidden">
<AuthProvider userApi={new userApi}>
<AppShell appName="Utopia Game" useAuth={useAuth}>
<AppShell appName="Utopia Game">
<Modal/>
<SideBar routes={routes} />
<Content>
{/** <Quests /> */}
{/** <Quests /> */ }
<Routes>
<Route path="/" element={<MapContainer />} />
<Route path="/settings" element={<Settings useAuth={useAuth} />} />
<Route path="/*" element={<MapContainer />} />
<Route path="/settings" element={<Settings />} />
<Route path="/concept" element={<Concept/>} />
<Route path="/login" element={<LoginPage/>} />
<Route path="/signup" element={<SignupPage/>} />

View File

@ -1,58 +1,58 @@
import { createItem, deleteItem, readItems, updateItem } from '@directus/sdk';
import { MyCollections, directusClient } from './directus';
import { MyCollections, directusClient } from './directus';
import { ItemsApi } from 'utopia-ui/dist/types';
export class itemsApi<T> implements ItemsApi<T>{
collectionName : string;
collectionName: string;
constructor(collectionName : string) {
constructor(collectionName: string) {
this.collectionName = collectionName;
}
async getItems() {
try {
return await directusClient.request(readItems(this.collectionName as never,{limit: 500 }));
} catch (error: any) {
console.log(error.errors[0].message);
throw new Error(error.errors[0].message); }
}
async createItem(item: T & { id?: string }) {
try {
return await directusClient.request(createItem(this.collectionName as keyof MyCollections,item))
return await directusClient.request(readItems(this.collectionName as never, { limit: 500 }));
} catch (error: any) {
console.log(error);
throw new Error(error.errors[0].message);
if (error.errors[0]?.message)
throw error.errors[0].message;
else throw error;
}
}
async createItem(item: T & { id?: string }) {
try {
return await directusClient.request(createItem(this.collectionName as keyof MyCollections, item))
} catch (error: any) {
console.log(error);
if (error.errors[0]?.message)
throw error.errors[0].message;
else throw error;
}
}
async updateItem(item: T & { id?: string }) {
try {
return await directusClient.request(updateItem(this.collectionName as keyof MyCollections,item.id!, item))
return await directusClient.request(updateItem(this.collectionName as keyof MyCollections, item.id!, item))
} catch (error: any) {
console.log(error);
throw new Error(error.errors[0].message);
if (error.errors[0].message)
throw error.errors[0].message;
else throw error;
}
}
async deleteItem(id: string ) {
async deleteItem(id: string) {
try {
return await directusClient.request(deleteItem(this.collectionName as keyof MyCollections,id))
return await directusClient.request(deleteItem(this.collectionName as keyof MyCollections, id))
} catch (error: any) {
console.log(error);
throw new Error(error.errors[0].message);
if (error.errors[0].message)
throw error.errors[0].message;
else throw error;
}
}
}
}

23
src/api/permissionsApi.ts Normal file
View File

@ -0,0 +1,23 @@
import { readPermissions } from '@directus/sdk';
import { directusClient } from './directus';
import { ItemsApi, Permission } from 'utopia-ui/dist/types';
export class permissionsApi implements ItemsApi<Permission>{
constructor() {
}
async getItems() {
try {
return await directusClient.request(readPermissions());
} catch (error: any) {
console.log(error);
if (error.errors[0]?.message)
throw error.errors[0].message;
else throw error;
}
}
}

View File

@ -8,34 +8,46 @@ export class userApi implements UserApi {
async register(email: string, password: string, userName: string): Promise<any> {
try {
return await directusClient.request(createUser({email: email, password: password, first_name: userName}));
} catch (error) {
} catch (error: any) {
console.log(error);
if (error.errors[0].message)
throw error.errors[0].message;
else throw error;
}
}
async login(email: string, password: string): Promise<any> {
try {
return await directusClient.login(email,password,{mode: 'json'});
} catch (error) {
} catch (error: any) {
console.log(error);
throw new Error("Failed while logging User in");
if (error.errors[0].message)
throw error.errors[0].message;
else throw error;
}
}
async logout(): Promise<any> {
try {
return await directusClient.logout();
} catch (error) {
} catch (error: any) {
console.log(error);
throw new Error("Failed while logging User out");
if (error.errors[0].message)
throw error.errors[0].message;
else throw error;
}
}
async getUser(): Promise<any> {
try {
let user = await directusClient.request(readMe());
return user;
} catch (error) {
} catch (error: any) {
console.log(error);
throw new Error("Failed while loading User");
if (error.errors[0].message)
throw error.errors[0].message;
else throw error;
}
}
@ -43,9 +55,11 @@ export class userApi implements UserApi {
try {
const token = await directusClient.getToken();
return token;
} catch (error) {
} catch (error: any) {
console.log(error);
throw new Error("Failed while loading User Token");
if (error.errors[0].message)
throw error.errors[0].message;
else throw error;
}
}
@ -56,10 +70,11 @@ export class userApi implements UserApi {
return res as any;
} catch (error: any) {
console.log(error);
throw new Error("Failed while updating User Profile");
if (error.errors[0].message)
throw error.errors[0].message;
else throw error;
}
}
}

View File

@ -1,5 +1,6 @@
import { UtopiaMap, Tags, Layer, ItemForm, ItemView, PopupTextAreaInput, PopupStartEndInput, TextView, StartEndView } from 'utopia-ui'
import { UtopiaMap, Tags, Layer, ItemForm, ItemView, PopupTextAreaInput, 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';
@ -9,6 +10,8 @@ function MapContainer() {
const [placesApi, setPlacesApi] = useState<itemsApi<Place>>();
const [eventsApi, setEventsApi] = useState<itemsApi<Event>>();
const [tagsApi, setTagsApi] = useState<itemsApi<Tag>>();
const [permissionsApiInstance, setPermissionsApiInstance] = useState<permissionsApi>();
@ -17,6 +20,7 @@ function MapContainer() {
setPlacesApi(new itemsApi<Place>('places'));
setEventsApi(new itemsApi<Event>('events'));
setTagsApi(new itemsApi<Tag>('tags'));
setPermissionsApiInstance(new permissionsApi());
@ -62,6 +66,7 @@ function MapContainer() {
api={placesApi}
/>
<Tags api={tagsApi}></Tags>
<Permissions api={permissionsApiInstance} adminRole='8ed0b24e-3320-48cd-8444-bc152304e580'></Permissions>
</UtopiaMap>
)
}

View File

@ -10,17 +10,17 @@ export default defineConfig({
react(),
VitePWA({manifest: {
"short_name": "Utopia Game",
"name": "Utopia Game: A Cooperative Real Life Manifestation Game",
"name": "Utopia Game: The Real Life Manifestation Game",
"icons": [
{
"src": "3markers.svg",
"sizes": "192x192",
"type": "image/svg"
"sizes": "any",
"type": "image/svg+xml"
}
],
"start_url": "/index.html",
"start_url": "/",
"display": "fullscreen",
"orientation": "portrait"
"orientation": "natural"
}})
]
})