1
0
Fork 0
mirror of synced 2024-07-15 19:25:55 +12:00

sets up invite action in onboarding modal

This commit is contained in:
Keviin Åberg Kultalahti 2021-05-12 11:33:04 +02:00
parent 28223baa41
commit b3c63defb3
2 changed files with 10 additions and 14 deletions

View file

@ -17,9 +17,13 @@
const [email, error, touched] = createValidationStore("", emailValidator) const [email, error, touched] = createValidationStore("", emailValidator)
async function createUserFlow() { async function createUserFlow() {
const response = await users.invite(email) const res = await users.invite($email)
console.log(response) console.log(res)
notifications.success("Email sent.") if (res.status) {
notifications.error(res.message)
} else {
notifications.success(res.message)
}
} }
</script> </script>

View file

@ -6,22 +6,14 @@ export function createUsersStore() {
const { subscribe, set } = writable([]) const { subscribe, set } = writable([])
async function init() { async function init() {
try { const response = await api.get(`/api/admin/users`)
const response = await api.get(`/api/admin/users`) const json = await response.json()
const json = await response.json() set(json)
set(json)
} catch (error) {
console.log(error)
}
} }
async function invite(email) { async function invite(email) {
try {
const response = await api.post(`/api/admin/users/invite`, { email }) const response = await api.post(`/api/admin/users/invite`, { email })
return await response.json() return await response.json()
} catch (error) {
return error
}
} }
async function create({ email, password }) { async function create({ email, password }) {