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)
async function createUserFlow() {
const response = await users.invite(email)
console.log(response)
notifications.success("Email sent.")
const res = await users.invite($email)
console.log(res)
if (res.status) {
notifications.error(res.message)
} else {
notifications.success(res.message)
}
}
</script>

View File

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