sets up invite action in onboarding modal
This commit is contained in:
parent
1ea4a9d850
commit
ea342c3e5e
|
@ -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>
|
||||||
|
|
||||||
|
|
|
@ -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 }) {
|
||||||
|
|
Loading…
Reference in New Issue