From 3d7935253613c8aa5e24f0aa0faf63edd3bb4e21 Mon Sep 17 00:00:00 2001 From: joycitta-siqueira Date: Sat, 26 Mar 2022 17:42:36 -0300 Subject: [PATCH] Pinea and login page --- package-lock.json | 93 +++++++++++++++++++++++++++-- package.json | 2 + src/main.ts | 6 +- src/pages/ColletionsList.vue | 26 ++++---- src/pages/HomePage.vue | 109 ---------------------------------- src/pages/ItemsList.vue | 18 +++--- src/pages/MuseumsLogin.vue | 72 +++++++++++----------- src/store/storeCollections.ts | 40 +++++++++++++ src/theme/variables.css | 2 +- 9 files changed, 189 insertions(+), 179 deletions(-) delete mode 100644 src/pages/HomePage.vue create mode 100644 src/store/storeCollections.ts diff --git a/package-lock.json b/package-lock.json index f5b7800..23734cb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,7 +15,9 @@ "@capacitor/status-bar": "1.0.8", "@ionic/vue": "^6.0.0", "@ionic/vue-router": "^6.0.0", + "axios": "^0.26.1", "core-js": "^3.6.5", + "pinia": "^2.0.12", "vue": "^3.2.21", "vue-router": "^4.0.12", "vuex": "^4.0.2" @@ -5266,6 +5268,14 @@ "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==", "dev": true }, + "node_modules/axios": { + "version": "0.26.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", + "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", + "dependencies": { + "follow-redirects": "^1.14.8" + } + }, "node_modules/babel-jest": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-27.5.1.tgz", @@ -8908,7 +8918,6 @@ "version": "1.14.9", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==", - "dev": true, "funding": [ { "type": "individual", @@ -14058,6 +14067,56 @@ "node": ">=0.10.0" } }, + "node_modules/pinia": { + "version": "2.0.12", + "resolved": "https://registry.npmjs.org/pinia/-/pinia-2.0.12.tgz", + "integrity": "sha512-tUeuYGFrLU5irmGyRAIxp35q1OTcZ8sKpGT4XkPeVcG35W4R6cfXDbCGexzmVqH5lTQJJTXXbNGutIu9yS5yew==", + "dependencies": { + "@vue/devtools-api": "^6.1.0", + "vue-demi": "*" + }, + "funding": { + "url": "https://github.com/sponsors/posva" + }, + "peerDependencies": { + "@vue/composition-api": "^1.4.0", + "typescript": ">=4.4.4", + "vue": "^2.6.14 || ^3.2.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + }, + "typescript": { + "optional": true + } + } + }, + "node_modules/pinia/node_modules/vue-demi": { + "version": "0.12.4", + "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.12.4.tgz", + "integrity": "sha512-ztPDkFt0TSUdoq1ZI6oD730vgztBkiByhUW7L1cOTebiSBqSYfSQgnhYakYigBkyAybqCTH7h44yZuDJf2xILQ==", + "hasInstallScript": true, + "bin": { + "vue-demi-fix": "bin/vue-demi-fix.js", + "vue-demi-switch": "bin/vue-demi-switch.js" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "@vue/composition-api": "^1.0.0-rc.1", + "vue": "^3.0.0-0 || ^2.6.0" + }, + "peerDependenciesMeta": { + "@vue/composition-api": { + "optional": true + } + } + }, "node_modules/pirates": { "version": "4.0.5", "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.5.tgz", @@ -16943,7 +17002,7 @@ "version": "4.6.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.2.tgz", "integrity": "sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==", - "dev": true, + "devOptional": true, "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" @@ -22244,6 +22303,14 @@ "integrity": "sha512-xh1Rl34h6Fi1DC2WWKfxUTVqRsNnr6LsKz2+hfwDxQJWmrx8+c7ylaqBMcHfl1U1r2dsifOvKX3LQuLNZ+XSvA==", "dev": true }, + "axios": { + "version": "0.26.1", + "resolved": "https://registry.npmjs.org/axios/-/axios-0.26.1.tgz", + "integrity": "sha512-fPwcX4EvnSHuInCMItEhAGnaSEXRBjtzh9fOtsE6E1G6p7vl7edEeZe11QHf18+6+9gR5PbKV/sGKNaD8YaMeA==", + "requires": { + "follow-redirects": "^1.14.8" + } + }, "babel-jest": { "version": "27.5.1", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-27.5.1.tgz", @@ -25003,8 +25070,7 @@ "follow-redirects": { "version": "1.14.9", "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.14.9.tgz", - "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==", - "dev": true + "integrity": "sha512-MQDfihBQYMcyy5dhRDJUHcw7lb2Pv/TuE6xP1vyraLukNDHKbDxDNaOE3NbCAdKQApno+GPRyo1YAp89yCjK4w==" }, "forever-agent": { "version": "0.6.1", @@ -28838,6 +28904,23 @@ "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", "dev": true }, + "pinia": { + "version": "2.0.12", + "resolved": "https://registry.npmjs.org/pinia/-/pinia-2.0.12.tgz", + "integrity": "sha512-tUeuYGFrLU5irmGyRAIxp35q1OTcZ8sKpGT4XkPeVcG35W4R6cfXDbCGexzmVqH5lTQJJTXXbNGutIu9yS5yew==", + "requires": { + "@vue/devtools-api": "^6.1.0", + "vue-demi": "*" + }, + "dependencies": { + "vue-demi": { + "version": "0.12.4", + "resolved": "https://registry.npmjs.org/vue-demi/-/vue-demi-0.12.4.tgz", + "integrity": "sha512-ztPDkFt0TSUdoq1ZI6oD730vgztBkiByhUW7L1cOTebiSBqSYfSQgnhYakYigBkyAybqCTH7h44yZuDJf2xILQ==", + "requires": {} + } + } + }, "pirates": { "version": "4.0.5", "resolved": "https://registry.npmjs.org/pirates/-/pirates-4.0.5.tgz", @@ -30975,7 +31058,7 @@ "version": "4.6.2", "resolved": "https://registry.npmjs.org/typescript/-/typescript-4.6.2.tgz", "integrity": "sha512-HM/hFigTBHZhLXshn9sN37H085+hQGeJHJ/X7LpBWLID/fbc2acUMfU+lGD98X81sKP+pFa9f0DZmCwB9GnbAg==", - "dev": true + "devOptional": true }, "unicode-canonical-property-names-ecmascript": { "version": "2.0.0", diff --git a/package.json b/package.json index 02538d7..82224f8 100644 --- a/package.json +++ b/package.json @@ -17,7 +17,9 @@ "@capacitor/status-bar": "1.0.8", "@ionic/vue": "^6.0.0", "@ionic/vue-router": "^6.0.0", + "axios": "^0.26.1", "core-js": "^3.6.5", + "pinia": "^2.0.12", "vue": "^3.2.21", "vue-router": "^4.0.12", "vuex": "^4.0.2" diff --git a/src/main.ts b/src/main.ts index 32ac17d..7b69597 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,7 +3,7 @@ import { createApp } from 'vue' import App from './App.vue' import BaseLayout from './components/base/BaseLayout.vue'; import router from './router'; -//import store from './store'; +import { createPinia } from 'pinia'; import { IonicVue } from '@ionic/vue'; @@ -30,8 +30,8 @@ import './theme/core.css'; //importei do arquivo criado const app = createApp(App) .use(IonicVue) - .use(router); - // .use(store); + .use(router) + .use(createPinia()); app.component('base-layout', BaseLayout); diff --git a/src/pages/ColletionsList.vue b/src/pages/ColletionsList.vue index 7a0d3ca..4c3a456 100644 --- a/src/pages/ColletionsList.vue +++ b/src/pages/ColletionsList.vue @@ -7,7 +7,7 @@ > - + @@ -19,6 +19,9 @@ diff --git a/src/pages/HomePage.vue b/src/pages/HomePage.vue deleted file mode 100644 index 1f85af5..0000000 --- a/src/pages/HomePage.vue +++ /dev/null @@ -1,109 +0,0 @@ - - - - - \ No newline at end of file diff --git a/src/pages/ItemsList.vue b/src/pages/ItemsList.vue index 34b079d..ff788d6 100644 --- a/src/pages/ItemsList.vue +++ b/src/pages/ItemsList.vue @@ -6,7 +6,7 @@ message="Carregando..." > - + {{ item.title }} Item não possui título @@ -14,6 +14,9 @@ \ No newline at end of file diff --git a/src/pages/MuseumsLogin.vue b/src/pages/MuseumsLogin.vue index 367f175..d0c3f1e 100644 --- a/src/pages/MuseumsLogin.vue +++ b/src/pages/MuseumsLogin.vue @@ -5,57 +5,57 @@ - Link do museu - + name="urlMuseum" + v-model.trim="urlMuseum" + required = "true"> - - - Login - - - - - Senha - - - - - - ACESSAR - + + ACESSAR - - - \ No newline at end of file + + diff --git a/src/store/storeCollections.ts b/src/store/storeCollections.ts new file mode 100644 index 0000000..cdb96a4 --- /dev/null +++ b/src/store/storeCollections.ts @@ -0,0 +1,40 @@ +import { defineStore } from 'pinia'; +import axios from 'axios'; //substitui o fetch + +const useCollectionsStore = defineStore('collections', { + state () { + return { + collections: [], + items: [], + urlMuseum: '', + } + }, + + actions: { + async fetchCollections() { + try { + const response = await axios.get(`https://${this.urlMuseum}/wp-json/tainacan/v2/collections?perpage=4&orderby=modified`); + this.collections = response.data; + } catch (err) { + this.collections = []; + console.error('Erro no carregamento das coleções:', err); + return err; + } + }, + + async fetchItems(collectionId :string) { + try { + this.items = []; + const response = await axios.get(`https://${this.urlMuseum}/wp-json/tainacan/v2/collection/${collectionId}/items?perpage=12&orderby=modified`); + this.items = response.data.items; + } catch (err) { + this.items = []; + console.error('Erro no carregamento das coleções:', err); + return err; + } + } + } +}) +export { + useCollectionsStore +} diff --git a/src/theme/variables.css b/src/theme/variables.css index fbc0e5d..ee1503e 100644 --- a/src/theme/variables.css +++ b/src/theme/variables.css @@ -79,5 +79,5 @@ http://ionicframework.com/docs/theming/ */ --ion-color-step-900: #e6e6e6; --ion-color-step-950: #f2f2f2; - --ion-input-color: var(--ion-color-primary-contrast); /* verificar */ + --ion-input-background: var(--ion-color-primary); /* verificar */ } \ No newline at end of file