Fixed Babel dependencies.

This commit is contained in:
2019-12-15 23:01:48 +01:00
parent 07a6c77ce2
commit 13b45e1709
6 changed files with 76 additions and 288 deletions

View File

@@ -1,12 +1,75 @@
import { get } from '../api';
import { graphql, get } from '../api';
function curateActor(actor) {
const curatedActor = {
...actor,
avatar: actor.avatar[0],
origin: {
country: actor.originCountry,
},
};
return curatedActor;
}
function initActorActions(store, _router) {
async function fetchActors({ _commit }, { actorId, limit = 100 }) {
if (actorId) {
return get(`/actors/${actorId}`, { limit });
async function fetchActorBySlug(actorSlug) {
const { actor } = await graphql(`
query Actor($actorSlug:String!) {
actor: actorBySlug(slug:$actorSlug) {
id
name
slug
avatar: actorsMediasByTargetId(condition: { role:"avatar" }) {
thumbnail
}
originCountry: countryByBirthCountryAlpha2 {
alpha2
name
alias
}
aliases: actorsByAliasFor {
id
name
slug
}
}
}
`, {
actorSlug,
});
return curateActor(actor);
}
async function fetchActors({ _commit }, { actorSlug, limit = 100 }) {
if (actorSlug) {
return fetchActorBySlug(actorSlug);
}
return get('/actors', { limit });
const { actors } = await graphql(`
query Actors($limit:Int) {
actors(first:$limit) {
id
name
slug
avatar: actorsMediasByTargetId(condition: { role:"avatar" }) {
thumbnail
}
originCountry: countryByBirthCountryAlpha2 {
alpha2
name
alias
}
}
}
`, {
limit,
});
console.log(actors);
return actors.map(actor => curateActor(actor));
}
async function fetchActorReleases({ _commit }, actorId) {