Added toast notifications

This commit is contained in:
JeyGR 2024-12-18 22:17:01 +05:30 committed by jey-exp
parent feebdfcfe9
commit ab86a3b871
8 changed files with 48 additions and 18 deletions

View file

@ -42,21 +42,25 @@ function OrgAccess() {
}
async function deleteInvite(invite: any) {
const toastId = toast.loading("Deleting...")
let res = await deleteInviteCode(org.id, invite.invite_code_uuid, access_token)
if (res.status == 200) {
mutate(`${getAPIUrl()}orgs/${org.id}/invites`)
toast.success("Deleted invite code", {id:toastId})
} else {
toast.error('Error ' + res.status + ': ' + res.data.detail)
toast.error('Error deleting', {id:toastId})
}
}
async function changeJoinMethod(method: 'open' | 'inviteOnly') {
const toastId = toast.loading("Changing join method...")
let res = await changeSignupMechanism(org.id, method, access_token)
if (res.status == 200) {
router.refresh()
mutate(`${getAPIUrl()}orgs/slug/${org?.slug}`)
toast.success(`Changed join method to ${method}`, {id:toastId})
} else {
toast.error('Error ' + res.status + ': ' + res.data.detail)
toast.error('Error changing join method', {id:toastId})
}
}

View file

@ -29,12 +29,14 @@ function OrgUserGroups() {
)
const deleteUserGroupUI = async (usergroup_id: any) => {
const toastId = toast.loading("Deleting...");
const res = await deleteUserGroup(usergroup_id, access_token)
if (res.status == 200) {
mutate(`${getAPIUrl()}usergroups/org/${org.id}`)
toast.success("Deleted usergroup", {id:toastId})
}
else {
toast.error('Error ' + res.status + ': ' + res.data.detail)
toast.error('Error deleting usergroup', {id:toastId})
}
}

View file

@ -31,11 +31,13 @@ function OrgUsers() {
}
const handleRemoveUser = async (user_id: any) => {
const toastId = toast.loading("Removing...");
const res = await removeUserFromOrg(org.id, user_id,access_token)
if (res.status === 200) {
await mutate(`${getAPIUrl()}orgs/${org.id}/users`)
toast.success("Removed user from org", {id:toastId});
} else {
toast.error('Error ' + res.status + ': ' + res.data.detail)
toast.error('Error removing user', {id:toastId});
}
}

View file

@ -20,13 +20,15 @@ function OrgUsersAdd() {
const [selectedInviteCode, setSelectedInviteCode] = React.useState('');
async function sendInvites() {
const toastId = toast.loading("Sending invite...")
setIsLoading(true)
let res = await inviteBatchUsers(org.id, invitedUsers, selectedInviteCode,access_token)
if (res.status == 200) {
mutate(`${getAPIUrl()}orgs/${org?.id}/invites/users`)
setIsLoading(false)
toast.success("Invite sent", {id:toastId})
} else {
toast.error('Error ' + res.status + ': ' + res.data.detail)
toast.error('Error sending invite', {id:toastId})
setIsLoading(false)
}