moved trycatch to the correct location lol
This commit is contained in:
@@ -67,14 +67,25 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async deleteKeep() {
|
async deleteKeep() {
|
||||||
|
try {
|
||||||
await keepsService.delete(props.keep.id)
|
await keepsService.delete(props.keep.id)
|
||||||
Modal.getOrCreateInstance(document.getElementById("keepModal")).hide();
|
Modal.getOrCreateInstance(document.getElementById("keepModal")).hide();
|
||||||
// do more things
|
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error)
|
||||||
|
Pop.toast(error)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async addToVault(vaultId) {
|
async addToVault(vaultId) {
|
||||||
|
try {
|
||||||
await vaultKeepsService.create(props.keep.id, vaultId)
|
await vaultKeepsService.create(props.keep.id, vaultId)
|
||||||
Modal.getOrCreateInstance(document.getElementById("keepModal")).hide();
|
Modal.getOrCreateInstance(document.getElementById("keepModal")).hide();
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error)
|
||||||
|
Pop.toast(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,20 +0,0 @@
|
|||||||
<template>
|
|
||||||
<div class="component">
|
|
||||||
keeps list
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</template>
|
|
||||||
|
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
setup(){
|
|
||||||
return {}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
|
|
||||||
|
|
||||||
<style lang="scss" scoped>
|
|
||||||
|
|
||||||
</style>
|
|
||||||
@@ -54,6 +54,7 @@ export default {
|
|||||||
tags: "",
|
tags: "",
|
||||||
|
|
||||||
async createKeep() {
|
async createKeep() {
|
||||||
|
try {
|
||||||
let newKeep = {
|
let newKeep = {
|
||||||
name: this.name,
|
name: this.name,
|
||||||
img: this.img,
|
img: this.img,
|
||||||
@@ -61,10 +62,12 @@ export default {
|
|||||||
// ,tags: this.tags
|
// ,tags: this.tags
|
||||||
}
|
}
|
||||||
await keepsService.create(newKeep)
|
await keepsService.create(newKeep)
|
||||||
Modal.getOrCreateInstance(document.getElementById("newKeepModal")).hide();
|
Modal.getOrCreateInstance(document.getElementById("newKeepModal")).hide()
|
||||||
|
|
||||||
// reload vaults
|
} catch (error) {
|
||||||
// close modal
|
logger.error(error)
|
||||||
|
Pop.toast(error0)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ export default {
|
|||||||
isPrivate: false,
|
isPrivate: false,
|
||||||
|
|
||||||
async createVault() {
|
async createVault() {
|
||||||
|
try {
|
||||||
let newVault = {
|
let newVault = {
|
||||||
name: this.name,
|
name: this.name,
|
||||||
img: this.img,
|
img: this.img,
|
||||||
@@ -55,6 +56,11 @@ export default {
|
|||||||
|
|
||||||
await vaultsService.createVault(newVault)
|
await vaultsService.createVault(newVault)
|
||||||
Modal.getOrCreateInstance(document.getElementById("newVaultModal")).hide();
|
Modal.getOrCreateInstance(document.getElementById("newVaultModal")).hide();
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error)
|
||||||
|
Pop.toast(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,17 +54,26 @@ export default {
|
|||||||
},
|
},
|
||||||
|
|
||||||
async removeFromVault() {
|
async removeFromVault() {
|
||||||
// props.keep don't have vaultKeepId...
|
try {
|
||||||
logger.log(props.keep)
|
|
||||||
await vaultKeepsService.delete(props.keep.vaultKeepId)
|
await vaultKeepsService.delete(props.keep.vaultKeepId)
|
||||||
Modal.getOrCreateInstance(document.getElementById("keepModal")).hide();
|
Modal.getOrCreateInstance(document.getElementById("keepModal")).hide();
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error)
|
||||||
|
Pop.toast(error)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async deleteKeep() {
|
async deleteKeep() {
|
||||||
|
try {
|
||||||
await keepsService.delete(props.keep.id)
|
await keepsService.delete(props.keep.id)
|
||||||
await vaultKeepsService.delete(props.keep.vaultKeepId)
|
await vaultKeepsService.delete(props.keep.vaultKeepId)
|
||||||
Modal.getOrCreateInstance(document.getElementById("keepModal")).hide();
|
Modal.getOrCreateInstance(document.getElementById("keepModal")).hide();
|
||||||
// do more things
|
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error)
|
||||||
|
Pop.toast(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,11 +35,18 @@ export default {
|
|||||||
return {
|
return {
|
||||||
keeps: computed(() => AppState.keeps),
|
keeps: computed(() => AppState.keeps),
|
||||||
activeKeep: computed(() => AppState.activeKeep),
|
activeKeep: computed(() => AppState.activeKeep),
|
||||||
|
|
||||||
viewKeep(keep) {
|
viewKeep(keep) {
|
||||||
|
try {
|
||||||
// AppState.activeKeep = keep;
|
// AppState.activeKeep = keep;
|
||||||
// make API call to trigger view counter
|
// make API call to trigger view counter
|
||||||
keepsService.getById(keep.id)
|
keepsService.getById(keep.id)
|
||||||
Modal.getOrCreateInstance(document.getElementById("keepModal")).show();
|
Modal.getOrCreateInstance(document.getElementById("keepModal")).show();
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error)
|
||||||
|
Pop.toast(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -81,11 +81,17 @@ export default {
|
|||||||
activeKeep: computed(() => AppState.activeKeep),
|
activeKeep: computed(() => AppState.activeKeep),
|
||||||
|
|
||||||
async viewKeep(keep) {
|
async viewKeep(keep) {
|
||||||
|
try {
|
||||||
keep.creator = AppState.activeProfile;
|
keep.creator = AppState.activeProfile;
|
||||||
// AppState.activeKeep = keep
|
// AppState.activeKeep = keep
|
||||||
// make API call to trigger view counter
|
// make API call to trigger view counter
|
||||||
keepsService.getById(keep.id)
|
keepsService.getById(keep.id)
|
||||||
Modal.getOrCreateInstance(document.getElementById("keepModal")).show();
|
Modal.getOrCreateInstance(document.getElementById("keepModal")).show();
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error)
|
||||||
|
Pop.toast(error)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async viewVault(vault) {
|
async viewVault(vault) {
|
||||||
|
|||||||
@@ -60,17 +60,29 @@ export default {
|
|||||||
account: computed(() => AppState.account),
|
account: computed(() => AppState.account),
|
||||||
|
|
||||||
async viewKeep(keep) {
|
async viewKeep(keep) {
|
||||||
|
try {
|
||||||
// AppState.activeKeep = keep
|
// AppState.activeKeep = keep
|
||||||
// make API call to trigger view counter
|
// make API call to trigger view counter
|
||||||
// debugger
|
// debugger
|
||||||
await keepsService.getById(keep.id)
|
await keepsService.getById(keep.id)
|
||||||
AppState.activeKeep = keep
|
AppState.activeKeep = keep
|
||||||
Modal.getOrCreateInstance(document.getElementById('keepModal')).show()
|
Modal.getOrCreateInstance(document.getElementById('keepModal')).show()
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error)
|
||||||
|
Pop.toast(error)
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
async deleteVault() {
|
async deleteVault() {
|
||||||
|
try {
|
||||||
await vaultsService.delete(AppState.activeVault.id, AppState.vaultKeeps)
|
await vaultsService.delete(AppState.activeVault.id, AppState.vaultKeeps)
|
||||||
router.push({ name: "Profile", params: { id: AppState.account.id } })
|
router.push({ name: "Profile", params: { id: AppState.account.id } })
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
logger.error(error)
|
||||||
|
Pop.toast(error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -5,49 +5,29 @@ import Pop from '../utils/Pop'
|
|||||||
|
|
||||||
class KeepsService {
|
class KeepsService {
|
||||||
async getAll() {
|
async getAll() {
|
||||||
try {
|
|
||||||
const res = await api.get('api/keeps')
|
const res = await api.get('api/keeps')
|
||||||
AppState.keeps = res.data
|
AppState.keeps = res.data
|
||||||
} catch (error) {
|
|
||||||
logger.error(error)
|
|
||||||
Pop.error(error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getById(id) {
|
async getById(id) {
|
||||||
try {
|
|
||||||
const res = await api.get('api/keeps/' + id)
|
const res = await api.get('api/keeps/' + id)
|
||||||
AppState.activeKeep = res.data
|
AppState.activeKeep = res.data
|
||||||
} catch (error) {
|
|
||||||
logger.error(error)
|
|
||||||
Pop.error(error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async create(newKeep) {
|
async create(newKeep) {
|
||||||
try {
|
|
||||||
const res = await api.post('api/keeps', newKeep)
|
const res = await api.post('api/keeps', newKeep)
|
||||||
// logger.log(res.data)
|
// logger.log(res.data)
|
||||||
AppState.profileKeeps.push(res.data)
|
AppState.profileKeeps.push(res.data)
|
||||||
AppState.keeps.push(res.data)
|
AppState.keeps.push(res.data)
|
||||||
// this.getAll()
|
// this.getAll()
|
||||||
} catch (error) {
|
|
||||||
logger.error(error)
|
|
||||||
Pop.error(error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete(keepId) {
|
async delete(keepId) {
|
||||||
try {
|
|
||||||
const res = await api.delete('api/keeps/' + keepId)
|
const res = await api.delete('api/keeps/' + keepId)
|
||||||
// logger.log(res.data)
|
// logger.log(res.data)
|
||||||
// AppState.keeps.filter((k) => k.id != res.data)
|
// AppState.keeps.filter((k) => k.id != res.data)
|
||||||
// AppState.keeps.filter((k) => k.id != keepId)
|
// AppState.keeps.filter((k) => k.id != keepId)
|
||||||
this.getAll()
|
this.getAll()
|
||||||
} catch (error) {
|
|
||||||
logger.error(error)
|
|
||||||
Pop.error(error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,41 +4,25 @@ import { api } from './AxiosService'
|
|||||||
|
|
||||||
class ProfilesService {
|
class ProfilesService {
|
||||||
async getProfile(profileId) {
|
async getProfile(profileId) {
|
||||||
try {
|
|
||||||
const res = await api.get('api/profiles/' + profileId)
|
const res = await api.get('api/profiles/' + profileId)
|
||||||
// logger.log(res.data)
|
// logger.log(res.data)
|
||||||
AppState.activeProfile = res.data
|
AppState.activeProfile = res.data
|
||||||
} catch (error) {
|
|
||||||
logger.error(error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getKeeps(profileId) {
|
async getKeeps(profileId) {
|
||||||
try {
|
|
||||||
const res = await api.get('api/profiles/' + profileId + '/keeps')
|
const res = await api.get('api/profiles/' + profileId + '/keeps')
|
||||||
AppState.profileKeeps = res.data
|
AppState.profileKeeps = res.data
|
||||||
} catch (error) {
|
|
||||||
logger.error(error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getVaults(profileId) {
|
async getVaults(profileId) {
|
||||||
try {
|
|
||||||
const res = await api.get('api/profiles/' + profileId + '/vaults')
|
const res = await api.get('api/profiles/' + profileId + '/vaults')
|
||||||
logger.log(res.data)
|
logger.log(res.data)
|
||||||
AppState.profileVaults = res.data
|
AppState.profileVaults = res.data
|
||||||
} catch (error) {
|
|
||||||
logger.error(error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getMyVaults(profileId) {
|
async getMyVaults(profileId) {
|
||||||
try {
|
|
||||||
const res = await api.get('api/profiles/' + profileId + '/vaults')
|
const res = await api.get('api/profiles/' + profileId + '/vaults')
|
||||||
AppState.myVaults = res.data
|
AppState.myVaults = res.data
|
||||||
} catch (error) {
|
|
||||||
logger.error(error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,28 +6,18 @@ import { vaultsService } from '../services/VaultsService'
|
|||||||
|
|
||||||
class VaultKeepsService {
|
class VaultKeepsService {
|
||||||
async create(keepId, vaultId) {
|
async create(keepId, vaultId) {
|
||||||
try {
|
|
||||||
let newVaultKeep = {
|
let newVaultKeep = {
|
||||||
vaultId: vaultId,
|
vaultId: vaultId,
|
||||||
keepId: keepId
|
keepId: keepId
|
||||||
}
|
}
|
||||||
const res = await api.post('api/vaultkeeps', newVaultKeep)
|
const res = await api.post('api/vaultkeeps', newVaultKeep)
|
||||||
AppState.vaultKeeps.push(res.data)
|
AppState.vaultKeeps.push(res.data)
|
||||||
} catch (error) {
|
|
||||||
logger.error(error)
|
|
||||||
Pop.error(error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete(vaultKeepId) {
|
async delete(vaultKeepId) {
|
||||||
try {
|
|
||||||
logger.log(vaultKeepId)
|
logger.log(vaultKeepId)
|
||||||
await api.delete('api/vaultkeeps/' + vaultKeepId)
|
await api.delete('api/vaultkeeps/' + vaultKeepId)
|
||||||
await vaultsService.getVaultKeeps(AppState.activeVault.id)
|
await vaultsService.getVaultKeeps(AppState.activeVault.id)
|
||||||
} catch (error) {
|
|
||||||
logger.error(error)
|
|
||||||
Pop.error(error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -21,31 +21,17 @@ class VaultsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async createVault(vaultData) {
|
async createVault(vaultData) {
|
||||||
try {
|
|
||||||
const res = await api.post('api/vaults', vaultData)
|
const res = await api.post('api/vaults', vaultData)
|
||||||
// logger.log(res.data)
|
// logger.log(res.data)
|
||||||
// AppState.myVaults.push(res.data)
|
// AppState.myVaults.push(res.data)
|
||||||
profilesService.getVaults(AppState.account.id)
|
profilesService.getVaults(AppState.account.id)
|
||||||
AppState.myVaults = AppState.profileVaults
|
AppState.myVaults = AppState.profileVaults
|
||||||
} catch (error) {
|
|
||||||
logger.error(error)
|
|
||||||
Pop.error(error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async delete(vaultId, vaultKeeps) {
|
async delete(vaultId, vaultKeeps) {
|
||||||
try {
|
|
||||||
// vaultKeeps will collect in db... if this isn't here
|
|
||||||
// for (let vk = 0; vk < vaultKeeps.length; vk++) {
|
|
||||||
// await vaultKeepsService.delete(vaultKeeps[vk].id)
|
|
||||||
// }
|
|
||||||
await api.delete('api/vaults/' + vaultId)
|
await api.delete('api/vaults/' + vaultId)
|
||||||
profilesService.getVaults(AppState.account.id)
|
profilesService.getVaults(AppState.account.id)
|
||||||
AppState.myVaults = AppState.profileVaults
|
AppState.myVaults = AppState.profileVaults
|
||||||
} catch (error) {
|
|
||||||
logger.error(error)
|
|
||||||
Pop.error(error)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,8 @@
|
|||||||
|
add form validation to new keep and new vault
|
||||||
|
upload images instead of linking them (BIG TASK)
|
||||||
|
move trycatches to component (DONE)
|
||||||
|
make more efficient to manipulate appstate without backend calls
|
||||||
|
fix styling bug for bottom button on keeps without delete or remove buttons in vualt
|
||||||
|
enable ability to add to vault from vaults that aren't yours
|
||||||
|
add title/aria/alt accessibility tags to everything
|
||||||
|
maybe add a shadow to the bottom of keep and vault cards?
|
||||||
Reference in New Issue
Block a user