Repackage Team Module
This commit is contained in:
commit
a1b4bbe18c
203 files changed
+29564
No files matched your search
@@ -0,0 +1,233 @@
|
||||
import { action, throttle } from '@hyperapp/fx'
|
||||
|
||||
import { UniqueAlgobotnameQuery } from '../graphql/UniqueAlgobotnameQuery'
|
||||
import { AddAlgobotMutation } from '../graphql/AddAlgobotMutation'
|
||||
import { GetAlgobotQuery } from '../graphql/GetAlgobotQuery'
|
||||
import { DeleteAlgobotMutation } from '../graphql/DeleteAlgobotMutation'
|
||||
|
||||
import { client } from '../../../index'
|
||||
|
||||
import { mergeDeep } from '../../../utils/js-helpers'
|
||||
|
||||
export const algobot = {
|
||||
form: ({ form, message }) => state => {
|
||||
return {
|
||||
form: {
|
||||
form,
|
||||
message
|
||||
}
|
||||
}
|
||||
},
|
||||
clearForms: () => ({
|
||||
form: {
|
||||
form: 'login',
|
||||
message: ''
|
||||
},
|
||||
createAlgobot: {
|
||||
input: '',
|
||||
unique: false,
|
||||
placeholder: 'Your algobotname'
|
||||
}
|
||||
}),
|
||||
checkAlgobotname: value => [
|
||||
action('throttleAlgobotname', value),
|
||||
action('createAlgobot.input', value)
|
||||
],
|
||||
throttleAlgobotname: value => throttle(750, 'uniqueAlgobotname', value),
|
||||
uniqueAlgobotname: value => async (state, actions) => {
|
||||
const result = await client.query({
|
||||
query: UniqueAlgobotnameQuery,
|
||||
variables: { algobotname: value }
|
||||
})
|
||||
return actions.createAlgobot.unique(result.data.uniqueAlgobotname)
|
||||
},
|
||||
createAlgobot: {
|
||||
input: value => state => {
|
||||
const algobotnameInput = {
|
||||
input: value
|
||||
}
|
||||
return mergeDeep(algobotnameInput, state.createAlgobot)
|
||||
},
|
||||
unique: value => state => {
|
||||
const algobotnameInput = {
|
||||
unique: value
|
||||
}
|
||||
return mergeDeep(algobotnameInput, state.createAlgobot)
|
||||
},
|
||||
error: message => state => {
|
||||
const errorInput = {
|
||||
message: message
|
||||
}
|
||||
return mergeDeep(errorInput, state.createAlgobot)
|
||||
}
|
||||
},
|
||||
profile: profile => (state, actions) => {
|
||||
return {
|
||||
profile
|
||||
}
|
||||
},
|
||||
addAlgobot: result => [
|
||||
action('form', {
|
||||
form: 'addAlgobotNotice',
|
||||
message: `Adding your algobot...`
|
||||
}),
|
||||
action('addAlgobotSubmit', result)
|
||||
],
|
||||
addAlgobotSubmit: algobotForm => async (state, actions) => {
|
||||
algobotForm.preventDefault()
|
||||
algobotForm.target.blur()
|
||||
|
||||
const algobotname = algobotForm.target.form[0].value
|
||||
|
||||
const slug = await algobotname.replace(/[^a-zA-Z0-9]+/g, '-').toLowerCase()
|
||||
const validateSlug = new RegExp('^[a-z0-9-]+$')
|
||||
const valid = await validateSlug.test(slug)
|
||||
await console.log('actions.algobot.addAlgobot: ', valid, slug)
|
||||
if (!valid) {
|
||||
return actions.form({
|
||||
form: 'addAlgobotError',
|
||||
message:
|
||||
'Algobot name not valid. Please only letters, numbers and spaces'
|
||||
})
|
||||
}
|
||||
|
||||
const teamId = algobotForm.target.form[2].value
|
||||
|
||||
if (teamId === '') {
|
||||
return actions.form({
|
||||
form: 'addAlgobotError',
|
||||
message: 'Please create a team first!'
|
||||
})
|
||||
}
|
||||
|
||||
const algobot = {
|
||||
name: algobotname,
|
||||
slug: slug,
|
||||
owner: algobotForm.target.form[1].value,
|
||||
team_id: teamId
|
||||
}
|
||||
|
||||
const uniqueAlgobot = await client.query({
|
||||
query: UniqueAlgobotnameQuery,
|
||||
variables: { algobotname: algobotname }
|
||||
})
|
||||
await console.log(
|
||||
'actions.algobot.addAlgobot: ',
|
||||
algobot,
|
||||
valid,
|
||||
uniqueAlgobot,
|
||||
uniqueAlgobot.data.uniqueAlgobotname
|
||||
)
|
||||
if (!uniqueAlgobot.data.uniqueAlgobotname) {
|
||||
return actions.form({
|
||||
form: 'addAlgobotError',
|
||||
message: 'Sorry, this algobot name is taken. Please create a new one'
|
||||
})
|
||||
}
|
||||
|
||||
const result = await client.mutate({
|
||||
mutation: AddAlgobotMutation,
|
||||
variables: { input: algobot },
|
||||
options: {
|
||||
update: (proxy, { data: { getAlgobotByOwner } }) => {
|
||||
const data = proxy.readQuery({ GetAlgobotQuery })
|
||||
data.getAlgobotByOwner.push(getAlgobotByOwner)
|
||||
proxy.writeQuery({ GetAlgobotQuery, data })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (result.data.addAlgobot !== null) {
|
||||
return actions.addAlgobotSuccess(result.data.addAlgobot)
|
||||
} else {
|
||||
return actions.form({
|
||||
form: 'addAlgobotError',
|
||||
message: `Unable to add Algobot: ${
|
||||
result.data.addAlgobot.errors[0].message
|
||||
}`
|
||||
})
|
||||
}
|
||||
},
|
||||
addAlgobotSuccess: result => [
|
||||
action('form', { form: 'addAlgobotSuccess', message: 'Algobot Added!' }),
|
||||
action('profile', result),
|
||||
action('createAlgobot.input', ''),
|
||||
action('toggleModal', '')
|
||||
],
|
||||
toggleModal: form => (state, actions) => {
|
||||
return {
|
||||
modal: {
|
||||
content: form,
|
||||
isActive: !state.modal.isActive
|
||||
}
|
||||
}
|
||||
},
|
||||
getAlgobots: id => [
|
||||
action('form', {
|
||||
form: 'getAlgobotLoad',
|
||||
message: 'Getting your algobot...'
|
||||
}),
|
||||
action('getAlgobotbyOwner', id)
|
||||
],
|
||||
getAlgobotbyOwner: id => async (state, actions) => {
|
||||
/*
|
||||
const result = await client.query({
|
||||
query: GetAlgobotQuery,
|
||||
variables: { owner: id },
|
||||
fetchPolicy: 'network-only'
|
||||
})
|
||||
|
||||
if (result.data.getAlgobotByOwner !== null) {
|
||||
return actions.getAlgobotSuccess(result.data.getAlgobotByOwner)
|
||||
} else {
|
||||
return actions.getAlgobotNoAlgobot()
|
||||
} */
|
||||
return actions.getAlgobotNoAlgobot()
|
||||
},
|
||||
getAlgobotSuccess: profile => [
|
||||
action('form', { form: 'getAlgobotSuccess', message: 'Your algobot' }),
|
||||
action('profile', profile)
|
||||
],
|
||||
getAlgobotNoAlgobot: profile => [
|
||||
action('form', { form: 'getAlgobotNotice', message: 'No algobot found' }),
|
||||
action('profile', { name: '' })
|
||||
],
|
||||
deleteAlgobot: id => [
|
||||
action('form', {
|
||||
form: 'deleteAlgobotLoad',
|
||||
message: 'Removing your algobot...'
|
||||
}),
|
||||
action('deleteAlgobotSubmit', id)
|
||||
],
|
||||
deleteAlgobotSubmit: id => async (state, actions) => {
|
||||
const result = await client.mutate({
|
||||
mutation: DeleteAlgobotMutation,
|
||||
variables: { id: Number(id) },
|
||||
options: {
|
||||
update: (proxy, { data: { getAlgobotByOwner } }) => {
|
||||
const data = proxy.readQuery({ GetAlgobotQuery })
|
||||
data.getAlgobotByOwner.push(getAlgobotByOwner)
|
||||
proxy.writeQuery({ GetAlgobotQuery, data })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (result.data.deleteAlgobot.id !== null) {
|
||||
return actions.deleteAlgobotSuccess({ name: '' })
|
||||
} else {
|
||||
return actions.form({
|
||||
form: 'deleteAlgobotError',
|
||||
message: 'No algobot found'
|
||||
})
|
||||
}
|
||||
},
|
||||
deleteAlgobotSuccess: profile => [
|
||||
action('form', {
|
||||
form: 'deleteAlgobotSuccess',
|
||||
message: 'Your algobot has been deleted'
|
||||
}),
|
||||
action('profile', profile)
|
||||
]
|
||||
}
|
||||
|
||||
export default algobot
|
||||
@@ -0,0 +1,17 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const AddAlgobotMutation = gql`
|
||||
mutation addAlgobot($input: AddAlgobotInput!) {
|
||||
addAlgobot(input: $input) {
|
||||
id
|
||||
name
|
||||
slug
|
||||
owner
|
||||
avatar
|
||||
repo
|
||||
team_id
|
||||
type
|
||||
}
|
||||
}
|
||||
`
|
||||
@@ -0,0 +1,10 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const DeleteAlgobotMutation = gql`
|
||||
mutation deleteAlgobot($id: Int!) {
|
||||
deleteAlgobot(id: $id) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`
|
||||
@@ -0,0 +1,19 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const GetAlgobotQuery = gql`
|
||||
query getAlgobotByOwner($owner: Int!) {
|
||||
getAlgobotByOwner(owner: $owner) {
|
||||
id
|
||||
name
|
||||
slug
|
||||
owner
|
||||
avatar
|
||||
repo
|
||||
team_id
|
||||
type
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export default GetAlgobotQuery
|
||||
@@ -0,0 +1,10 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const UniqueAlgobotnameQuery = gql`
|
||||
query uniqueAlgobotname($algobotname: String!) {
|
||||
uniqueAlgobotname(algobotname: $algobotname)
|
||||
}
|
||||
`
|
||||
|
||||
export default UniqueAlgobotnameQuery
|
||||
Whitespace-only changes.
@@ -0,0 +1,28 @@
|
||||
export const algobot = {
|
||||
form: {
|
||||
type: 'login',
|
||||
message: ''
|
||||
},
|
||||
createAlgobot: {
|
||||
input: '',
|
||||
unique: true,
|
||||
placeholder: 'Your algobot name',
|
||||
error: ''
|
||||
},
|
||||
profile: {
|
||||
id: '',
|
||||
name: '',
|
||||
slug: '',
|
||||
owner: '',
|
||||
avatar: '',
|
||||
repo: '',
|
||||
team_id: ''
|
||||
},
|
||||
members: [],
|
||||
modal: {
|
||||
content: '',
|
||||
isActive: false
|
||||
}
|
||||
}
|
||||
|
||||
export default algobot
|
||||
@@ -0,0 +1,90 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { h } from 'hyperapp'
|
||||
|
||||
export const AddAlgobotForm = props => (state, actions) => (
|
||||
<form name='addAlgobotForm' key='AddAlgobotForm'>
|
||||
<h1 class='title'>Add An Algobot</h1>
|
||||
<div class='field'>
|
||||
<label class='label'>Enter a algobot name</label>
|
||||
<div class='control has-icons-left has-icons-right'>
|
||||
<input
|
||||
class='input'
|
||||
type='text'
|
||||
onupdate={(element, oldAttributes) => {
|
||||
if (
|
||||
oldAttributes.value !== element.value ||
|
||||
(oldAttributes.value !== '' && element.value === '')
|
||||
) {
|
||||
element.focus()
|
||||
}
|
||||
}}
|
||||
aria-label={state.algobot.createAlgobot.placeholder}
|
||||
oninput={({ target: { value } }) =>
|
||||
actions.algobot.checkAlgobotname(value)
|
||||
}
|
||||
onblur={({ target: { value } }) =>
|
||||
actions.algobot.checkAlgobotname(value)
|
||||
}
|
||||
value={state.algobot.createAlgobot.input}
|
||||
placeholder={state.algobot.createAlgobot.placeholder}
|
||||
/>
|
||||
<span
|
||||
class={`icon is-small is-right ${
|
||||
state.algobot.createAlgobot.unique.input !== '' &&
|
||||
state.algobot.createAlgobot.unique
|
||||
? 'has-text-success'
|
||||
: 'has-text-grey'
|
||||
}`}
|
||||
>
|
||||
<i class='fas fa-check' />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<p
|
||||
key='createAlgobotUniqueMessage'
|
||||
class={`has-text-centered ${
|
||||
!state.algobot.createAlgobot.unique ? 'has-text-danger' : 'is-invisible'
|
||||
}`}
|
||||
>
|
||||
This algobotname is already taken. Please create a new one.
|
||||
</p>
|
||||
<p
|
||||
key='addAlgobotMessage'
|
||||
class={`help is-size-4 m-t-hlf m-b-hlf
|
||||
${
|
||||
state.algobot.form.form === 'addAlgobotSuccess'
|
||||
? 'has-text-success'
|
||||
: ''
|
||||
}
|
||||
${
|
||||
state.algobot.form.form === 'addAlgobotNotice'
|
||||
? 'has-text-primary'
|
||||
: ''
|
||||
}
|
||||
${
|
||||
state.algobot.form.form === 'addAlgobotError' ? 'has-text-danger' : ''
|
||||
}
|
||||
${
|
||||
state.algobot.form.form === 'addAlgobotSuccess' ||
|
||||
state.algobot.form.form === 'addAlgobotNotice' ||
|
||||
state.algobot.form.form === 'addAlgobotError'
|
||||
? ''
|
||||
: 'is-invisible'
|
||||
}`}
|
||||
>
|
||||
{state.algobot.form.message}
|
||||
</p>
|
||||
<div class='control buttons is-centered'>
|
||||
<input type='hidden' name='owner' value={state.user.profile.id} />
|
||||
<input type='hidden' name='team_id' value={state.team.profile.id} />
|
||||
<button
|
||||
onclick={e => actions.algobot.addAlgobot(e)}
|
||||
class='button is-link'
|
||||
>
|
||||
Create Algobot
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
)
|
||||
|
||||
export default AddAlgobotForm
|
||||
@@ -0,0 +1,164 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { h } from 'hyperapp'
|
||||
import { Link } from '@hyperapp/router'
|
||||
import { validObject } from '../../../utils/js-helpers'
|
||||
|
||||
export const AlgobotList = props => (state, actions) => {
|
||||
const algobot = state.algobot.profile
|
||||
console.log(state.algobot.form.form, state.algobot.form.message, algobot.name)
|
||||
if (
|
||||
state.algobot.form.form === 'getAlgobotNotice' &&
|
||||
state.algobot.form.message === 'No algobot found' &&
|
||||
algobot.name === '' &&
|
||||
state.team.profile.name === ''
|
||||
) {
|
||||
return (
|
||||
<div class='section' key='algobotList1'>
|
||||
<p class='is-size-4'>
|
||||
You don't have a team yet! Please create one before adding an algobot.
|
||||
</p>
|
||||
<div class='level m-t-2'>
|
||||
<div class='level-item'>
|
||||
<Link to='/team' class='button navbar-item'>
|
||||
Go to Team Overview →
|
||||
</Link>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (
|
||||
state.algobot.form.form === 'getAlgobotNotice' &&
|
||||
state.algobot.form.message === 'No algobot found' &&
|
||||
algobot.name === ''
|
||||
) {
|
||||
return (
|
||||
<div class='section' key='algobotList2'>
|
||||
<p class='is-size-4'>Algobot creation currently disabled</p>
|
||||
<div class='level m-t-2'>
|
||||
<div class='level-item'>
|
||||
<a
|
||||
class='button is-primary is-medium'
|
||||
disabled={true}
|
||||
onclick={() => actions.algobot.toggleModal('AddAlgobot')}
|
||||
>
|
||||
Create an algobot
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (
|
||||
(algobot.name !== '' && algobot.name !== null) ||
|
||||
state.algobot.form.form === 'deleteAlgobotSuccess'
|
||||
) {
|
||||
const initial = algobot.name.substring(0, 1)
|
||||
return (
|
||||
<div class='section' key='algobotList3'>
|
||||
<p
|
||||
class={`is-size-5 card-footer-item
|
||||
${
|
||||
state.algobot.form.form === 'deleteAlgobotSuccess'
|
||||
? 'has-text-success'
|
||||
: ''
|
||||
}
|
||||
${
|
||||
state.algobot.form.form === 'deleteAlgobotNotice'
|
||||
? 'has-text-primary'
|
||||
: ''
|
||||
}
|
||||
${
|
||||
state.algobot.form.form === 'deleteAlgobotError'
|
||||
? 'has-text-danger'
|
||||
: ''
|
||||
}
|
||||
${
|
||||
state.algobot.form.form === 'deleteAlgobotSuccess' ||
|
||||
state.algobot.form.form === 'deleteAlgobotNotice' ||
|
||||
state.algobot.form.form === 'deleteAlgobotError'
|
||||
? ''
|
||||
: 'is-invisible'
|
||||
}`}
|
||||
>
|
||||
{state.algobot.form.message}
|
||||
</p>
|
||||
<table class='table is-fullwidth is-striped'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>Algobot Name</th>
|
||||
<th>Team</th>
|
||||
<th>Type</th>
|
||||
<th>Owner</th>
|
||||
<th>Repo</th>
|
||||
<th class='has-text-right'>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{algobot.name !== '' ? (
|
||||
<tr>
|
||||
<td>
|
||||
{algobot.avatar !== null && algobot.avatar !== '' ? (
|
||||
<div class='image is-16x16 avatar'>
|
||||
<img src={algobot.avatar} alt={algobot.name} />
|
||||
</div>
|
||||
) : (
|
||||
<div class='image is-16x16 avatar has-text-white is-uppercase is-green is-size-7 is-centered'>
|
||||
{initial}
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<strong>{algobot.name}</strong>
|
||||
</td>
|
||||
<td>{state.team.profile.name}</td>
|
||||
<td />
|
||||
<td>{state.user.profile.username}</td>
|
||||
<td />
|
||||
<td class='has-text-right'>
|
||||
<button
|
||||
onclick={e =>
|
||||
actions.algobot.deleteAlgobot(
|
||||
state.algobot.profile.id,
|
||||
state.algobot.profile.owner
|
||||
)
|
||||
}
|
||||
class='button is-small is-red'
|
||||
disabled={
|
||||
state.algobot.form.form === 'getAlgobotNotice' &&
|
||||
state.algobot.form.message === 'Removing your algobot...'
|
||||
}
|
||||
>
|
||||
<span class='icon'>
|
||||
<i class='fas fa-trash-alt' />
|
||||
</span>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div class='section' key='algobotList4'>
|
||||
<p class='is-size-4'>{state.algobot.form.message}</p>
|
||||
<div class='level m-t-2'>
|
||||
<div class='level-item'>
|
||||
<span class='icon has-text-primary is-large'>
|
||||
<i class='fas fa-spinner fa-pulse' />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default AlgobotList
|
||||
@@ -0,0 +1,121 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { h } from 'hyperapp'
|
||||
import { Link } from '@hyperapp/router'
|
||||
import { validObject } from '../../../utils/js-helpers'
|
||||
|
||||
export const AlgobotPanel = props => (state, actions) => {
|
||||
const algobot = validObject(state.algobot.profile, 'edges') ? state.team.profile.edges : ''
|
||||
|
||||
if (algobot === '') {
|
||||
return (
|
||||
<div
|
||||
class='section'
|
||||
key='algobotList1'
|
||||
class='is-marginless is-paddingless'
|
||||
>
|
||||
<h2 class='title is-size-4 m-t-1'>Algobots</h2>
|
||||
<p class='is-size-5'>
|
||||
Create a team first,<br />then setup your algobot!
|
||||
</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (
|
||||
state.algobot.form.form === 'getAlgobotNotice' &&
|
||||
state.algobot.form.message === 'No algobot found' &&
|
||||
algobot.name === ''
|
||||
) {
|
||||
return (
|
||||
<div
|
||||
class='section'
|
||||
key='algobotList2'
|
||||
class='is-marginless is-paddingless p-l-1 p-r-1'
|
||||
>
|
||||
<h2 class='title is-size-4 m-t-1'>Algobots</h2>
|
||||
<p class='is-size-5'>Algobot creation currently disabled</p>
|
||||
<div class='level m-t-2'>
|
||||
<div class='level-item'>
|
||||
<a
|
||||
class='button is-primary is-medium'
|
||||
disabled={true}
|
||||
onclick={() => actions.algobot.toggleModal('AddAlgobot')}
|
||||
>
|
||||
Create an algobot
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (
|
||||
(algobot.name !== '' && algobot.name !== null) ||
|
||||
state.algobot.form.form === 'deleteAlgobotSuccess'
|
||||
) {
|
||||
const initial = algobot.name.substring(0, 1)
|
||||
return (
|
||||
<div
|
||||
class='section'
|
||||
key='algobotList3'
|
||||
class='is-marginless is-paddingless'
|
||||
>
|
||||
<h2 class='title is-size-4 m-t-1'>Algobots</h2>
|
||||
<table class='table is-fullwidth is-striped is-narrow'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>Name</th>
|
||||
<th>Team</th>
|
||||
<th>Owner</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{algobot.name !== '' ? (
|
||||
<tr>
|
||||
<td>
|
||||
{algobot.avatar !== null && algobot.avatar !== '' ? (
|
||||
<div class='image is-16x16 avatar'>
|
||||
<img src={algobot.avatar} alt={algobot.name} />
|
||||
</div>
|
||||
) : (
|
||||
<div class='image is-16x16 avatar has-text-white is-uppercase is-green is-size-7 is-centered'>
|
||||
{initial}
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
<td class='is-size-6'>
|
||||
<strong>{algobot.name}</strong>
|
||||
</td>
|
||||
<td class='is-size-6'>{state.team.profile.name}</td>
|
||||
<td class='is-size-6'>{state.user.profile.username}</td>
|
||||
</tr>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
class='section'
|
||||
key='algobotList4'
|
||||
class='is-marginless is-paddingless'
|
||||
>
|
||||
<h2 class='title is-size-4 m-t-1'>Algobots</h2>
|
||||
<p class='is-size-4'>{state.algobot.form.message}</p>
|
||||
<div class='level m-t-2'>
|
||||
<div class='level-item'>
|
||||
<span class='icon has-text-primary is-large'>
|
||||
<i class='fas fa-spinner fa-pulse' />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default AlgobotPanel
|
||||
@@ -0,0 +1,5 @@
|
||||
import { AddAlgobotForm } from './add-algobot'
|
||||
import { AlgobotList } from './algobot-list'
|
||||
import { AlgobotPanel } from './algobot-panel'
|
||||
|
||||
export { AddAlgobotForm, AlgobotList, AlgobotPanel }
|
||||
@@ -0,0 +1,569 @@
|
||||
import { action, throttle, delay } from '@hyperapp/fx'
|
||||
|
||||
import { client } from '../../../index'
|
||||
import { UniqueUsernameQuery } from '../graphql/UniqueUsernameQuery'
|
||||
import { RegisterSubmitMutation } from '../graphql/RegisterSubmit'
|
||||
import { VerifyEmailMutation } from '../graphql/VerifyEmail'
|
||||
import { FinishRegisterMutation } from '../graphql/FinishRegisterMutation'
|
||||
import { ForgotPassSubmitMutation } from '../graphql/ForgotPass'
|
||||
import { ResetPassSubmitMutation } from '../graphql/ResetPass'
|
||||
|
||||
import { mergeDeep } from '../../../utils/js-helpers'
|
||||
|
||||
const emailRegex = new RegExp(
|
||||
"^[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?"
|
||||
)
|
||||
|
||||
export const auth = {
|
||||
form: ({ form, message }) => state => {
|
||||
return {
|
||||
form: {
|
||||
form,
|
||||
message
|
||||
}
|
||||
}
|
||||
},
|
||||
clearForms: () => ({
|
||||
form: {
|
||||
form: 'login',
|
||||
message: ''
|
||||
},
|
||||
username: {
|
||||
input: '',
|
||||
placeholder: 'Your username or email',
|
||||
valid: false
|
||||
},
|
||||
createUsername: {
|
||||
input: '',
|
||||
placeholder: 'Create a username',
|
||||
valid: false,
|
||||
unique: false
|
||||
},
|
||||
email: {
|
||||
input: '',
|
||||
placeholder: 'Your email address',
|
||||
valid: false
|
||||
},
|
||||
registerEmail: {
|
||||
input: ''
|
||||
},
|
||||
password: {
|
||||
input: '',
|
||||
placeholder: 'Your password',
|
||||
valid: false
|
||||
},
|
||||
createPassword: {
|
||||
input: '',
|
||||
placeholder: 'Your new password',
|
||||
secure: false,
|
||||
valid: false
|
||||
},
|
||||
confirmPassword: {
|
||||
input: '',
|
||||
placeholder: 'Confirm your password',
|
||||
matches: false,
|
||||
valid: false
|
||||
},
|
||||
forgotEmail: {
|
||||
input: '',
|
||||
placeholder: 'Enter your email address',
|
||||
valid: false
|
||||
},
|
||||
resetPassword: {
|
||||
input: '',
|
||||
placeholder: 'Set a new password',
|
||||
strength: '',
|
||||
valid: false
|
||||
},
|
||||
confirmResetPassword: {
|
||||
input: '',
|
||||
placeholder: 'Confirm your new password',
|
||||
matches: false,
|
||||
valid: false
|
||||
},
|
||||
finishRegister: {
|
||||
load: false,
|
||||
error: false,
|
||||
message: '',
|
||||
success: false
|
||||
}
|
||||
}),
|
||||
username: {
|
||||
input: value => state => {
|
||||
const usernameInput = {
|
||||
input: value
|
||||
}
|
||||
return mergeDeep(usernameInput, state.username)
|
||||
},
|
||||
error: message => state => {
|
||||
const errorInput = {
|
||||
message: message
|
||||
}
|
||||
return mergeDeep(errorInput, state.username)
|
||||
}
|
||||
},
|
||||
email: {
|
||||
input: value => state => {
|
||||
const emailInput = {
|
||||
input: value,
|
||||
valid: emailRegex.test(value)
|
||||
}
|
||||
return mergeDeep(emailInput, state.email)
|
||||
},
|
||||
sent: value => state => {
|
||||
const emailInput = {
|
||||
input: value
|
||||
}
|
||||
return mergeDeep(emailInput, state.email)
|
||||
}
|
||||
},
|
||||
registerEmail: {
|
||||
input: value => state => {
|
||||
const emailInput = {
|
||||
input: value
|
||||
}
|
||||
return mergeDeep(emailInput, state.registerEmail)
|
||||
}
|
||||
},
|
||||
password: {
|
||||
input: value => state => {
|
||||
const passwordInput = {
|
||||
input: value,
|
||||
valid: value !== ''
|
||||
}
|
||||
return mergeDeep(passwordInput, state.password)
|
||||
},
|
||||
error: message => state => {
|
||||
const errorInput = {
|
||||
message: message
|
||||
}
|
||||
return mergeDeep(errorInput, state.password)
|
||||
}
|
||||
},
|
||||
checkUsername: value => [
|
||||
action('throttleUsername', value),
|
||||
action('createUsername.input', value)
|
||||
],
|
||||
throttleUsername: value => throttle(750, 'uniqueUsername', value),
|
||||
uniqueUsername: value => async (state, actions) => {
|
||||
const result = await client.query({
|
||||
query: UniqueUsernameQuery,
|
||||
variables: { username: value }
|
||||
})
|
||||
|
||||
const unique = result.data.uniqueUsername
|
||||
if (unique) {
|
||||
return actions.setUsername(unique)
|
||||
} else {
|
||||
return actions.setUsernameError(unique)
|
||||
}
|
||||
},
|
||||
setUsername: value => [
|
||||
action('createUsername.setUnique', value),
|
||||
action('createUsername.error', '')
|
||||
],
|
||||
setUsernameError: value => [
|
||||
action('createUsername.setUnique', value),
|
||||
action('createUsername.error', 'This username already exists')
|
||||
],
|
||||
createUsername: {
|
||||
input: value => state => {
|
||||
const usernameInput = {
|
||||
input: value
|
||||
}
|
||||
return mergeDeep(usernameInput, state.createUsername)
|
||||
},
|
||||
setUnique: value => state => {
|
||||
const usernameInput = {
|
||||
unique: value
|
||||
}
|
||||
return mergeDeep(usernameInput, state.createUsername)
|
||||
},
|
||||
error: message => state => {
|
||||
const errorInput = {
|
||||
message: message
|
||||
}
|
||||
return mergeDeep(errorInput, state.createUsername)
|
||||
}
|
||||
},
|
||||
createPassword: {
|
||||
input: value => state => {
|
||||
let passStrength = 'weak'
|
||||
const strongRegex = new RegExp(
|
||||
'^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*])(?=.{10,})'
|
||||
)
|
||||
const mediumRegex = new RegExp(
|
||||
'^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,})'
|
||||
)
|
||||
if (mediumRegex.test(value)) {
|
||||
passStrength = 'medium'
|
||||
}
|
||||
if (strongRegex.test(value)) {
|
||||
passStrength = 'strong'
|
||||
}
|
||||
const passwordInput = {
|
||||
input: value,
|
||||
strength: passStrength
|
||||
}
|
||||
return mergeDeep(passwordInput, state.createPassword)
|
||||
},
|
||||
error: message => state => {
|
||||
const errorInput = {
|
||||
message: message
|
||||
}
|
||||
return mergeDeep(errorInput, state.createPassword)
|
||||
}
|
||||
},
|
||||
confirmPassword: {
|
||||
input: ({ value, confirm }) => state => {
|
||||
const passwordInput = {
|
||||
input: value,
|
||||
matches: value === confirm
|
||||
}
|
||||
return mergeDeep(passwordInput, state.confirmPassword)
|
||||
}
|
||||
},
|
||||
register: registerForm => [
|
||||
action('form', {
|
||||
form: 'registerLoad',
|
||||
message: 'Submitting registration...'
|
||||
}),
|
||||
action('registerSubmit', registerForm)
|
||||
],
|
||||
registerSubmit: registerForm => async (state, actions) => {
|
||||
registerForm.preventDefault()
|
||||
registerForm.target.blur()
|
||||
|
||||
const email = registerForm.target.form[0].value
|
||||
|
||||
if (!state.email.valid) {
|
||||
return action('form', {
|
||||
form: 'registerSignup',
|
||||
message: 'Please submit a valid email address'
|
||||
})
|
||||
}
|
||||
const result = await client.mutate({
|
||||
mutation: RegisterSubmitMutation,
|
||||
variables: { input: { email } }
|
||||
})
|
||||
|
||||
if (
|
||||
result.data.registerSubmit.user !== '' &&
|
||||
result.data.registerSubmit.user !== null
|
||||
) {
|
||||
return actions.registerSubmitSuccess(result)
|
||||
} else {
|
||||
return actions.form({
|
||||
form: 'registerError',
|
||||
message: result.data.registerSubmit.errors[0].message
|
||||
})
|
||||
}
|
||||
},
|
||||
registerSubmitSuccess: result => [
|
||||
action('form', {
|
||||
form: 'registerSuccess',
|
||||
message:
|
||||
'To continue registration, please check your email for further instructions'
|
||||
}),
|
||||
action('email.input', '')
|
||||
],
|
||||
verifyRegister: token => [
|
||||
action('form', { form: 'loading', message: 'Verifying registration...' }),
|
||||
action('verifyEmail', token)
|
||||
],
|
||||
verifyEmail: token => async (state, actions) => {
|
||||
const result = await client.mutate({
|
||||
mutation: VerifyEmailMutation,
|
||||
variables: { token: token }
|
||||
})
|
||||
|
||||
const email = await result.data.verifyEmail.user.email
|
||||
console.log('actions.auth.verifyEmail: ', email)
|
||||
if (email !== '' && email !== null) {
|
||||
return actions.verifySuccess(email)
|
||||
} else {
|
||||
return actions.form({
|
||||
form: 'error',
|
||||
message: `Could not verify token: ${
|
||||
result.data.verifyEmail.errors[0].message
|
||||
}`
|
||||
})
|
||||
}
|
||||
},
|
||||
verifySuccess: email => [
|
||||
action('registerEmail.input', email),
|
||||
action('form', {
|
||||
form: 'verifySuccess',
|
||||
message: 'Continue registration...'
|
||||
})
|
||||
],
|
||||
finishRegister: {
|
||||
load: value => state => {
|
||||
const newState = {
|
||||
load: value
|
||||
}
|
||||
return mergeDeep(newState, state.finishRegister)
|
||||
},
|
||||
error: value => state => {
|
||||
const newState = {
|
||||
error: value
|
||||
}
|
||||
return mergeDeep(newState, state.finishRegister)
|
||||
},
|
||||
message: value => state => {
|
||||
const newState = {
|
||||
message: value
|
||||
}
|
||||
return mergeDeep(newState, state.finishRegister)
|
||||
},
|
||||
success: value => state => {
|
||||
const newState = {
|
||||
success: value
|
||||
}
|
||||
return mergeDeep(newState, state.finishRegister)
|
||||
}
|
||||
},
|
||||
finish: registerForm => [
|
||||
action('finishRegister.load', true),
|
||||
action('finishRegister.message', 'Completing registration...'),
|
||||
action('finishSubmit', registerForm)
|
||||
],
|
||||
finishSubmit: registerForm => async (state, actions) => {
|
||||
registerForm.preventDefault()
|
||||
registerForm.target.blur()
|
||||
|
||||
const username = registerForm.target.form[0].value
|
||||
const password = registerForm.target.form[1].value
|
||||
const confirm = registerForm.target.form[2].value
|
||||
const email = registerForm.target.form[3].value
|
||||
console.log(
|
||||
'actions.auth.finishSubmit: ',
|
||||
username,
|
||||
password,
|
||||
confirm,
|
||||
email
|
||||
)
|
||||
|
||||
var checkUsername = await client.query({
|
||||
query: UniqueUsernameQuery,
|
||||
variables: { username: username }
|
||||
})
|
||||
|
||||
if (!checkUsername) {
|
||||
actions.finishRegister.load(false)
|
||||
actions.finishRegister.error(true)
|
||||
actions.finishRegister.message('Username already exist.')
|
||||
return false
|
||||
}
|
||||
|
||||
if (password !== confirm) {
|
||||
actions.finishRegister.load(false)
|
||||
actions.finishRegister.error(true)
|
||||
actions.finishRegister.message('Passwords do not match')
|
||||
actions.confirmPassword.input({ value: confirm, confirm: password })
|
||||
return false
|
||||
}
|
||||
|
||||
if (checkUsername && password === confirm) {
|
||||
const result = await client.mutate({
|
||||
mutation: FinishRegisterMutation,
|
||||
variables: { input: { username, email, password } }
|
||||
})
|
||||
if (result.data.finishRegister.user !== null) {
|
||||
actions.finishRegister.load(false)
|
||||
actions.finishRegister.error(false)
|
||||
actions.finishRegister.success(true)
|
||||
actions.finishRegister.message(
|
||||
'Registration complete. Logging you in...'
|
||||
)
|
||||
return actions.form({
|
||||
form: 'finishSuccess',
|
||||
message: 'Registration complete. Logging you in...'
|
||||
})
|
||||
} else {
|
||||
actions.finishRegister.load(false)
|
||||
actions.finishRegister.error(true)
|
||||
actions.finishRegister.message(
|
||||
`${result.data.finishRegister.errors[0].field}: ${
|
||||
result.data.finishRegister.errors[0].message
|
||||
}`
|
||||
)
|
||||
actions.confirmPassword.input({ value: confirm, confirm: password })
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
return state
|
||||
},
|
||||
finishSubmitError: result => [
|
||||
action('form', { form: 'finishError', message: `Error: ${result}` })
|
||||
],
|
||||
checkEmailUsername: value => [
|
||||
action('throttleUsername', value),
|
||||
action('createUsername.input', value)
|
||||
],
|
||||
throttleEmailUsername: value => throttle(750, 'uniqueUsername', value),
|
||||
forgotEmail: {
|
||||
input: value => state => {
|
||||
const usernameInput = {
|
||||
input: value
|
||||
}
|
||||
return mergeDeep(usernameInput, state.forgotEmail)
|
||||
},
|
||||
error: message => state => {
|
||||
const errorInput = {
|
||||
message: message
|
||||
}
|
||||
return mergeDeep(errorInput, state.forgotEmail)
|
||||
},
|
||||
valid: value => state => {
|
||||
const emailInput = {
|
||||
valid: emailRegex.test(value)
|
||||
}
|
||||
return mergeDeep(emailInput, state.forgotEmail)
|
||||
}
|
||||
},
|
||||
forgotPass: forgotPassForm => [
|
||||
action('form', {
|
||||
form: 'forgotPassLoad',
|
||||
message: 'Submitting password reset...'
|
||||
}),
|
||||
action('forgotPassSubmit', forgotPassForm)
|
||||
],
|
||||
forgotPassSubmit: forgotPassForm => async (state, actions) => {
|
||||
forgotPassForm.preventDefault()
|
||||
forgotPassForm.target.blur()
|
||||
|
||||
const email = forgotPassForm.target.form[0].value
|
||||
console.log('actions.auth.forgotPassSubmit: ', email)
|
||||
if (!emailRegex.test(email)) {
|
||||
return action('form', {
|
||||
form: 'registerSignup',
|
||||
message: 'Please submit a valid email address'
|
||||
})
|
||||
}
|
||||
const result = await client.mutate({
|
||||
mutation: ForgotPassSubmitMutation,
|
||||
variables: { input: { email: email } }
|
||||
})
|
||||
console.log('actions.auth.forgotPassSubmit 2: ', result)
|
||||
if (
|
||||
result.data.forgotPassword !== '' &&
|
||||
result.data.forgotPassword !== null
|
||||
) {
|
||||
if (result.data.forgotPassword === 'Success') {
|
||||
return actions.form({
|
||||
form: 'forgotPassSuccess',
|
||||
message: 'Please check your email for further instructions'
|
||||
})
|
||||
}
|
||||
return actions.form({
|
||||
form: 'forgotPassError',
|
||||
message: `Failed to reset password: ${result.data.forgotPassword}`
|
||||
})
|
||||
}
|
||||
},
|
||||
resetPassword: {
|
||||
input: value => state => {
|
||||
let passStrength = 'weak'
|
||||
const strongRegex = new RegExp(
|
||||
'^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.*[!@#$%^&*])(?=.{10,})'
|
||||
)
|
||||
const mediumRegex = new RegExp(
|
||||
'^(?=.*[a-z])(?=.*[A-Z])(?=.*[0-9])(?=.{8,})'
|
||||
)
|
||||
if (mediumRegex.test(value)) {
|
||||
passStrength = 'medium'
|
||||
}
|
||||
if (strongRegex.test(value)) {
|
||||
passStrength = 'strong'
|
||||
}
|
||||
const passwordInput = {
|
||||
input: value,
|
||||
strength: passStrength
|
||||
}
|
||||
return mergeDeep(passwordInput, state.resetPassword)
|
||||
},
|
||||
error: message => state => {
|
||||
const errorInput = {
|
||||
message: message
|
||||
}
|
||||
return mergeDeep(errorInput, state.resetPassword)
|
||||
}
|
||||
},
|
||||
confirmResetPassword: {
|
||||
input: ({ value, confirm }) => state => {
|
||||
const passwordInput = {
|
||||
input: value,
|
||||
matches: value === confirm
|
||||
}
|
||||
return mergeDeep(passwordInput, state.confirmResetPassword)
|
||||
}
|
||||
},
|
||||
resetPass: resetPassForm => [
|
||||
action('form', {
|
||||
form: 'resetPassLoad',
|
||||
message: 'Updating your password...'
|
||||
}),
|
||||
action('resetPassSubmit', resetPassForm)
|
||||
],
|
||||
resetPassSubmit: resetPassForm => async (state, actions) => {
|
||||
resetPassForm.preventDefault()
|
||||
resetPassForm.target.blur()
|
||||
|
||||
const password = resetPassForm.target.form[0].value
|
||||
const confirm = resetPassForm.target.form[1].value
|
||||
const token = resetPassForm.target.form[2].value
|
||||
console.log(
|
||||
'actions.auth.resetPassSubmit: ',
|
||||
password,
|
||||
confirm,
|
||||
token,
|
||||
resetPassForm
|
||||
)
|
||||
if (password !== confirm) {
|
||||
return action('form', {
|
||||
form: 'resetPassError',
|
||||
message: 'Passwords do not match'
|
||||
})
|
||||
}
|
||||
const result = await client.mutate({
|
||||
mutation: ResetPassSubmitMutation,
|
||||
variables: {
|
||||
input: {
|
||||
password: password,
|
||||
passwordConfirmation: confirm,
|
||||
token: token
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log('actions.auth.resetPassSubmit 2: ', result)
|
||||
if (
|
||||
result.data.resetPassword !== '' &&
|
||||
result.data.resetPassword !== null
|
||||
) {
|
||||
if (result.data.resetPassword.errors === null) {
|
||||
actions.form({
|
||||
form: 'resetPassDone',
|
||||
message: 'Redirecting to Login...'
|
||||
})
|
||||
return actions.delayResetRedirect()
|
||||
}
|
||||
return actions.form({
|
||||
form: 'resetPassError',
|
||||
message: `Failed to reset password: ${
|
||||
result.data.resetPassword.errors[0].message
|
||||
}`
|
||||
})
|
||||
}
|
||||
},
|
||||
delayResetRedirect: () => delay(3000, 'resetPassSuccess'),
|
||||
resetPassSuccess: resetPassForm => [
|
||||
action('form', {
|
||||
form: 'resetPassSuccess',
|
||||
message: 'Redirecting to Login...'
|
||||
})
|
||||
]
|
||||
}
|
||||
|
||||
export default auth
|
||||
@@ -0,0 +1,18 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const FinishRegisterMutation = gql`
|
||||
mutation finishRegister($input: RegisterUserInput!) {
|
||||
finishRegister(input: $input) {
|
||||
user {
|
||||
id
|
||||
email
|
||||
username
|
||||
}
|
||||
errors {
|
||||
field
|
||||
message
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
@@ -0,0 +1,8 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const ForgotPassSubmitMutation = gql`
|
||||
mutation forgotPassword($input: ForgotPasswordInput!) {
|
||||
forgotPassword(input: $input)
|
||||
}
|
||||
`
|
||||
@@ -0,0 +1,53 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const RegisterSubmitMutation = gql`
|
||||
mutation registerSubmit($input: RegisterSubmitInput!) {
|
||||
registerSubmit(input: $input) {
|
||||
user {
|
||||
id
|
||||
email
|
||||
}
|
||||
errors {
|
||||
field
|
||||
message
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const UserInfo = gql`
|
||||
fragment UserInfo on User {
|
||||
id
|
||||
username
|
||||
role
|
||||
isActive
|
||||
email
|
||||
profile {
|
||||
firstName
|
||||
lastName
|
||||
fullName
|
||||
}
|
||||
auth {
|
||||
certificate {
|
||||
serial
|
||||
}
|
||||
facebook {
|
||||
fbId
|
||||
displayName
|
||||
}
|
||||
google {
|
||||
googleId
|
||||
displayName
|
||||
}
|
||||
github {
|
||||
ghId
|
||||
displayName
|
||||
}
|
||||
linkedin {
|
||||
lnId
|
||||
displayName
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
@@ -0,0 +1,13 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const ResetPassSubmitMutation = gql`
|
||||
mutation resetPassword($input: ResetPasswordInput!) {
|
||||
resetPassword(input: $input) {
|
||||
errors {
|
||||
field
|
||||
message
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
@@ -0,0 +1,10 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const UniqueUsernameQuery = gql`
|
||||
query uniqueUsername($username: String!) {
|
||||
uniqueUsername(username: $username)
|
||||
}
|
||||
`
|
||||
|
||||
export default UniqueUsernameQuery
|
||||
@@ -0,0 +1,16 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const VerifyEmailMutation = gql`
|
||||
mutation verifyEmail($token: String!) {
|
||||
verifyEmail(token: $token) {
|
||||
user {
|
||||
email
|
||||
}
|
||||
errors {
|
||||
field
|
||||
message
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
Whitespace-only changes.
@@ -0,0 +1,67 @@
|
||||
export const auth = {
|
||||
form: {
|
||||
type: 'login',
|
||||
message: ''
|
||||
},
|
||||
username: {
|
||||
input: '',
|
||||
placeholder: 'Your username or email',
|
||||
valid: false
|
||||
},
|
||||
createUsername: {
|
||||
input: '',
|
||||
placeholder: 'Create a username',
|
||||
valid: false,
|
||||
unique: true
|
||||
},
|
||||
email: {
|
||||
input: '',
|
||||
placeholder: 'Your email address',
|
||||
valid: false
|
||||
},
|
||||
registerEmail: {
|
||||
input: ''
|
||||
},
|
||||
password: {
|
||||
input: '',
|
||||
placeholder: 'Your password',
|
||||
valid: false
|
||||
},
|
||||
createPassword: {
|
||||
input: '',
|
||||
placeholder: 'Your new password',
|
||||
strength: '',
|
||||
valid: false
|
||||
},
|
||||
confirmPassword: {
|
||||
input: '',
|
||||
placeholder: 'Confirm your password',
|
||||
matches: false,
|
||||
valid: false
|
||||
},
|
||||
forgotEmail: {
|
||||
input: '',
|
||||
placeholder: 'Enter your email address or username',
|
||||
valid: false
|
||||
},
|
||||
resetPassword: {
|
||||
input: '',
|
||||
placeholder: 'Set a new password',
|
||||
strength: '',
|
||||
valid: false
|
||||
},
|
||||
confirmResetPassword: {
|
||||
input: '',
|
||||
placeholder: 'Confirm your new password',
|
||||
matches: false,
|
||||
valid: false
|
||||
},
|
||||
finishRegister: {
|
||||
load: false,
|
||||
error: false,
|
||||
message: '',
|
||||
success: false
|
||||
}
|
||||
}
|
||||
|
||||
export default auth
|
||||
@@ -0,0 +1,261 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { h } from 'hyperapp'
|
||||
|
||||
export const FinishRegisterForm = props => (state, actions) => (
|
||||
<form name='finishRegisterForm' key='finishRegisterForm'>
|
||||
<div class='field'>
|
||||
<label class='label'>New Username:</label>
|
||||
<div class='control has-icons-left has-icons-right'>
|
||||
<input
|
||||
name='new-username'
|
||||
class='input'
|
||||
type='text'
|
||||
autocomplete='username'
|
||||
onupdate={(element, oldAttributes) => {
|
||||
if (
|
||||
oldAttributes.value !== element.value ||
|
||||
(oldAttributes.value !== '' && element.value === '')
|
||||
) {
|
||||
element.focus()
|
||||
}
|
||||
}}
|
||||
aria-label={state.auth.createUsername.placeholder}
|
||||
oninput={({ target: { value } }) => actions.auth.checkUsername(value)}
|
||||
onblur={({ target: { value } }) => actions.auth.checkUsername(value)}
|
||||
value={state.auth.createUsername.input}
|
||||
placeholder={state.auth.createUsername.placeholder}
|
||||
/>
|
||||
<span
|
||||
key='createUsernameUserIcon'
|
||||
class={`icon is-small is-left ${
|
||||
state.auth.createUsername.unique ? 'has-text-success' : ''
|
||||
}`}
|
||||
>
|
||||
<i class='fas fa-user' />
|
||||
</span>
|
||||
<span
|
||||
key='createUsernameCheckIcon'
|
||||
class={`icon is-small is-right ${
|
||||
state.auth.createUsername.unique ? 'has-text-success' : ''
|
||||
}`}
|
||||
>
|
||||
<i class='fas fa-check' />
|
||||
</span>
|
||||
<p
|
||||
key='createUsernameUniqueMessage'
|
||||
class={`m-t-1 has-text-centered ${
|
||||
state.auth.createUsername.input !== '' &&
|
||||
state.auth.createUsername.error !== null &&
|
||||
state.auth.createUsername.error !== '' &&
|
||||
!state.auth.createUsername.unique
|
||||
? 'has-text-danger'
|
||||
: 'is-invisible'
|
||||
}`}
|
||||
>
|
||||
This username is already taken. Please create a new one.
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class='field'>
|
||||
<label class='label'>New Password:</label>
|
||||
<div class='control has-icons-left has-icons-right'>
|
||||
<input
|
||||
name='new-password'
|
||||
class='input'
|
||||
type='password'
|
||||
autocomplete='new-password'
|
||||
onupdate={(element, oldAttributes) => {
|
||||
if (
|
||||
oldAttributes.value !== element.value ||
|
||||
(oldAttributes.value !== '' && element.value === '')
|
||||
) {
|
||||
element.focus()
|
||||
}
|
||||
}}
|
||||
aria-label={state.auth.createPassword.placeholder}
|
||||
oninput={({ target: { value } }) =>
|
||||
actions.auth.createPassword.input(value)
|
||||
}
|
||||
onblur={({ target: { value } }) =>
|
||||
actions.auth.createPassword.input(value)
|
||||
}
|
||||
value={state.auth.createPassword.input}
|
||||
placeholder={state.auth.createPassword.placeholder}
|
||||
/>
|
||||
<span
|
||||
key='createPasswordLockIcon'
|
||||
class={`icon is-small is-left
|
||||
${
|
||||
state.auth.createPassword.strength === 'weak'
|
||||
? 'has-text-danger'
|
||||
: ''
|
||||
}
|
||||
${
|
||||
state.auth.createPassword.strength === 'medium'
|
||||
? 'has-text-warning'
|
||||
: ''
|
||||
}
|
||||
${
|
||||
state.auth.createPassword.strength === 'strong'
|
||||
? 'has-text-success'
|
||||
: ''
|
||||
}
|
||||
`}
|
||||
>
|
||||
<i class='fas fa-lock' />
|
||||
</span>
|
||||
<span
|
||||
key='createPasswordCheckIcon'
|
||||
class={`icon is-small is-right ${
|
||||
state.auth.createPassword.strength === 'strong'
|
||||
? 'has-text-success'
|
||||
: ''
|
||||
}`}
|
||||
>
|
||||
<i class='fas fa-check' />
|
||||
</span>
|
||||
<p
|
||||
key='createPasswordStrengthMessage'
|
||||
class={`m-t-1 has-text-centered ${
|
||||
state.auth.createPassword.strength !== null &&
|
||||
state.auth.createPassword.input !== ''
|
||||
? 'has-text-primary'
|
||||
: 'is-invisible'
|
||||
}`}
|
||||
>
|
||||
Password strength is {state.auth.createPassword.strength}
|
||||
</p>
|
||||
<p
|
||||
key='createPasswordStrengthMessage2'
|
||||
class={`m-t-1 has-text-centered ${
|
||||
state.auth.createPassword.strength === 'weak' ||
|
||||
state.auth.createPassword.strength === 'medium'
|
||||
? 'has-text-primary'
|
||||
: 'is-invisible'
|
||||
}`}
|
||||
>
|
||||
<span class='is-italic is-size-6'>
|
||||
At least 10 characters, upper & lower case letters<br />+ a
|
||||
number + a special char [! @ # $ % ^ & *]
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class='field'>
|
||||
<label class='label'>Confirm Password:</label>
|
||||
<div class='control has-icons-left has-icons-right'>
|
||||
<input
|
||||
name='confirm-password'
|
||||
class='input'
|
||||
type='password'
|
||||
autocomplete='new-confirm-password'
|
||||
onupdate={(element, oldAttributes) => {
|
||||
if (
|
||||
oldAttributes.value !== element.value ||
|
||||
(oldAttributes.value !== '' && element.value === '')
|
||||
) {
|
||||
element.focus()
|
||||
}
|
||||
}}
|
||||
aria-label={state.auth.confirmPassword.placeholder}
|
||||
oninput={({ target: { value } }) =>
|
||||
actions.auth.confirmPassword.input({
|
||||
value: value,
|
||||
confirm: state.auth.createPassword.input
|
||||
})
|
||||
}
|
||||
onblur={({ target: { value } }) =>
|
||||
actions.auth.confirmPassword.input({
|
||||
value: value,
|
||||
confirm: state.auth.createPassword.input
|
||||
})
|
||||
}
|
||||
value={state.auth.confirmPassword.input}
|
||||
placeholder={state.auth.confirmPassword.placeholder}
|
||||
/>
|
||||
<span
|
||||
key='confirmPasswordLockIcon'
|
||||
class={`icon is-small is-left
|
||||
${
|
||||
state.auth.confirmPassword.strength === 'weak'
|
||||
? 'has-text-danger'
|
||||
: ''
|
||||
}
|
||||
${
|
||||
state.auth.confirmPassword.strength === 'medium'
|
||||
? 'has-text-warning'
|
||||
: ''
|
||||
}
|
||||
${
|
||||
state.auth.confirmPassword.strength === 'strong'
|
||||
? 'has-text-success'
|
||||
: ''
|
||||
}
|
||||
`}
|
||||
>
|
||||
<i class='fas fa-lock' />
|
||||
</span>
|
||||
<span
|
||||
key='confirmPasswordCheckIcon'
|
||||
class={`icon is-small is-right ${
|
||||
state.auth.confirmPassword.matches ? 'has-text-success' : ''
|
||||
}`}
|
||||
>
|
||||
<i class='fas fa-check' />
|
||||
</span>
|
||||
<p
|
||||
key='confirmPasswordMatchesMessage'
|
||||
class={`m-t-1 has-text-centered ${
|
||||
state.auth.confirmPassword.matches
|
||||
? 'has-text-primary'
|
||||
: 'is-invisible'
|
||||
}`}
|
||||
>
|
||||
Passwords match!
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<p
|
||||
key='finishRegisterMessage'
|
||||
class={`help
|
||||
${state.auth.finishRegister.success ? 'has-text-success' : ''}
|
||||
${state.auth.finishRegister.error ? 'has-text-danger' : ''}
|
||||
${state.auth.finishRegister.load ? 'has-text-primary' : ''}
|
||||
${
|
||||
(state.auth.finishRegister.load ||
|
||||
state.auth.finishRegister.error ||
|
||||
state.auth.finishRegister.success) &&
|
||||
state.auth.finishRegister.success !== ''
|
||||
? 'is-size-4 m-t-hlf m-b-hlf'
|
||||
: 'is-invisible'
|
||||
}`}
|
||||
>
|
||||
{state.auth.finishRegister.message}
|
||||
</p>
|
||||
<div class='control buttons is-centered'>
|
||||
<input
|
||||
type='hidden'
|
||||
name='email'
|
||||
value={state.auth.registerEmail.input}
|
||||
/>
|
||||
<button
|
||||
onclick={e => actions.auth.finish(e)}
|
||||
class={`button is-primary ${
|
||||
state.auth.finishRegister.load ? 'is-loading' : ''
|
||||
}`}
|
||||
aria-label='Finish Account Creation'
|
||||
disabled={
|
||||
!(
|
||||
state.auth.createUsername.unique &&
|
||||
state.auth.createPassword.strength === 'strong' &&
|
||||
state.auth.confirmPassword.matches
|
||||
)
|
||||
}
|
||||
>
|
||||
Finish Account Creation
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
)
|
||||
|
||||
export default FinishRegisterForm
|
||||
@@ -0,0 +1,79 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { h } from 'hyperapp'
|
||||
import { Link } from '@hyperapp/router'
|
||||
|
||||
export const ForgotPassForm = props => (state, actions) => (
|
||||
<form name='forgotPassForm' key='forgotPassForm'>
|
||||
<div class='field'>
|
||||
<label class='label'>Enter your Email Address</label>
|
||||
<div class='control has-icons-left has-icons-right'>
|
||||
<input
|
||||
class='input'
|
||||
type='text'
|
||||
onupdate={(element, oldAttributes) => {
|
||||
if (
|
||||
oldAttributes.value !== element.value ||
|
||||
(oldAttributes.value !== '' && element.value === '')
|
||||
) {
|
||||
element.focus()
|
||||
}
|
||||
}}
|
||||
aria-label={state.auth.forgotEmail.placeholder}
|
||||
oninput={({ target: { value } }) =>
|
||||
actions.auth.forgotEmail.input(value)
|
||||
}
|
||||
value={state.auth.forgotEmail.input}
|
||||
placeholder={state.auth.forgotEmail.placeholder}
|
||||
/>
|
||||
<span
|
||||
class={`icon is-small is-left ${
|
||||
state.auth.forgotEmail.valid ? 'has-text-success' : ''
|
||||
}`}
|
||||
>
|
||||
<i class='fas fa-user' />
|
||||
</span>
|
||||
<span
|
||||
class={`icon is-small is-right ${
|
||||
state.auth.forgotEmail.valid
|
||||
? 'has-text-success'
|
||||
: 'has-text-light-grey'
|
||||
}`}
|
||||
>
|
||||
<i class='fas fa-check' />
|
||||
</span>
|
||||
</div>
|
||||
<p
|
||||
class={`help is-size-4 m-t-hlf m-b-hlf
|
||||
${state.auth.form.form === 'forgotPassLoad' ? 'is-primary' : ''}
|
||||
${state.auth.form.form === 'forgotPassSuccess' ? 'is-success' : ''}
|
||||
${state.auth.form.form === 'forgotPassError' ? 'is-danger' : ''}
|
||||
${
|
||||
state.auth.form.form === 'forgotPassLoad' ||
|
||||
state.auth.form.form === 'forgotPassSuccess' ||
|
||||
state.auth.form.form === 'forgotPassError'
|
||||
? ''
|
||||
: 'is-invisible'
|
||||
}`}
|
||||
>
|
||||
{state.auth.form.message}
|
||||
</p>
|
||||
</div>
|
||||
<div class='control'>
|
||||
<button
|
||||
onclick={e => actions.auth.forgotPass(e)}
|
||||
class={`button is-primary ${
|
||||
state.auth.form.form === 'forgotPassLoad' ? 'is-loading' : ''
|
||||
}`}
|
||||
aria-label='Send New Password'
|
||||
disabled={state.auth.form.form === 'forgotPassLoad'}
|
||||
>
|
||||
Submit
|
||||
</button>
|
||||
<Link to='/login' class='is-link is-size-6 is-pulled-right'>
|
||||
Back to Login →
|
||||
</Link>
|
||||
</div>
|
||||
</form>
|
||||
)
|
||||
|
||||
export default ForgotPassForm
|
||||
@@ -0,0 +1,13 @@
|
||||
import LoginForm from './login'
|
||||
import RegisterForm from './register'
|
||||
import FinishRegisterForm from './finish-register'
|
||||
import ForgotPassForm from './forgot-pass-form'
|
||||
import ResetPassForm from './reset-pass-form'
|
||||
|
||||
export {
|
||||
LoginForm,
|
||||
RegisterForm,
|
||||
FinishRegisterForm,
|
||||
ForgotPassForm,
|
||||
ResetPassForm
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { h } from 'hyperapp'
|
||||
import { Link } from '@hyperapp/router'
|
||||
|
||||
export const LoginForm = props => (state, actions) => (
|
||||
<form name='loginForm' key='LoginForm'>
|
||||
<div class='field'>
|
||||
<label class='label'>Username or Email</label>
|
||||
<div class='control has-icons-left has-icons-right'>
|
||||
<input
|
||||
class='input'
|
||||
type='text'
|
||||
autocomplete='username'
|
||||
onupdate={(element, oldAttributes) => {
|
||||
if (
|
||||
oldAttributes.value !== element.value ||
|
||||
(oldAttributes.value !== '' && element.value === '')
|
||||
) {
|
||||
element.focus()
|
||||
}
|
||||
}}
|
||||
aria-label={state.auth.username.placeholder}
|
||||
oninput={({ target: { value } }) =>
|
||||
actions.auth.username.input(value)
|
||||
}
|
||||
value={state.auth.username.input}
|
||||
placeholder={state.auth.username.placeholder}
|
||||
/>
|
||||
<span class='icon is-small is-left'>
|
||||
<i class='fas fa-user' />
|
||||
</span>
|
||||
<span class='icon is-small is-right is-invisible'>
|
||||
<i class='fas fa-check' />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class='field'>
|
||||
<label class='label'>Password</label>
|
||||
<div class='control has-icons-left has-icons-right'>
|
||||
<input
|
||||
class='input'
|
||||
type='password'
|
||||
autocomplete='current-password'
|
||||
onupdate={(element, oldAttributes) => {
|
||||
if (
|
||||
oldAttributes.value !== element.value ||
|
||||
(oldAttributes.value !== '' && element.value === '')
|
||||
) {
|
||||
element.focus()
|
||||
}
|
||||
}}
|
||||
aria-label={state.auth.password.placeholder}
|
||||
oninput={({ target: { value } }) =>
|
||||
actions.auth.password.input(value)
|
||||
}
|
||||
value={state.auth.password.input}
|
||||
placeholder={state.auth.password.placeholder}
|
||||
/>
|
||||
<span class='icon is-small is-left'>
|
||||
<i class='fas fa-lock' />
|
||||
</span>
|
||||
<span
|
||||
class={`icon is-small is-right ${
|
||||
state.user.form.form === 'loginError' ? '' : 'is-invisible'
|
||||
}`}
|
||||
>
|
||||
<i class='fas fa-exclamation-triangle' />
|
||||
</span>
|
||||
</div>
|
||||
<p
|
||||
key='loginMessage'
|
||||
class={`help is-size-4 m-t-hlf m-b-hlf
|
||||
${state.user.form.form === 'loginSuccess' ? 'has-text-success' : ''}
|
||||
${state.user.form.form === 'loginNotice' ? 'has-text-primary' : ''}
|
||||
${state.user.form.form === 'loginError' ? 'has-text-danger' : ''}
|
||||
${
|
||||
state.user.form.form === 'loginSuccess' ||
|
||||
state.user.form.form === 'loginNotice' ||
|
||||
state.user.form.form === 'loginError'
|
||||
? ''
|
||||
: 'is-invisible'
|
||||
}`}
|
||||
>
|
||||
{state.user.form.message}
|
||||
</p>
|
||||
</div>
|
||||
<div class='control'>
|
||||
<button onclick={e => actions.user.loginSubmit(e)} class='button is-link'>
|
||||
Submit
|
||||
</button>
|
||||
<Link to='/forgot-pass' class='is-link is-size-6 is-pulled-right'>
|
||||
Forgot password?
|
||||
</Link>
|
||||
</div>
|
||||
</form>
|
||||
)
|
||||
|
||||
export default LoginForm
|
||||
@@ -0,0 +1,71 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { h } from 'hyperapp'
|
||||
|
||||
export const RegisterForm = props => (state, actions) => (
|
||||
<form name='registerForm' key='registerForm'>
|
||||
<div class='field'>
|
||||
<label class='label'>Email Address</label>
|
||||
<div class='control has-icons-left has-icons-right'>
|
||||
<input
|
||||
class='input'
|
||||
type='text'
|
||||
onupdate={(element, oldAttributes) => {
|
||||
if (
|
||||
oldAttributes.value !== element.value ||
|
||||
(oldAttributes.value !== '' && element.value === '')
|
||||
) {
|
||||
element.focus()
|
||||
}
|
||||
}}
|
||||
aria-label={state.auth.email.placeholder}
|
||||
oninput={({ target: { value } }) => actions.auth.email.input(value)}
|
||||
value={state.auth.email.input}
|
||||
placeholder={state.auth.email.placeholder}
|
||||
/>
|
||||
<span
|
||||
class={`icon is-small is-left ${
|
||||
state.auth.email.valid ? 'has-text-success' : ''
|
||||
}`}
|
||||
>
|
||||
<i class='fas fa-user' />
|
||||
</span>
|
||||
<span
|
||||
class={`icon is-small is-right ${
|
||||
state.auth.email.valid ? 'has-text-success' : 'has-text-light-grey'
|
||||
}`}
|
||||
>
|
||||
<i class='fas fa-check' />
|
||||
</span>
|
||||
</div>
|
||||
<p
|
||||
class={`help is-size-4 m-t-hlf m-b-hlf
|
||||
${state.auth.form.form === 'registerLoad' ? 'is-primary' : ''}
|
||||
${state.auth.form.form === 'registerSuccess' ? 'is-success' : ''}
|
||||
${state.auth.form.form === 'registerError' ? 'is-danger' : ''}
|
||||
${
|
||||
state.auth.form.form === 'registerLoad' ||
|
||||
state.auth.form.form === 'registerSuccess' ||
|
||||
state.auth.form.form === 'registerError'
|
||||
? ''
|
||||
: 'is-invisible'
|
||||
}`}
|
||||
>
|
||||
{state.auth.form.message}
|
||||
</p>
|
||||
</div>
|
||||
<div class='control buttons is-centered'>
|
||||
<button
|
||||
onclick={e => actions.auth.register(e)}
|
||||
class={`button is-primary ${
|
||||
state.auth.form.form === 'registerLoad' ? 'is-loading' : ''
|
||||
}`}
|
||||
aria-label='Register'
|
||||
disabled={state.auth.form.form === 'registerLoad'}
|
||||
>
|
||||
Register
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
)
|
||||
|
||||
export default RegisterForm
|
||||
@@ -0,0 +1,200 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { h } from 'hyperapp'
|
||||
|
||||
export const ResetPassForm = ({ token }) => (state, actions) => (
|
||||
<form name='resetPassForm' key='resetPassForm'>
|
||||
<div class='field'>
|
||||
<label class='label'>New Password:</label>
|
||||
<div class='control has-icons-left has-icons-right'>
|
||||
<input
|
||||
name='new-password'
|
||||
class='input'
|
||||
type='password'
|
||||
autocomplete='new-password'
|
||||
onupdate={(element, oldAttributes) => {
|
||||
if (
|
||||
oldAttributes.value !== element.value ||
|
||||
(oldAttributes.value !== '' && element.value === '')
|
||||
) {
|
||||
element.focus()
|
||||
}
|
||||
}}
|
||||
aria-label={state.auth.resetPassword.placeholder}
|
||||
oninput={({ target: { value } }) =>
|
||||
actions.auth.resetPassword.input(value)
|
||||
}
|
||||
onblur={({ target: { value } }) =>
|
||||
actions.auth.resetPassword.input(value)
|
||||
}
|
||||
value={state.auth.resetPassword.input}
|
||||
placeholder={state.auth.resetPassword.placeholder}
|
||||
/>
|
||||
<span
|
||||
key='resetPasswordLockIcon'
|
||||
class={`icon is-small is-left
|
||||
${
|
||||
state.auth.resetPassword.strength === 'weak'
|
||||
? 'has-text-danger'
|
||||
: ''
|
||||
}
|
||||
${
|
||||
state.auth.resetPassword.strength === 'medium'
|
||||
? 'has-text-warning'
|
||||
: ''
|
||||
}
|
||||
${
|
||||
state.auth.resetPassword.strength === 'strong'
|
||||
? 'has-text-success'
|
||||
: ''
|
||||
}
|
||||
`}
|
||||
>
|
||||
<i class='fas fa-lock' />
|
||||
</span>
|
||||
<span
|
||||
key='resetPasswordCheckIcon'
|
||||
class={`icon is-small is-right ${
|
||||
state.auth.resetPassword.strength === 'strong'
|
||||
? 'has-text-success'
|
||||
: ''
|
||||
}`}
|
||||
>
|
||||
<i class='fas fa-check' />
|
||||
</span>
|
||||
<p
|
||||
key='resetPasswordStrengthMessage'
|
||||
class={`${
|
||||
state.auth.resetPassword.strength !== null &&
|
||||
state.auth.resetPassword.input !== ''
|
||||
? 'm-t-1 has-text-centered has-text-primary'
|
||||
: 'is-invisible'
|
||||
}`}
|
||||
>
|
||||
Password strength is {state.auth.resetPassword.strength}
|
||||
</p>
|
||||
<p
|
||||
key='resetPasswordStrengthMessage2'
|
||||
class={`${
|
||||
state.auth.resetPassword.strength === 'weak' ||
|
||||
state.auth.resetPassword.strength === 'medium'
|
||||
? 'm-t-1 has-text-centered has-text-primary'
|
||||
: 'is-invisible'
|
||||
}`}
|
||||
>
|
||||
<span class='is-italic is-size-6'>
|
||||
At least 10 characters, upper & lower case letters<br />+ a
|
||||
number + a special char [! @ # $ % ^ & *]
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class='field'>
|
||||
<label class='label'>Confirm Password:</label>
|
||||
<div class='control has-icons-left has-icons-right'>
|
||||
<input
|
||||
name='confirm-password'
|
||||
class='input'
|
||||
type='password'
|
||||
autocomplete='new-confirm-password'
|
||||
onupdate={(element, oldAttributes) => {
|
||||
if (
|
||||
oldAttributes.value !== element.value ||
|
||||
(oldAttributes.value !== '' && element.value === '')
|
||||
) {
|
||||
element.focus()
|
||||
}
|
||||
}}
|
||||
aria-label={state.auth.confirmResetPassword.placeholder}
|
||||
oninput={({ target: { value } }) =>
|
||||
actions.auth.confirmResetPassword.input({
|
||||
value: value,
|
||||
confirm: state.auth.resetPassword.input
|
||||
})
|
||||
}
|
||||
onblur={({ target: { value } }) =>
|
||||
actions.auth.confirmResetPassword.input({
|
||||
value: value,
|
||||
confirm: state.auth.resetPassword.input
|
||||
})
|
||||
}
|
||||
value={state.auth.confirmResetPassword.input}
|
||||
placeholder={state.auth.confirmResetPassword.placeholder}
|
||||
/>
|
||||
<span
|
||||
key='confirmResetPasswordLockIcon'
|
||||
class={`icon is-small is-left
|
||||
${
|
||||
state.auth.confirmResetPassword.strength === 'weak'
|
||||
? 'has-text-danger'
|
||||
: ''
|
||||
}
|
||||
${
|
||||
state.auth.confirmResetPassword.strength === 'medium'
|
||||
? 'has-text-warning'
|
||||
: ''
|
||||
}
|
||||
${
|
||||
state.auth.confirmResetPassword.strength === 'strong'
|
||||
? 'has-text-success'
|
||||
: ''
|
||||
}
|
||||
`}
|
||||
>
|
||||
<i class='fas fa-lock' />
|
||||
</span>
|
||||
<span
|
||||
key='confirmResetPasswordCheckIcon'
|
||||
class={`icon is-small is-right ${
|
||||
state.auth.confirmResetPassword.matches ? 'has-text-success' : ''
|
||||
}`}
|
||||
>
|
||||
<i class='fas fa-check' />
|
||||
</span>
|
||||
<p
|
||||
key='confirmResetPasswordMatchesMessage'
|
||||
class={`${
|
||||
state.auth.confirmResetPassword.matches
|
||||
? 'm-t-1 has-text-centered has-text-primary'
|
||||
: 'is-invisible'
|
||||
}`}
|
||||
>
|
||||
Passwords match!
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<p
|
||||
key='resetPassMessage'
|
||||
class={`help
|
||||
${state.auth.form.form === 'resetPassDone' ? 'has-text-success' : ''}
|
||||
${state.auth.form.form === 'resetPassError' ? 'has-text-danger' : ''}
|
||||
${
|
||||
state.auth.form.form === 'resetPassDone' ||
|
||||
state.auth.form.form === 'resetPassError' ||
|
||||
state.auth.form.form === 'resetPassLoad'
|
||||
? ' is-size-4 m-t-hlf m-b-hlf has-text-centered'
|
||||
: 'is-invisible'
|
||||
}`}
|
||||
>
|
||||
{state.auth.form.message}
|
||||
</p>
|
||||
<div class='control buttons is-centered'>
|
||||
<input type='hidden' name='token' value={token} />
|
||||
<button
|
||||
onclick={e => actions.auth.resetPass(e)}
|
||||
class={`button is-primary ${
|
||||
state.auth.form.form === 'resetPassLoad' ? 'is-loading' : ''
|
||||
}`}
|
||||
disabled={
|
||||
!(
|
||||
state.auth.resetPassword.strength === 'strong' &&
|
||||
state.auth.confirmResetPassword.matches
|
||||
)
|
||||
}
|
||||
>
|
||||
Reset Password
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
)
|
||||
|
||||
export default ResetPassForm
|
||||
@@ -0,0 +1,94 @@
|
||||
import { action } from '@hyperapp/fx'
|
||||
|
||||
import { GetAllTeamsQuery } from '../graphql/GetAllTeamsQuery'
|
||||
import { GetAllAlgobotsQuery } from '../graphql/GetAllAlgobotsQuery'
|
||||
|
||||
import { client } from '../../../index'
|
||||
|
||||
export const community = {
|
||||
form: ({ form, message }) => state => {
|
||||
return {
|
||||
form: {
|
||||
form,
|
||||
message
|
||||
}
|
||||
}
|
||||
},
|
||||
clearForms: () => ({
|
||||
form: {
|
||||
form: 'login',
|
||||
message: ''
|
||||
}
|
||||
}),
|
||||
toggleModal: form => (state, actions) => {
|
||||
return {
|
||||
modal: {
|
||||
content: form,
|
||||
isActive: !state.modal.isActive
|
||||
}
|
||||
}
|
||||
},
|
||||
teams: teams => ({ teams }),
|
||||
algobots: algobots => ({ algobots }),
|
||||
getTeams: id => [
|
||||
action('form', {
|
||||
form: 'getTeamsLoad',
|
||||
message: 'Getting community teams...'
|
||||
}),
|
||||
action('getAllTeams')
|
||||
],
|
||||
getAllTeams: () => async (state, actions) => {
|
||||
const result = await client.query({
|
||||
query: GetAllTeamsQuery,
|
||||
variables: { limit: 10, after: 0 },
|
||||
fetchPolicy: 'network-only'
|
||||
})
|
||||
console.log(result.data.teams)
|
||||
if (result.data.teams.edges.length > 0) {
|
||||
return actions.getAllTeamsSuccess(result.data.teams)
|
||||
} else {
|
||||
return actions.noTeams()
|
||||
}
|
||||
},
|
||||
getAllTeamsSuccess: teams => [
|
||||
action('form', { form: 'getAllTeamsSuccess', message: 'Community Teams' }),
|
||||
action('teams', teams)
|
||||
],
|
||||
noTeams: profile => [
|
||||
action('form', { form: 'getAlgobotsNotice', message: 'No teams found' }),
|
||||
action('teams', [])
|
||||
],
|
||||
getAlgobots: id => [
|
||||
action('form', {
|
||||
form: 'getAlgobotsLoad',
|
||||
message: 'Getting community algobots...'
|
||||
}),
|
||||
action('getAllAlgobots', id)
|
||||
],
|
||||
getAllAlgobots: () => async (state, actions) => {
|
||||
const result = await client.query({
|
||||
query: GetAllAlgobotsQuery,
|
||||
variables: { limit: 10, after: 0 },
|
||||
fetchPolicy: 'network-only'
|
||||
})
|
||||
console.log(result.data.getAlgobots)
|
||||
if (result.data.getAlgobots !== null) {
|
||||
return actions.getAllAlgobotsSuccess(result.data.getAlgobots)
|
||||
} else {
|
||||
return actions.noAlgobots()
|
||||
}
|
||||
},
|
||||
getAllAlgobotsSuccess: algobots => [
|
||||
action('form', {
|
||||
form: 'getAlgobotSuccess',
|
||||
message: 'Community Algobots'
|
||||
}),
|
||||
action('algobots', algobots)
|
||||
],
|
||||
noAlgobots: profile => [
|
||||
action('form', { form: 'getAlgobotsNotice', message: 'No algobots found' }),
|
||||
action('algobots', [])
|
||||
]
|
||||
}
|
||||
|
||||
export default community
|
||||
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const GetAllAlgobotsQuery = gql`
|
||||
query algobots($limit: Int!, $after: Int) {
|
||||
algobots(limit: $limit, after: $after) {
|
||||
totalCount
|
||||
edges {
|
||||
cursor
|
||||
node {
|
||||
id
|
||||
name
|
||||
slug
|
||||
owner
|
||||
avatar
|
||||
repo
|
||||
team_id
|
||||
type
|
||||
}
|
||||
}
|
||||
pageInfo {
|
||||
endCursor
|
||||
hasNextPage
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export default GetAllAlgobotsQuery
|
||||
@@ -0,0 +1,40 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const GetAllTeamsQuery = gql`
|
||||
query teamsQuery {
|
||||
teams {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
name
|
||||
slug
|
||||
profile {
|
||||
avatar
|
||||
description
|
||||
motto
|
||||
}
|
||||
owner {
|
||||
nickname
|
||||
visible
|
||||
profile {
|
||||
avatar
|
||||
}
|
||||
}
|
||||
members {
|
||||
role
|
||||
member {
|
||||
nickname
|
||||
visible
|
||||
profile {
|
||||
avatar
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export default GetAllTeamsQuery
|
||||
Whitespace-only changes.
@@ -0,0 +1,15 @@
|
||||
export const community = {
|
||||
form: {
|
||||
form: 'login',
|
||||
message: ''
|
||||
},
|
||||
filter: {},
|
||||
teams: [],
|
||||
algobots: [],
|
||||
modal: {
|
||||
content: 'AddAlgobot',
|
||||
isActive: false
|
||||
}
|
||||
}
|
||||
|
||||
export default community
|
||||
@@ -0,0 +1,141 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { h } from 'hyperapp'
|
||||
import { Link } from '@hyperapp/router'
|
||||
|
||||
export const AlgobotsList = props => (state, actions) => {
|
||||
const algobot = state.algobot.profile
|
||||
console.log(state.algobot.form.form, state.algobot.form.message, algobot.name)
|
||||
|
||||
if (
|
||||
state.algobot.form.form === 'getAlgobotNotice' &&
|
||||
state.algobot.form.message === 'No algobot found' &&
|
||||
algobot.name === ''
|
||||
) {
|
||||
return (
|
||||
<div class='section' key='algobotsList2'>
|
||||
<p class='is-size-4'>You don't have an algobot yet!</p>
|
||||
<div class='level m-t-2'>
|
||||
<div class='level-item'>
|
||||
<a
|
||||
class='button is-primary is-medium'
|
||||
onclick={() => actions.algobot.toggleModal('AddAlgobot')}
|
||||
>
|
||||
Create an algobot
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (
|
||||
(algobot.name !== '' && algobot.name !== null) ||
|
||||
state.algobot.form.form === 'deleteAlgobotSuccess'
|
||||
) {
|
||||
const initial = algobot.name.substring(0, 1)
|
||||
return (
|
||||
<div class='section' key='algobotsList3'>
|
||||
<p
|
||||
class={`is-size-5 card-footer-item
|
||||
${
|
||||
state.algobot.form.form === 'deleteAlgobotSuccess'
|
||||
? 'has-text-success'
|
||||
: ''
|
||||
}
|
||||
${
|
||||
state.algobot.form.form === 'deleteAlgobotNotice'
|
||||
? 'has-text-primary'
|
||||
: ''
|
||||
}
|
||||
${
|
||||
state.algobot.form.form === 'deleteAlgobotError'
|
||||
? 'has-text-danger'
|
||||
: ''
|
||||
}
|
||||
${
|
||||
state.algobot.form.form === 'deleteAlgobotSuccess' ||
|
||||
state.algobot.form.form === 'deleteAlgobotNotice' ||
|
||||
state.algobot.form.form === 'deleteAlgobotError'
|
||||
? ''
|
||||
: 'is-invisible'
|
||||
}`}
|
||||
>
|
||||
{state.algobot.form.message}
|
||||
</p>
|
||||
<table class='table is-fullwidth is-striped'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>Algobot Name</th>
|
||||
<th>Team</th>
|
||||
<th>Type</th>
|
||||
<th>Owner</th>
|
||||
<th>Repo</th>
|
||||
<th class='has-text-right'>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{algobot.name !== '' ? (
|
||||
<tr>
|
||||
<td>
|
||||
{algobot.avatar !== null && algobot.avatar !== '' ? (
|
||||
<div class='image is-16x16 avatar'>
|
||||
<img src={algobot.avatar} alt={algobot.name} />
|
||||
</div>
|
||||
) : (
|
||||
<div class='image is-16x16 avatar has-text-white is-uppercase is-green is-size-7 is-centered'>
|
||||
{initial}
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<strong>{algobot.name}</strong>
|
||||
</td>
|
||||
<td>{state.team.profile.name}</td>
|
||||
<td />
|
||||
<td>{state.user.profile.username}</td>
|
||||
<td />
|
||||
<td class='has-text-right'>
|
||||
<button
|
||||
onclick={e =>
|
||||
actions.algobot.deleteAlgobot(
|
||||
state.algobot.profile.id,
|
||||
state.algobot.profile.owner
|
||||
)
|
||||
}
|
||||
class='button is-small is-red'
|
||||
disabled={
|
||||
state.algobot.form.form === 'getAlgobotNotice' &&
|
||||
state.algobot.form.message === 'Removing your algobot...'
|
||||
}
|
||||
>
|
||||
<span class='icon'>
|
||||
<i class='fas fa-trash-alt' />
|
||||
</span>
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
) : (
|
||||
''
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div class='section' key='algobotsList4'>
|
||||
<p class='is-size-4'>{state.algobot.form.message}</p>
|
||||
<div class='level m-t-2'>
|
||||
<div class='level-item'>
|
||||
<span class='icon has-text-primary is-large'>
|
||||
<i class='fas fa-spinner fa-pulse' />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default AlgobotsList
|
||||
@@ -0,0 +1,5 @@
|
||||
import { AlgobotsList } from './algobots-list'
|
||||
import { TeamsList } from './teams-list'
|
||||
import { TeamsListWrapper } from './teams-list-wrapper'
|
||||
|
||||
export { AlgobotsList, TeamsList, TeamsListWrapper }
|
||||
@@ -0,0 +1,29 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { h } from 'hyperapp'
|
||||
|
||||
export const TeamsItem = ({ team }) => (
|
||||
<tr>
|
||||
<td>
|
||||
{team.profile !== null && team.profile.avatar !== '' ? (
|
||||
<div class='image is-16x16 avatar'>
|
||||
<img src={team.profile.avatar} alt={team.name} />
|
||||
</div>
|
||||
) : (
|
||||
<div class='image is-16x16 avatar has-text-white is-uppercase is-green is-size-7 is-centered'>
|
||||
{team.name.substring(0, 1)}
|
||||
</div>
|
||||
)}
|
||||
</td>
|
||||
<td>
|
||||
<strong>{team.name}</strong>
|
||||
</td>
|
||||
<td>
|
||||
<strong>{team.owner.nickname}</strong>
|
||||
</td>
|
||||
<td>
|
||||
<strong>{team.members.length}</strong>
|
||||
</td>
|
||||
</tr>
|
||||
)
|
||||
|
||||
export default TeamsItem
|
||||
@@ -0,0 +1,25 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { h } from 'hyperapp'
|
||||
|
||||
import { TeamsList } from './teams-list'
|
||||
|
||||
export const TeamsListWrapper = () => (state, actions) => (
|
||||
<section
|
||||
class='section has-text-centered p-l-3 p-r-3'
|
||||
key='DashboardContainer'
|
||||
oncreate={() => actions.community.getTeams()}
|
||||
>
|
||||
<div class='section m-b-0'>
|
||||
<div class='card'>
|
||||
<div class='card-content has-text-centered'>
|
||||
<h1 class='title has-text-centered is-uppercase is-condensed is-size-3'>
|
||||
Community Teams
|
||||
</h1>
|
||||
<TeamsList />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
)
|
||||
|
||||
export default TeamsListWrapper
|
||||
@@ -0,0 +1,73 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { h } from 'hyperapp'
|
||||
import { Link } from '@hyperapp/router'
|
||||
|
||||
import { TeamsItem } from './teams-item'
|
||||
|
||||
import { validObject } from '../../../utils/js-helpers'
|
||||
|
||||
export const TeamsList = props => (state, actions) => {
|
||||
const teams = validObject(state.community.teams, 'edges') ? state.community.teams.edges : ''
|
||||
console.log(state.community.form.form, state.community.form.message)
|
||||
|
||||
if (
|
||||
state.community.teams.length > 0 ||
|
||||
state.community.form.form === 'getAllTeamsSuccess'
|
||||
) {
|
||||
return (
|
||||
<div class='section' key='teamsList3'>
|
||||
<p
|
||||
class={`is-size-5 card-footer-item
|
||||
${
|
||||
state.community.form.form === 'getAllTeamsNotice'
|
||||
? 'has-text-primary'
|
||||
: ''
|
||||
}
|
||||
${
|
||||
state.community.form.form === 'getAllTeamsError'
|
||||
? 'has-text-danger'
|
||||
: ''
|
||||
}
|
||||
${
|
||||
state.community.form.form === 'getAllTeamsNotice' ||
|
||||
state.community.form.form === 'getAllTeamsError'
|
||||
? ''
|
||||
: 'is-invisible'
|
||||
}`}
|
||||
>
|
||||
{state.community.form.message}
|
||||
</p>
|
||||
<table class='table is-fullwidth is-striped'>
|
||||
<thead>
|
||||
<tr>
|
||||
<th> </th>
|
||||
<th>Team Name</th>
|
||||
<th>Team Owner</th>
|
||||
<th># of Members</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{teams.map((team, i) => (
|
||||
<TeamsItem team={team.node} key={`team-item-${team.node.id}`} />
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div class='section' key='teamsList4'>
|
||||
<p class='is-size-4'>{state.community.form.message}</p>
|
||||
<div class='level m-t-2'>
|
||||
<div class='level-item'>
|
||||
<span class='icon has-text-primary is-large'>
|
||||
<i class='fas fa-spinner fa-pulse' />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default TeamsList
|
||||
@@ -0,0 +1,16 @@
|
||||
import { mergeDeep } from '../../../utils/js-helpers'
|
||||
|
||||
export const nav = {
|
||||
top: {
|
||||
toggleMobileMenu: () => state => {
|
||||
const menu = { mobileMenu: !state.mobileMenu }
|
||||
return mergeDeep(menu, state.top)
|
||||
},
|
||||
more: () => state => {
|
||||
const more = { more: !state.more }
|
||||
return mergeDeep(more, state.top)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export default nav
|
||||
@@ -0,0 +1,8 @@
|
||||
export const navState = {
|
||||
top: {
|
||||
mobileMenu: false,
|
||||
more: false
|
||||
}
|
||||
}
|
||||
|
||||
export default navState
|
||||
@@ -0,0 +1,41 @@
|
||||
import { action } from '@hyperapp/fx'
|
||||
|
||||
import { mergeDeep } from '../../../utils/js-helpers'
|
||||
|
||||
export const onboard = {
|
||||
form: ({ form, message }) => state => {
|
||||
return {
|
||||
form: {
|
||||
form,
|
||||
message
|
||||
}
|
||||
}
|
||||
},
|
||||
clearForms: () => ({
|
||||
form: {
|
||||
form: 'login',
|
||||
message: ''
|
||||
},
|
||||
dashboard: {
|
||||
team: false,
|
||||
algobot: false,
|
||||
develop: false,
|
||||
compete: false,
|
||||
active: true
|
||||
}
|
||||
}),
|
||||
registerEmail: {
|
||||
input: value => state => {
|
||||
const emailInput = {
|
||||
input: value
|
||||
}
|
||||
return mergeDeep(emailInput, state.registerEmail)
|
||||
}
|
||||
},
|
||||
checkUsername: value => [
|
||||
action('throttleUsername', value),
|
||||
action('createUsername.input', value)
|
||||
]
|
||||
}
|
||||
|
||||
export default onboard
|
||||
@@ -0,0 +1,19 @@
|
||||
export const onboard = {
|
||||
form: {
|
||||
type: 'login',
|
||||
message: ''
|
||||
},
|
||||
dashboard: {
|
||||
team: false,
|
||||
algobot: false,
|
||||
develop: false,
|
||||
compete: false,
|
||||
active: true
|
||||
},
|
||||
modal: {
|
||||
content: 'AddTeam',
|
||||
isActive: false
|
||||
}
|
||||
}
|
||||
|
||||
export default onboard
|
||||
@@ -0,0 +1,57 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { h } from 'hyperapp'
|
||||
|
||||
export const DashboardSteps = props => (state, actions) => (
|
||||
<ul class='steps is-narrow is-medium is-centered has-content-centered'>
|
||||
<li class='steps-segment'>
|
||||
<a href='#' class='has-text-dark'>
|
||||
<span class='steps-marker has-text-white'>
|
||||
<span class='icon'>
|
||||
<i class='fa fa-users' />
|
||||
</span>
|
||||
</span>
|
||||
<div class='steps-content'>
|
||||
<p class='heading'>Create A Team</p>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li class='steps-segment'>
|
||||
<a hef='#' class='has-text-dark'>
|
||||
<span class='steps-marker has-text-white'>
|
||||
<span class='icon'>
|
||||
<i class='fa fa-robot' />
|
||||
</span>
|
||||
</span>
|
||||
<div class='steps-content'>
|
||||
<p class='heading'>Name Your Algobot</p>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li class='steps-segment is-active has-gaps'>
|
||||
<a hef='#' class='has-text-dark has-text-white'>
|
||||
<span class='steps-marker has-text-dark'>
|
||||
<span class='icon'>
|
||||
<i class='fa fa-code' />
|
||||
</span>
|
||||
</span>
|
||||
<div class='steps-content'>
|
||||
<p class='heading'>Develop</p>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
<li class='steps-segment'>
|
||||
<a hef='#' class='has-text-dark'>
|
||||
<span class='steps-marker is-hollow'>
|
||||
<span class='icon'>
|
||||
<i class='fa fa-trophy' />
|
||||
</span>
|
||||
</span>
|
||||
<div class='steps-content'>
|
||||
<p class='heading'>Compete</p>
|
||||
</div>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
)
|
||||
|
||||
export default DashboardSteps
|
||||
@@ -0,0 +1,3 @@
|
||||
import DashboardSteps from './dashboard-steps'
|
||||
|
||||
export { DashboardSteps }
|
||||
@@ -0,0 +1,210 @@
|
||||
import { action, throttle } from '@hyperapp/fx'
|
||||
|
||||
import { UniqueTeamnameQuery } from '../graphql/UniqueTeamnameQuery'
|
||||
import { AddTeamMutation } from '../graphql/AddTeamMutation'
|
||||
import { GetTeamQuery } from '../graphql/GetTeamQuery'
|
||||
import { DeleteTeamMutation } from '../graphql/DeleteTeamMutation'
|
||||
|
||||
import { client } from '../../../index'
|
||||
|
||||
import { mergeDeep } from '../../../utils/js-helpers'
|
||||
|
||||
export const team = {
|
||||
form: ({ form, message }) => state => {
|
||||
return {
|
||||
form: {
|
||||
form,
|
||||
message
|
||||
}
|
||||
}
|
||||
},
|
||||
clearForms: () => ({
|
||||
form: {
|
||||
form: 'login',
|
||||
message: ''
|
||||
},
|
||||
createTeam: {
|
||||
input: '',
|
||||
unique: false,
|
||||
placeholder: 'Your teamname'
|
||||
}
|
||||
}),
|
||||
checkTeamname: value => [
|
||||
action('throttleTeamname', value),
|
||||
action('createTeam.input', value)
|
||||
],
|
||||
throttleTeamname: value => throttle(750, 'uniqueTeamname', value),
|
||||
uniqueTeamname: value => async (state, actions) => {
|
||||
const result = await client.query({
|
||||
query: UniqueTeamnameQuery,
|
||||
variables: { name: value }
|
||||
})
|
||||
return actions.createTeam.unique(result.data.teamByName.name === null)
|
||||
},
|
||||
createTeam: {
|
||||
input: value => state => {
|
||||
const teamnameInput = {
|
||||
input: value
|
||||
}
|
||||
return mergeDeep(teamnameInput, state.createTeam)
|
||||
},
|
||||
unique: value => state => {
|
||||
const teamnameInput = {
|
||||
unique: value
|
||||
}
|
||||
return mergeDeep(teamnameInput, state.createTeam)
|
||||
},
|
||||
error: message => state => {
|
||||
const errorInput = {
|
||||
message: message
|
||||
}
|
||||
return mergeDeep(errorInput, state.createTeam)
|
||||
}
|
||||
},
|
||||
profile: profile => (state, actions) => {
|
||||
return {
|
||||
profile
|
||||
}
|
||||
},
|
||||
addTeam: result => [
|
||||
action('form', { form: 'addTeamNotice', message: `Adding your team...` }),
|
||||
action('addTeamSubmit', result)
|
||||
],
|
||||
addTeamSubmit: teamForm => async (state, actions) => {
|
||||
teamForm.preventDefault()
|
||||
teamForm.target.blur()
|
||||
|
||||
const teamname = teamForm.target.form[0].value
|
||||
|
||||
const slug = await teamname.replace(/[^a-zA-Z0-9]+/g, '-').toLowerCase()
|
||||
const validateSlug = new RegExp('^[a-z0-9-]+$')
|
||||
const valid = await validateSlug.test(slug)
|
||||
await console.log('actions.team.addTeam: ', valid, slug)
|
||||
if (!valid) {
|
||||
return actions.form({
|
||||
form: 'addTeamError',
|
||||
message: 'Team name not valid. Please only letters, numbers and spaces'
|
||||
})
|
||||
}
|
||||
|
||||
const team = {
|
||||
name: teamname,
|
||||
slug: slug,
|
||||
owner: teamForm.target.form[1].value
|
||||
}
|
||||
|
||||
const uniqueTeam = await client.query({
|
||||
query: UniqueTeamnameQuery,
|
||||
variables: { name: teamname }
|
||||
})
|
||||
await console.log(
|
||||
'actions.team.addTeam: ',
|
||||
team,
|
||||
valid,
|
||||
uniqueTeam,
|
||||
uniqueTeam.data.uniqueTeamname
|
||||
)
|
||||
if (uniqueTeam.data.teamByName !== null) {
|
||||
return actions.form({
|
||||
form: 'addTeamError',
|
||||
message: 'Sorry, this team name is taken. Please create a new one'
|
||||
})
|
||||
}
|
||||
|
||||
const result = await client.mutate({
|
||||
mutation: AddTeamMutation,
|
||||
variables: { name: teamname, slug: slug, owner: teamForm.target.form[1].value },
|
||||
options: {
|
||||
update: (proxy, { data: { getTeamByOwner } }) => {
|
||||
const data = proxy.readQuery({ GetTeamQuery })
|
||||
data.getTeamByOwner.push(getTeamByOwner)
|
||||
proxy.writeQuery({ GetTeamQuery, data })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (result.data.addTeam !== null) {
|
||||
return actions.addTeamSuccess(result.data.addTeam)
|
||||
} else {
|
||||
return actions.form({
|
||||
form: 'addTeamError',
|
||||
message: `Unable to add Team: ${result.data.addTeam.errors[0].message}`
|
||||
})
|
||||
}
|
||||
},
|
||||
addTeamSuccess: result => [
|
||||
action('form', { form: 'addTeamSuccess', message: 'Team Added!' }),
|
||||
action('profile', result),
|
||||
action('createTeam.input', ''),
|
||||
action('toggleModal', '')
|
||||
],
|
||||
toggleModal: form => (state, actions) => {
|
||||
return {
|
||||
modal: {
|
||||
content: form,
|
||||
isActive: !state.modal.isActive
|
||||
}
|
||||
}
|
||||
},
|
||||
getTeam: id => [
|
||||
action('form', { form: 'getTeamLoad', message: 'Getting your team...' }),
|
||||
action('getTeambyOwner', id)
|
||||
],
|
||||
getTeambyOwner: id => async (state, actions) => {
|
||||
const result = await client.query({
|
||||
query: GetTeamQuery,
|
||||
variables: { auth0id: id },
|
||||
fetchPolicy: 'network-only'
|
||||
})
|
||||
|
||||
if (result.data.teamByOwner.edges.length > 0) {
|
||||
return actions.getTeamSuccess(result.data.teamByOwner)
|
||||
} else {
|
||||
return actions.getTeamNoTeam()
|
||||
}
|
||||
},
|
||||
getTeamSuccess: profile => [
|
||||
action('form', { form: 'getTeamSuccess', message: 'Your team' }),
|
||||
action('profile', profile)
|
||||
],
|
||||
getTeamNoTeam: profile => [
|
||||
action('form', { form: 'getTeamNotice', message: 'No team found' }),
|
||||
action('profile', { name: '' })
|
||||
],
|
||||
deleteTeam: id => [
|
||||
action('form', {
|
||||
form: 'deleteTeamLoad',
|
||||
message: 'Removing your team...'
|
||||
}),
|
||||
action('deleteTeamSubmit', id)
|
||||
],
|
||||
deleteTeamSubmit: ({id, owner}) => async (state, actions) => {
|
||||
console.log('deleteTeamSubmit: ', id, owner)
|
||||
const result = await client.mutate({
|
||||
mutation: DeleteTeamMutation,
|
||||
variables: { id: id, owner: owner },
|
||||
options: {
|
||||
update: (proxy, { data: { getTeamByOwner } }) => {
|
||||
const data = proxy.readQuery({ GetTeamQuery })
|
||||
data.getTeamByOwner.push(getTeamByOwner)
|
||||
proxy.writeQuery({ GetTeamQuery, data })
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
if (result.data.deleteTeam.id !== null) {
|
||||
return actions.deleteTeamSuccess({ name: '' })
|
||||
} else {
|
||||
return actions.form({ form: 'deleteTeamError', message: 'No team found' })
|
||||
}
|
||||
},
|
||||
deleteTeamSuccess: profile => [
|
||||
action('form', {
|
||||
form: 'deleteTeamSuccess',
|
||||
message: 'Your team has been deleted'
|
||||
}),
|
||||
action('profile', profile)
|
||||
]
|
||||
}
|
||||
|
||||
export default team
|
||||
@@ -0,0 +1,16 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const AddTeamMutation = gql`
|
||||
mutation CreateTeamMutation($name: String!, $slug: String!, $owner: String!) {
|
||||
createTeam(name: $name, slug: $slug, owner: $owner) {
|
||||
id
|
||||
name
|
||||
slug
|
||||
owner {
|
||||
auth0id
|
||||
id
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
@@ -0,0 +1,10 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const DeleteTeamMutation = gql`
|
||||
mutation deleteTeam($id: ID!, $owner: String!) {
|
||||
deleteTeam(id: $id, owner: $owner) {
|
||||
id
|
||||
}
|
||||
}
|
||||
`
|
||||
@@ -0,0 +1,40 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const GetTeamQuery = gql`
|
||||
query teamDetailsQuery($auth0id: String!) {
|
||||
teamByOwner(ownerId: $auth0id) {
|
||||
edges {
|
||||
node {
|
||||
id
|
||||
name
|
||||
slug
|
||||
profile {
|
||||
avatar
|
||||
description
|
||||
motto
|
||||
}
|
||||
owner {
|
||||
nickname
|
||||
visible
|
||||
profile {
|
||||
avatar
|
||||
}
|
||||
}
|
||||
members {
|
||||
role
|
||||
member {
|
||||
nickname
|
||||
visible
|
||||
profile {
|
||||
avatar
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export default GetTeamQuery
|
||||
@@ -0,0 +1,12 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const UniqueTeamnameQuery = gql`
|
||||
query uniqueTeamname($name: String!) {
|
||||
teamByName(name: $name){
|
||||
name
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export default UniqueTeamnameQuery
|
||||
Whitespace-only changes.
@@ -0,0 +1,20 @@
|
||||
export const team = {
|
||||
form: {
|
||||
type: 'login',
|
||||
message: ''
|
||||
},
|
||||
createTeam: {
|
||||
input: '',
|
||||
unique: true,
|
||||
placeholder: 'Your teamname',
|
||||
error: ''
|
||||
},
|
||||
profile: {},
|
||||
members: [],
|
||||
modal: {
|
||||
content: '',
|
||||
isActive: false
|
||||
}
|
||||
}
|
||||
|
||||
export default team
|
||||
@@ -0,0 +1,72 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { h } from 'hyperapp'
|
||||
|
||||
export const AddTeamForm = props => (state, actions) => (
|
||||
<form name='addTeamForm' key='AddTeamForm'>
|
||||
<h1 class='title'>Add A Team</h1>
|
||||
<div class='field'>
|
||||
<label class='label'>Enter a team name</label>
|
||||
<div class='control has-icons-left has-icons-right'>
|
||||
<input
|
||||
class='input'
|
||||
type='text'
|
||||
onupdate={(element, oldAttributes) => {
|
||||
if (
|
||||
oldAttributes.value !== element.value ||
|
||||
(oldAttributes.value !== '' && element.value === '')
|
||||
) {
|
||||
element.focus()
|
||||
}
|
||||
}}
|
||||
aria-label={state.team.createTeam.placeholder}
|
||||
oninput={({ target: { value } }) => actions.team.checkTeamname(value)}
|
||||
onblur={({ target: { value } }) => actions.team.checkTeamname(value)}
|
||||
value={state.team.createTeam.input}
|
||||
placeholder={state.team.createTeam.placeholder}
|
||||
/>
|
||||
<span
|
||||
class={`icon is-small is-right ${
|
||||
state.team.createTeam.unique.input !== '' &&
|
||||
state.team.createTeam.unique
|
||||
? 'has-text-success'
|
||||
: 'has-text-grey'
|
||||
}`}
|
||||
>
|
||||
<i class='fas fa-check' />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<p
|
||||
key='createTeamUniqueMessage'
|
||||
class={`has-text-centered ${
|
||||
!state.team.createTeam.unique ? 'has-text-danger' : 'is-invisible'
|
||||
}`}
|
||||
>
|
||||
This teamname is already taken. Please create a new one.
|
||||
</p>
|
||||
<p
|
||||
key='addTeamMessage'
|
||||
class={`help is-size-4 m-t-hlf m-b-hlf
|
||||
${state.team.form.form === 'addTeamSuccess' ? 'has-text-success' : ''}
|
||||
${state.team.form.form === 'addTeamNotice' ? 'has-text-primary' : ''}
|
||||
${state.team.form.form === 'addTeamError' ? 'has-text-danger' : ''}
|
||||
${
|
||||
state.team.form.form === 'addTeamSuccess' ||
|
||||
state.team.form.form === 'addTeamNotice' ||
|
||||
state.team.form.form === 'addTeamError'
|
||||
? ''
|
||||
: 'is-invisible'
|
||||
}`}
|
||||
>
|
||||
{state.team.form.message}
|
||||
</p>
|
||||
<div class='control buttons is-centered'>
|
||||
<input type='hidden' name='owner' value={state.user.id} />
|
||||
<button onclick={e => actions.team.addTeam(e)} class='button is-link'>
|
||||
Create Team
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
)
|
||||
|
||||
export default AddTeamForm
|
||||
@@ -0,0 +1,5 @@
|
||||
import { AddTeamForm } from './add-team'
|
||||
import { TeamList } from './team-list'
|
||||
import { TeamPanel } from './team-panel'
|
||||
|
||||
export { AddTeamForm, TeamList, TeamPanel }
|
||||
@@ -0,0 +1,57 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { h } from 'hyperapp'
|
||||
import { validObject } from '../../../utils/js-helpers'
|
||||
|
||||
export const TeamList = props => (state, actions) => {
|
||||
const team = validObject(state.team.profile, 'edges') ? state.team.profile.edges : ''
|
||||
|
||||
if (team === '') {
|
||||
return (
|
||||
<div class='section' key='teamList'>
|
||||
<p class='is-size-4'>You don't have a team yet!</p>
|
||||
<div class='level m-t-2'>
|
||||
<div class='level-item'>
|
||||
<a
|
||||
class='button is-primary is-medium'
|
||||
onclick={() => actions.toggleModal('AddTeam')}
|
||||
>
|
||||
Create a team
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (team[0].node.name !== '' && team[0].node.name !== null) {
|
||||
const initial = team[0].node.name.substring(0, 1)
|
||||
return (
|
||||
<div class='section' key='teamList'>
|
||||
{team[0].node.profile !== null && team[0].node.profile.avatar !== '' ? (
|
||||
<div class='image is-96x96 avatar'>
|
||||
<img src={team[0].node.profile.avatar} alt={team[0].node.name} />
|
||||
</div>
|
||||
) : (
|
||||
<div class='image is-96x96 avatar has-text-white is-uppercase is-red is-size-3 is-centered'>
|
||||
{initial}
|
||||
</div>
|
||||
)}
|
||||
<p class='title'>{team[0].node.name}</p>
|
||||
<p class='is-size-4'>Team leader: {team[0].node.owner.nickname}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div class='section' key='teamList'>
|
||||
<p class='is-size-4'>{state.team.form.message}</p>
|
||||
<div class='level m-t-2'>
|
||||
<div class='level-item'>
|
||||
<span class='icon has-text-primary is-large'>
|
||||
<i class='fas fa-spinner fa-pulse' />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import { h } from 'hyperapp'
|
||||
import { validObject } from '../../../utils/js-helpers'
|
||||
|
||||
export const TeamPanel = props => (state, actions) => {
|
||||
const team = validObject(state.team.profile, 'edges') ? state.team.profile.edges : ''
|
||||
if (team === '') {
|
||||
return (
|
||||
<div class='section' key='teamList' class='is-marginless is-paddingless'>
|
||||
<h2 class='title is-size-4 m-t-1'>Team</h2>
|
||||
<p class='is-size-4'>You don't have a team yet!</p>
|
||||
<div class='level m-t-2'>
|
||||
<div class='level-item'>
|
||||
<a
|
||||
class='button is-primary is-medium'
|
||||
onclick={() => actions.toggleModal('AddTeam')}
|
||||
>
|
||||
Create a team
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
if (team[0].node.name !== '' && team[0].node.name !== null) {
|
||||
const initial = team[0].node.name.substring(0, 1)
|
||||
return (
|
||||
<div class='section' key='teamList' class='is-marginless is-paddingless'>
|
||||
<h2 class='title is-size-4 m-t-1'>Team</h2>
|
||||
{team[0].node.profile !== null && team[0].node.profile.avatar !== '' ? (
|
||||
<div class='image is-32x32 avatar'>
|
||||
<img src={team[0].node.avatar} alt={team[0].node.name} />
|
||||
</div>
|
||||
) : (
|
||||
<div class='image is-32x32 avatar has-text-white is-uppercase is-red is-size-3 is-centered'>
|
||||
{initial}
|
||||
</div>
|
||||
)}
|
||||
<p class='title'>{team[0].node.name}</p>
|
||||
<p class='is-size-4'>Team leader: {team[0].node.owner.nickname}</p>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<div class='section' key='teamList' class='is-marginless is-paddingless'>
|
||||
<h2 class='title is-size-4 m-t-1'>Team</h2>
|
||||
<p class='is-size-4'>{state.team.form.message}</p>
|
||||
<div class='level m-t-2'>
|
||||
<div class='level-item'>
|
||||
<span class='icon has-text-primary is-large'>
|
||||
<i class='fas fa-spinner fa-pulse' />
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default TeamPanel
|
||||
@@ -0,0 +1,95 @@
|
||||
import { action } from '@hyperapp/fx'
|
||||
|
||||
import { client } from '../../../index'
|
||||
import { LoginMutation } from '../graphql/Login'
|
||||
|
||||
// import { auth } from '../../auth/actions'
|
||||
|
||||
import { removeItem } from '../../../utils/local-storage'
|
||||
|
||||
export const user = {
|
||||
form: ({ form, message }) => state => {
|
||||
return {
|
||||
form: {
|
||||
form,
|
||||
message
|
||||
}
|
||||
}
|
||||
},
|
||||
clearForms: () => ({
|
||||
form: {
|
||||
form: 'login',
|
||||
message: ''
|
||||
}
|
||||
}),
|
||||
login: value => [
|
||||
action('form', { form: 'loginNotice', message: 'Logging you in...' }),
|
||||
action('loginSubmit', value)
|
||||
],
|
||||
loginSubmit: loginForm => async (state, actions) => {
|
||||
loginForm.preventDefault()
|
||||
loginForm.target.blur()
|
||||
|
||||
const usernameOrEmail = loginForm.target.form[0].value
|
||||
const password = loginForm.target.form[1].value
|
||||
const result = await client.mutate({
|
||||
mutation: LoginMutation,
|
||||
variables: { input: { usernameOrEmail, password } }
|
||||
})
|
||||
console.log('actions.user.loginSubmit: ', result.data.login)
|
||||
if (result.data.login.user !== null) {
|
||||
return actions.setLoggedIn(result.data.login.user)
|
||||
} else {
|
||||
return actions.form({
|
||||
form: 'loginError',
|
||||
message: result.data.login.errors[0].message
|
||||
})
|
||||
}
|
||||
},
|
||||
loginRegister: user => async (state, actions) => {
|
||||
const usernameOrEmail = user.username
|
||||
const password = user.password
|
||||
const result = await client.mutate({
|
||||
mutation: LoginMutation,
|
||||
variables: { input: { usernameOrEmail, password } }
|
||||
})
|
||||
console.log('actions.user.loginRegister: ', result.data.login)
|
||||
if (result.data.login.user !== null) {
|
||||
return actions.setLoggedIn(result.data.login.user)
|
||||
} else {
|
||||
return actions.form({
|
||||
form: 'loginError',
|
||||
message: result.data.login.errors[0].message
|
||||
})
|
||||
}
|
||||
},
|
||||
setLoggedIn: user => state => ({
|
||||
auth: {
|
||||
loggedIn: true,
|
||||
role: user.role
|
||||
},
|
||||
profile: {
|
||||
id: user.id,
|
||||
ghId: '',
|
||||
username: user.username,
|
||||
email: user.email,
|
||||
name: '',
|
||||
avatar: '',
|
||||
url: ''
|
||||
}
|
||||
}),
|
||||
logOut: () => async (state, actions) => {
|
||||
await removeItem('accessToken')
|
||||
await removeItem('refreshToken')
|
||||
return actions.loggedOut()
|
||||
},
|
||||
loggedOut: () => state => ({
|
||||
auth: {
|
||||
loggedIn: false,
|
||||
role: ''
|
||||
},
|
||||
profile: {}
|
||||
})
|
||||
}
|
||||
|
||||
export default user
|
||||
@@ -0,0 +1,12 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const currentUser = gql`
|
||||
query currentUser {
|
||||
currentUser {
|
||||
...UserInfo
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export default currentUser
|
||||
@@ -0,0 +1,86 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const LoginMutation = gql`
|
||||
mutation login($input: LoginUserInput!) {
|
||||
login(input: $input) {
|
||||
tokens {
|
||||
accessToken
|
||||
refreshToken
|
||||
}
|
||||
user {
|
||||
id
|
||||
username
|
||||
role
|
||||
isActive
|
||||
email
|
||||
profile {
|
||||
firstName
|
||||
lastName
|
||||
fullName
|
||||
}
|
||||
auth {
|
||||
certificate {
|
||||
serial
|
||||
}
|
||||
facebook {
|
||||
fbId
|
||||
displayName
|
||||
}
|
||||
google {
|
||||
googleId
|
||||
displayName
|
||||
}
|
||||
github {
|
||||
ghId
|
||||
displayName
|
||||
}
|
||||
linkedin {
|
||||
lnId
|
||||
displayName
|
||||
}
|
||||
}
|
||||
}
|
||||
errors {
|
||||
field
|
||||
message
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const UserInfo = gql`
|
||||
fragment UserInfo on User {
|
||||
id
|
||||
username
|
||||
role
|
||||
isActive
|
||||
email
|
||||
profile {
|
||||
firstName
|
||||
lastName
|
||||
fullName
|
||||
}
|
||||
auth {
|
||||
certificate {
|
||||
serial
|
||||
}
|
||||
facebook {
|
||||
fbId
|
||||
displayName
|
||||
}
|
||||
google {
|
||||
googleId
|
||||
displayName
|
||||
}
|
||||
github {
|
||||
ghId
|
||||
displayName
|
||||
}
|
||||
linkedin {
|
||||
lnId
|
||||
displayName
|
||||
}
|
||||
}
|
||||
}
|
||||
`
|
||||
@@ -0,0 +1,5 @@
|
||||
fragment UserProfileInfo on UserProfile {
|
||||
firstName
|
||||
lastName
|
||||
fullName
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
/* eslint-disable no-unused-vars */
|
||||
import gql from 'graphql-tag'
|
||||
|
||||
export const RefreshTokens = gql`
|
||||
mutation refreshTokens($refreshToken: String!) {
|
||||
refreshTokens(refreshToken: $refreshToken) {
|
||||
accessToken
|
||||
refreshToken
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export default RefreshTokens
|
||||
@@ -0,0 +1,33 @@
|
||||
#import "./Profile.graphql"
|
||||
|
||||
fragment UserInfo on User {
|
||||
id
|
||||
username
|
||||
role
|
||||
isActive
|
||||
email
|
||||
profile {
|
||||
...UserProfileInfo
|
||||
}
|
||||
auth {
|
||||
certificate {
|
||||
serial
|
||||
}
|
||||
facebook {
|
||||
fbId
|
||||
displayName
|
||||
}
|
||||
google {
|
||||
googleId
|
||||
displayName
|
||||
}
|
||||
github {
|
||||
ghId
|
||||
displayName
|
||||
}
|
||||
linkedin {
|
||||
lnId
|
||||
displayName
|
||||
}
|
||||
}
|
||||
}
|
||||
Whitespace-only changes.
@@ -0,0 +1,21 @@
|
||||
export const user = {
|
||||
form: {
|
||||
type: 'login',
|
||||
message: ''
|
||||
},
|
||||
auth: {
|
||||
loggedIn: false,
|
||||
role: 'pending'
|
||||
},
|
||||
profile: {
|
||||
id: '',
|
||||
ghId: '',
|
||||
username: '',
|
||||
email: '',
|
||||
name: '',
|
||||
avatar: '',
|
||||
url: ''
|
||||
}
|
||||
}
|
||||
|
||||
export default user
|
||||
Reference in new issue
Block a user