This repository was archived by the owner on May 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
ユーザー招待ページ #94
Merged
Merged
ユーザー招待ページ #94
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
c2c0c96
Handle requiresAdmin
gedorinku ce27a54
Merge branch 'master' into gedorinku/invitations
gedorinku e8d29e3
Add isAdmin
gedorinku 0bd5f27
Show invitations
gedorinku 13d5444
Add bulma package
gedorinku c0fcf08
Impl invitation
gedorinku 586e1ed
Fix router
gedorinku 65916cf
Handle errors
gedorinku 0de98bd
Add name
gedorinku 249f39e
Merge branch 'master' into gedorinku/invitations
gedorinku 745862e
Clear error
gedorinku File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import api from '@/api'; | ||
import getHeader from '@/api/utils/get-header'; | ||
|
||
export default { | ||
async listInvitations(sessionID) { | ||
const res = (await api.client.get('/admin/invitations', getHeader(sessionID))).data.invitations; | ||
return res; | ||
}, | ||
async createInvitation(sessionID, email) { | ||
const res = (await api.client.post('/admin/invitations', { email }, getHeader(sessionID))).data.invitations; | ||
return res; | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import invitationClient from '@/api/invitation'; | ||
|
||
export default { | ||
namespaced: true, | ||
state: { | ||
invitations: null, | ||
invitationError: null, | ||
}, | ||
/* eslint-disable no-param-reassign */ | ||
mutations: { | ||
setInvitations(state, invitations) { | ||
state.invitations = invitations; | ||
}, | ||
clearInvitationError(state) { | ||
state.invitationError = null; | ||
}, | ||
setInvitationError(state, error) { | ||
state.invitationError = error; | ||
}, | ||
}, | ||
/* eslint-enable no-param-reassign */ | ||
actions: { | ||
async listInvitations({ commit }, sessionID) { | ||
try { | ||
commit('setInvitations', await invitationClient.listInvitations(sessionID)); | ||
} catch (e) { | ||
commit('criticalError/createError', e, { root: true }); | ||
} | ||
}, | ||
async invite({ commit, dispatch }, { sessionID, rawEmails }) { | ||
commit('clearInvitationError'); | ||
const emails = rawEmails.split(/\r\n|\n/).map(email => email.trim()).filter(email => email); | ||
try { | ||
await Promise.all(emails.map(email => invitationClient.createInvitation(sessionID, email))); | ||
} catch (e) { | ||
commit('setInvitationError', e); | ||
} | ||
|
||
dispatch('listInvitations', sessionID); | ||
}, | ||
}, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
<template> | ||
<div class="container"> | ||
<section class="section"> | ||
<h1 class="title">部員の招待</h1> | ||
<div> | ||
<form v-on:submit.prevent="onInvite"> | ||
<div class="field"> | ||
<label class="label">メールアドレス</label> | ||
<div class="control"> | ||
<textarea | ||
class="textarea" | ||
:placeholder="'[email protected]\[email protected]\[email protected]\n...'" | ||
v-model="emails" | ||
></textarea> | ||
</div> | ||
</div> | ||
<div class="control"> | ||
<button type="submit" class="button">招待</button> | ||
</div> | ||
<ErrorMessage :error="invitationError"/> | ||
</form> | ||
</div> | ||
</section> | ||
<section class="section"> | ||
<h1 class="title">招待されたメールアドレス</h1> | ||
<table class="table"> | ||
<thead> | ||
<tr> | ||
<th>ID</th> | ||
<th>メールアドレス</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
<tr v-for="invitation in invitations" :key="invitation.invitation_id"> | ||
<th>{{ invitation.invitation_id }}</th> | ||
<td>{{ invitation.email }}</td> | ||
</tr> | ||
</tbody> | ||
</table> | ||
</section> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import 'bulma/css/bulma.css'; | ||
import { mapState, mapActions } from 'vuex'; | ||
import ErrorMessage from '@/components/ErrorMessage.vue'; | ||
|
||
export default { | ||
name: 'invitation', | ||
components: { | ||
ErrorMessage, | ||
}, | ||
data() { | ||
return { | ||
emails: null, | ||
}; | ||
}, | ||
created() { | ||
this.listInvitations(this.sessionID); | ||
}, | ||
computed: { | ||
...mapState('invitation', ['invitations', 'invitationError']), | ||
...mapState('session', ['sessionID']), | ||
}, | ||
methods: { | ||
...mapActions('invitation', ['listInvitations', 'invite']), | ||
onInvite() { | ||
this.invite({ sessionID: this.sessionID, rawEmails: this.emails }); | ||
this.emails = null; | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<style> | ||
</style> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.