traxxx/assets/js/users/actions.js

67 lines
1.1 KiB
JavaScript

import { graphql } from '../api';
import { releaseFields } from '../fragments';
import { curateUser } from '../curate';
function initUsersActions(_store, _router) {
async function fetchUser(context, username) {
const { user } = await graphql(`
query User(
$username: String!
) {
user: userByUsername(username: $username) {
id
role
username
stashes {
id
name
slug
public
actors: stashesActors {
comment
actor {
id
name
slug
gender
age
ageFromBirth
dateOfBirth
birthCity
birthState
birthCountry: countryByBirthCountryAlpha2 {
alpha2
name
alias
}
avatar: avatarMedia {
id
path
thumbnail
lazy
}
}
}
scenes: stashesScenes {
comment
scene {
${releaseFields}
}
}
}
}
}
`, {
username,
});
return curateUser(user);
}
return {
fetchUser,
};
}
export default initUsersActions;