diff --git a/.env b/.env index ed8c5c1..aef72ab 100644 --- a/.env +++ b/.env @@ -1,2 +1 @@ - VUE_APP_BASE_URL = http://localhost:3000/api/v1 \ No newline at end of file diff --git a/.gitignore b/.gitignore index 403adbc..2f69d4f 100644 --- a/.gitignore +++ b/.gitignore @@ -2,6 +2,7 @@ node_modules /dist +.env # local env files .env.local diff --git a/src/components/CardUser.vue b/src/components/CardUser.vue new file mode 100644 index 0000000..e59828d --- /dev/null +++ b/src/components/CardUser.vue @@ -0,0 +1,49 @@ + + + + + diff --git a/src/components/EditProfile.vue b/src/components/EditProfile.vue new file mode 100644 index 0000000..d962a75 --- /dev/null +++ b/src/components/EditProfile.vue @@ -0,0 +1,323 @@ + + + diff --git a/src/components/Navbar.vue b/src/components/Navbar.vue index 6a0f30a..1259951 100644 --- a/src/components/Navbar.vue +++ b/src/components/Navbar.vue @@ -1,46 +1,89 @@ diff --git a/src/main.js b/src/main.js index 7767cde..45c49ab 100644 --- a/src/main.js +++ b/src/main.js @@ -6,6 +6,49 @@ import { BootstrapVue, IconsPlugin } from 'bootstrap-vue' import 'bootstrap/dist/css/bootstrap.css' import 'bootstrap-vue/dist/bootstrap-vue.css' import VueCarousel from 'vue-carousel' +import { url } from './helper/env' +import axios from 'axios' + +axios.defaults.headers = { + token: localStorage.getItem('token') +} + +// handle token expired +axios.interceptors.response.use((response) => { + if (response.data.message === 'Token Expired! Please log in again') { + return new Promise((resolve, reject) => { + axios.post(`${url}/pekerja/refreshToken`, { + refreshToken: localStorage.getItem('refreshToken') + }) + .then(res => { + resolve() + localStorage.setItem('token', res.data.data.token) + window.location = '/home' + }) + .catch(err => reject(err.message)) + }) + } else { + return response + } +}) + +axios.interceptors.response.use((response) => { + if (response.data.message === 'Token Expired! Please log in again') { + return new Promise((resolve, reject) => { + axios.post(`${url}/perekrut/refreshToken`, { + refreshToken: localStorage.getItem('refreshToken') + }) + .then(res => { + resolve() + localStorage.setItem('token', res.data.data.token) + window.location = '/home' + }) + .catch(err => reject(err.message)) + }) + } else { + return response + } +}) Vue.use(VueCarousel) Vue.use(BootstrapVue) diff --git a/src/router/index.js b/src/router/index.js index 6a6ca2a..e67dc0d 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -55,6 +55,18 @@ const routes = [ name: 'Home', component: () => import('../views/Home.vue'), meta: { requiresAuth: true } + }, + { + path: '/portfolio', + name: 'Portfolio', + component: () => import('../views/Portfolio.vue'), + meta: { requiresAuth: true } + }, + { + path: '/profile', + name: 'Profile', + component: () => import('../views/Profile.vue'), + meta: { requiresAuth: true } } ] diff --git a/src/store/index.js b/src/store/index.js index 52c82f5..d4a1585 100644 --- a/src/store/index.js +++ b/src/store/index.js @@ -1,7 +1,8 @@ import Vue from 'vue' import Vuex from 'vuex' import auth from './auth' - +import pekerja from './pekerja' +import perekrut from './perekrut' Vue.use(Vuex) export default new Vuex.Store({ @@ -12,6 +13,8 @@ export default new Vuex.Store({ actions: { }, modules: { - auth + auth, + pekerja, + perekrut } }) diff --git a/src/store/pekerja/index.js b/src/store/pekerja/index.js new file mode 100644 index 0000000..9ffa94f --- /dev/null +++ b/src/store/pekerja/index.js @@ -0,0 +1,57 @@ +import axios from 'axios' +import { url } from '../../helper/env' + +const state = () => { + return { + dataPekerja: [], + detailDetail: [] + } +} + +const getters = { + getPekerja (state) { + return state.dataPekerja + }, + getDetailPekerja (state) { + return state.detailDetail + } +} + +const mutations = { + SET_ALL_DATA (state, payload) { + state.dataPekerja = payload + }, + SET_DETAIL_DATA (state, payload) { + state.detailDetail = payload + } +} + +const actions = { + getPekerja (context, payload) { + return new Promise((resolve, reject) => { + axios.get(`${url}/pekerja/getall`) + .then((response) => { + context.commit('SET_ALL_DATA', response.data.data) + }).catch((err) => { + console.log(err) + }) + }) + }, + getDetailPekerja (context, payload) { + return new Promise((resolve, reject) => { + axios.get(`${url}/pekerja/getDetail/${payload}`) + .then((response) => { + context.commit('SET_DETAIL_DATA', response.data.data[0]) + }).catch((err) => { + console.log(err) + }) + }) + } +} +export default { + namespaced: true, + state, + getters, + mutations, + actions +} diff --git a/src/store/perekrut/index.js b/src/store/perekrut/index.js new file mode 100644 index 0000000..5d11a14 --- /dev/null +++ b/src/store/perekrut/index.js @@ -0,0 +1,57 @@ +import axios from 'axios' +import { url } from '../../helper/env' + +const state = () => { + return { + dataPerekrut: [], + detail: [] + } +} + +const getters = { + getPerekrut (state) { + return state.dataPerekrut + }, + getDetailPerekrut (state) { + return state.detail + } +} + +const mutations = { + SET_ALL_DATA (state, payload) { + state.dataPerekrut = payload + }, + SET_DETAIL_DATA (state, payload) { + state.detail = payload + } +} + +const actions = { + getPerekrut (context, payload) { + return new Promise((resolve, reject) => { + axios.get(`${url}/perekrut/getall`) + .then((response) => { + context.commit('SET_ALL_DATA', response.data.data) + }).catch((err) => { + console.log(err) + }) + }) + }, + getDetailPerekrut (context, payload) { + return new Promise((resolve, reject) => { + axios.get(`${url}/perekrut/getdetail/${payload}`) + .then((response) => { + context.commit('SET_DETAIL_DATA', response.data.data[0]) + }).catch((err) => { + console.log(err) + }) + }) + } +} +export default { + namespaced: true, + state, + getters, + mutations, + actions +} diff --git a/src/views/Home.vue b/src/views/Home.vue index 5ab9531..fabc667 100644 --- a/src/views/Home.vue +++ b/src/views/Home.vue @@ -23,7 +23,6 @@ no-caret > Sortir berdasarkan nama - Sortir berdasarkan Skill Sortir berdasarkan Lokasi Sortir berdasarkan freelance Sortir berdasarkan fulltime @@ -34,21 +33,19 @@ -
+
-
+
- +
-

Louis Tomlinson

-

Web developer

-

Lorem ipsum

+

{{ item.namapekerja }}

+

+

{{ item.domisilipekerja }}

- - - +
@@ -222,6 +219,8 @@ import Navbar from '@/components/Navbar.vue' import Footer from '@/components/Footer.vue' import { Carousel, Slide } from 'vue-carousel' +import { mapActions, mapGetters } from 'vuex' + export default { components: { Navbar, @@ -238,13 +237,24 @@ export default { sliding: null } }, + computed: { + ...mapGetters({ + allPekerja: 'pekerja/getPekerja' + }) + }, methods: { + ...mapActions({ + actionGetAllPekerja: 'pekerja/getPekerja' + }), onSlideStart (slide) { this.sliding = true }, onSlideEnd (slide) { this.sliding = false } + }, + mounted () { + this.actionGetAllPekerja() } } diff --git a/src/views/Portfolio.vue b/src/views/Portfolio.vue new file mode 100644 index 0000000..0b831a5 --- /dev/null +++ b/src/views/Portfolio.vue @@ -0,0 +1,136 @@ + + + + + diff --git a/src/views/Profile.vue b/src/views/Profile.vue new file mode 100644 index 0000000..9f36693 --- /dev/null +++ b/src/views/Profile.vue @@ -0,0 +1,64 @@ + + + +