Added actor alphanetic and gender filters.

This commit is contained in:
2020-02-09 05:30:10 +01:00
parent cde290fbd7
commit 4eb57b4a91
9 changed files with 217 additions and 9 deletions

View File

@@ -171,14 +171,34 @@ function initActorActions(store, _router) {
return curateActor(actor);
}
async function fetchActors({ _commit }, { actorSlug, limit = 100 }) {
async function fetchActors({ _commit }, {
actorSlug,
limit = 100,
letter,
genders,
}) {
if (actorSlug) {
return fetchActorBySlug(actorSlug);
}
const { actors } = await graphql(`
query Actors($limit:Int) {
actors(first:$limit, orderBy: NAME_ASC) {
query Actors(
$limit: Int,
$letter: String! = "",
$genders: [String!] = ["female"],
) {
actors(
first:$limit,
orderBy: NAME_ASC,
filter: {
name: {
startsWith: $letter
},
gender: {
in: $genders
},
},
) {
id
name
slug
@@ -199,6 +219,8 @@ function initActorActions(store, _router) {
}
`, {
limit,
letter,
genders,
});
return actors.map(actor => curateActor(actor));

View File

@@ -53,6 +53,17 @@ const routes = [
{
path: '/actors',
component: Actors,
redirect: {
name: 'actors',
params: {
gender: 'female',
letter: 'all',
},
},
},
{
path: '/actors/:gender/:letter',
component: Actors,
name: 'actors',
},
{