diff --git a/src/components/SelectedProjects.vue b/src/components/SelectedProjects.vue index 6e7d1e2..692a043 100644 --- a/src/components/SelectedProjects.vue +++ b/src/components/SelectedProjects.vue @@ -8,7 +8,7 @@

{{ project.title }}

-
{{ project.version }} - {{ project.release_data }}
+
{{ project.version }}

{{ project.short_description }}

diff --git a/src/components/sections/FavoriteProjects.vue b/src/components/sections/FavoriteProjects.vue index af2f3dc..fedaaec 100644 --- a/src/components/sections/FavoriteProjects.vue +++ b/src/components/sections/FavoriteProjects.vue @@ -27,56 +27,16 @@ export default { } }, mounted () { - this.select_projects = [ - { - title: 'KamilCraft.com', - category: 'private', - image: `${this.publicPath}assets/me.jpg`, - release_data: '29.08.2021', - version: 'v1.0.1', - short_description: `Lorem ipsum dolor sit amet, consectetur adipiscing elit, - sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. - Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. - Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.` - }, - { - title: 'Projekt 4', - category: '', - image: `${this.publicPath}assets/me.jpg`, - release_data: '29.08.2021', - version: 'v1.0.0', - short_description: `Lorem ipsum dolor sit amet, consectetur adipiscing elit, - sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. - Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. - Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.` - }, - { - title: 'Projekt 3', - category: '', - image: `${this.publicPath}assets/me.jpg`, - release_data: '29.08.2021', - version: 'v1.0.0', - short_description: `Lorem ipsum dolor sit amet, consectetur adipiscing elit, - sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. - Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. - Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.` - }, - { - title: 'Projekt 1', - category: '', - image: `${this.publicPath}assets/me.jpg`, - release_data: '29.08.2021', - version: 'v1.0.0', - short_description: `Lorem ipsum dolor sit amet, consectetur adipiscing elit, - sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. - Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. - Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. - Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.` - } - ] + this.loadProjectList() + }, + methods: { + loadProjectList () { + fetch('https://api.kamilcraft.com/projects/category/selected') + .then(response => response.json()) + .then(data => { + this.select_projects = data + }) + } }, components: { GhostButton, diff --git a/src/store/index.js b/src/store/index.js index 5d08842..75c0578 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -25,12 +25,20 @@ const moduleSettings = { }, actions: { fetchProjects (store) { - return fetch('/api/projects.json') + return fetch('https://api.kamilcraft.com/projects') .then(response => response.json()) .then(data => { store.commit('setProjects', data) return store.getters.getProjects }) + }, + fetchCategories (store) { + return fetch('https://api.kamilcraft.com/categories') + .then(response => response.json()) + .then(data => { + store.commit('setCategories', data) + return store.getters.getCategories + }) } }, mutations: { diff --git a/src/views/Project.vue b/src/views/Project.vue index ff9b53c..8051de8 100644 --- a/src/views/Project.vue +++ b/src/views/Project.vue @@ -13,7 +13,7 @@
  • - {{ getCategoryName(project.category) }} + {{ getCategoryName(project.categories)[0] }}
  • @@ -26,7 +26,7 @@
    -

    +

    {{ description }}

    @@ -44,21 +44,33 @@ export default { } }, mounted () { - const project = this.getProjects.find(project => project.id === this.$route.params.id) - this.project = project + if (this.getCategories.length === 0) { + this.$store.dispatch('fetchCategories') + } + this.loadProject(this.$route.params.id) }, computed: { getCategories () { return this.$store.getters.getCategories - }, - getProjects () { - return this.$store.getters.getProjects } }, methods: { - getCategoryName (slug) { - const category = this.getCategories.find(category => category.slug === slug) - return category.name + getCategoryName (categories) { + const categoriesText = [] + categories.forEach(categoryElement => { + const cat = this.getCategories.find(category => category.slug === categoryElement) + if (cat) { + categoriesText.push(cat.name) + } + }) + return categoriesText + }, + loadProject (id) { + fetch('https://api.kamilcraft.com/projects/' + id) + .then(response => response.json()) + .then(data => { + this.project = data + }) } } } diff --git a/src/views/Projects.vue b/src/views/Projects.vue index 9735916..8600e97 100644 --- a/src/views/Projects.vue +++ b/src/views/Projects.vue @@ -3,7 +3,7 @@
    • @@ -104,31 +104,19 @@ export default { data () { return { categories: { - active: 'wszystkie' + active: 'all' }, publicPath: process.env.BASE_URL, projects: [] } }, + computed: { + getCategories () { + return this.$store.getters.getCategories + } + }, async mounted () { - this.$store.commit('setCategories', [ - { - name: 'Wszystkie', - slug: 'wszystkie' - }, - { - name: 'Wordpress', - slug: 'wordpress' - }, - { - name: 'Prywatne', - slug: 'prywatne' - }, - { - name: 'Zlecenia', - slug: 'zlecenia' - } - ]) + await this.$store.dispatch('fetchCategories') await this.$store.dispatch('fetchProjects').then(projects => { projects.sort((firstProduct, secondProduct) => { return secondProduct.id - firstProduct.id @@ -146,8 +134,8 @@ export default { loadListWhereCategory (category) { this.projects = [] setTimeout(() => { - if (category !== 'wszystkie') { - const projects = this.$store.getters.getProjects.filter(project => project.category === category) + if (category !== 'all') { + const projects = this.$store.getters.getProjects.filter(project => project.categories.includes(category)) this.projects = projects } else { this.projects = this.$store.getters.getProjects