Fix notifications for profile and password changes in client apps
This commit is contained in:
parent
64e92e91ac
commit
383b799e3e
|
@ -12,7 +12,7 @@
|
|||
|
||||
export let compact: boolean = false
|
||||
|
||||
const { authStore, environmentStore } = getContext("sdk")
|
||||
const { authStore, environmentStore, notificationStore } = getContext("sdk")
|
||||
|
||||
let profileModal: any
|
||||
let changePasswordModal: any
|
||||
|
@ -87,13 +87,17 @@
|
|||
{API}
|
||||
user={$authStore}
|
||||
on:save={() => authStore.actions.fetchUser()}
|
||||
notifySuccess={notificationStore.actions.success}
|
||||
notifyError={notificationStore.actions.error}
|
||||
/>
|
||||
</Modal>
|
||||
<Modal bind:this={changePasswordModal}>
|
||||
<ChangePasswordModal
|
||||
{API}
|
||||
passwordMinLength={$environmentStore.passwordMinLength}
|
||||
on:save={() => authStore.actions.fetchUser()}
|
||||
on:save={() => authStore.actions.logOut()}
|
||||
notifySuccess={notificationStore.actions.success}
|
||||
notifyError={notificationStore.actions.error}
|
||||
/>
|
||||
</Modal>
|
||||
{/if}
|
||||
|
|
|
@ -12,6 +12,7 @@ import {
|
|||
hoverStore,
|
||||
stateStore,
|
||||
routeStore,
|
||||
notificationStore,
|
||||
} from "@/stores"
|
||||
import { get } from "svelte/store"
|
||||
import { initWebsocket } from "@/websocket"
|
||||
|
@ -83,6 +84,7 @@ export interface SDK {
|
|||
generateGoldenSample: any
|
||||
authStore: typeof authStore
|
||||
environmentStore: typeof environmentStore
|
||||
notificationStore: typeof notificationStore
|
||||
builderStore: Readable<{
|
||||
inBuilder: boolean
|
||||
}> & {
|
||||
|
|
|
@ -46,6 +46,7 @@ const createAuthStore = () => {
|
|||
const logOut = async () => {
|
||||
try {
|
||||
await API.logOut()
|
||||
window.location.href = "/"
|
||||
} catch (error) {
|
||||
// Do nothing
|
||||
}
|
||||
|
|
|
@ -6,6 +6,8 @@
|
|||
|
||||
export let API: APIClient
|
||||
export let passwordMinLength: string | undefined = undefined
|
||||
export let notifySuccess = notifications.success
|
||||
export let notifyError = notifications.error
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
|
@ -15,10 +17,10 @@
|
|||
const updatePassword = async () => {
|
||||
try {
|
||||
await API.updateSelf({ password })
|
||||
notifications.success("Password changed successfully")
|
||||
notifySuccess("Password changed successfully")
|
||||
dispatch("save")
|
||||
} catch (error) {
|
||||
notifications.error("Failed to update password")
|
||||
notifyError("Failed to update password")
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,8 @@
|
|||
|
||||
export let user: User | ContextUser | undefined = undefined
|
||||
export let API: APIClient
|
||||
export let notifySuccess = notifications.success
|
||||
export let notifyError = notifications.error
|
||||
|
||||
const dispatch = createEventDispatcher()
|
||||
|
||||
|
@ -18,11 +20,11 @@
|
|||
const updateInfo = async () => {
|
||||
try {
|
||||
await API.updateSelf($values)
|
||||
notifications.success("Information updated successfully")
|
||||
notifySuccess("Information updated successfully")
|
||||
dispatch("save")
|
||||
} catch (error) {
|
||||
console.error(error)
|
||||
notifications.error("Failed to update information")
|
||||
notifyError("Failed to update information")
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
|
Loading…
Reference in New Issue