Skip to content

Commit

Permalink
linting error fix fe
Browse files Browse the repository at this point in the history
  • Loading branch information
MWest2020 committed Aug 5, 2024
2 parents f5c2e8b + b9967e2 commit 05fdc8a
Show file tree
Hide file tree
Showing 10 changed files with 557 additions and 0 deletions.
49 changes: 49 additions & 0 deletions src/store/modules/catalogi.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineStore } from 'pinia'
import { Catalogi } from '../../entities/index.js'

export const useCatalogiStore = defineStore(
<<<<<<< HEAD
'catalogi', {
state: () => ({
catalogiItem: false,
Expand Down Expand Up @@ -49,4 +50,52 @@ export const useCatalogiStore = defineStore(
},
},
},
=======
'catalogi', {
state: () => ({
catalogiItem: false,
catalogiList: [],
}),
actions: {
setCatalogiItem(catalogiItem) {
this.catalogiItem = catalogiItem && new Catalogi(catalogiItem)
console.log('Active catalog item set to ' + catalogiItem && catalogiItem?.id)
},
setCatalogiList(catalogiList) {
this.catalogiList = catalogiList.map(
(catalogiItem) => new Catalogi(catalogiItem),
)
console.log('Catalogi list set to ' + catalogiList.length + ' item')
},
async refreshCatalogiList(search = null) {
// @todo this might belong in a service?
let endpoint = '/index.php/apps/opencatalogi/api/catalogi'
if (search !== null && search !== '') {
endpoint = endpoint + '?_search=' + search
}
return fetch(
endpoint, {
method: 'GET',
}
)
.then(
(response) => {
response.json().then(
(data) => {
this.catalogiList = data.results.map(
(catalogiItem) => new Catalogi(catalogiItem),
)
}
)
}
)
.catch(
(err) => {
console.error(err)
}
)
},
},
}
>>>>>>> b9967e2fa96c9c05d7a70f54b75412883822a595
)
19 changes: 19 additions & 0 deletions src/store/modules/catalogi.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useCatalogiStore } from './catalogi.js'
import { Catalogi } from '../../entities/index.js'

describe(
<<<<<<< HEAD
'Catalogi Store', () => {
beforeEach(
() => {
Expand All @@ -15,6 +16,18 @@ describe(
it(
'sets catalogi item correctly', () => {
const store = useCatalogiStore()
=======
'Catalogi Store', () => {
beforeEach(
() => {
setActivePinia(createPinia())
}
)

it(
'sets catalogi item correctly', () => {
const store = useCatalogiStore()
>>>>>>> b9967e2fa96c9c05d7a70f54b75412883822a595

store.setCatalogiItem(testData[0])

Expand All @@ -25,9 +38,15 @@ describe(
},
)

<<<<<<< HEAD
it(
'sets catalogi list correctly', () => {
const store = useCatalogiStore()
=======
it(
'sets catalogi list correctly', () => {
const store = useCatalogiStore()
>>>>>>> b9967e2fa96c9c05d7a70f54b75412883822a595

store.setCatalogiList(testData)

Expand Down
49 changes: 49 additions & 0 deletions src/store/modules/directory.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { defineStore } from 'pinia'
import { Listing } from '../../entities/index.js'

export const useDirectoryStore = defineStore(
<<<<<<< HEAD
'directory', {
state: () => ({
listingItem: false,
Expand Down Expand Up @@ -49,4 +50,52 @@ export const useDirectoryStore = defineStore(
},
},
},
=======
'directory', {
state: () => ({
listingItem: false,
listingList: [],
}),
actions: {
setListingItem(listingItem) {
this.listingItem = listingItem && new Listing(listingItem)
console.log('Active directory item set to ' + listingItem && listingItem.id)
},
setListingList(listingList) {
this.listingList = listingList.map(
(listingItem) => new Listing(listingItem),
)
console.log('Active directory item set to ' + listingList.length)
},
async refreshListingList(search = null) {
// @todo this might belong in a service?
let endpoint = '/index.php/apps/opencatalogi/api/directory'
if (search !== null && search !== '') {
endpoint = endpoint + '?_search=' + search
}
return fetch(
endpoint, {
method: 'GET',
}
)
.then(
(response) => {
response.json().then(
(data) => {
this.listingList = data.results.map(
(listingItem) => new Listing(listingItem),
)
}
)
}
)
.catch(
(err) => {
console.error(err)
}
)
},
},
}
>>>>>>> b9967e2fa96c9c05d7a70f54b75412883822a595
)
19 changes: 19 additions & 0 deletions src/store/modules/directory.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useDirectoryStore } from './directory.js'
import { Listing } from '../../entities/index.js'

describe(
<<<<<<< HEAD
'Directory Store', () => {
beforeEach(
() => {
Expand All @@ -15,6 +16,18 @@ describe(
it(
'sets listing item correctly', () => {
const store = useDirectoryStore()
=======
'Directory Store', () => {
beforeEach(
() => {
setActivePinia(createPinia())
}
)

it(
'sets listing item correctly', () => {
const store = useDirectoryStore()
>>>>>>> b9967e2fa96c9c05d7a70f54b75412883822a595

store.setListingItem(testData[0])

Expand All @@ -23,9 +36,15 @@ describe(
},
)

<<<<<<< HEAD
it(
'sets listings list correctly', () => {
const store = useDirectoryStore()
=======
it(
'sets listings list correctly', () => {
const store = useDirectoryStore()
>>>>>>> b9967e2fa96c9c05d7a70f54b75412883822a595

store.setListingList(testData)

Expand Down
Loading

0 comments on commit 05fdc8a

Please sign in to comment.