Skip to content

Commit

Permalink
feat: added toasts instead of alerts (mckaywrigley#1740)
Browse files Browse the repository at this point in the history
  • Loading branch information
techcontributor authored Jun 2, 2024
1 parent 583e33b commit 66f4bd6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion components/setup/profile-step.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
} from "@tabler/icons-react"
import { FC, useCallback, useState } from "react"
import { LimitDisplay } from "../ui/limit-display"
import { toast } from "sonner"

interface ProfileStepProps {
username: string
Expand Down Expand Up @@ -63,7 +64,7 @@ export const ProfileStep: FC<ProfileStepProps> = ({
const usernameRegex = /^[a-zA-Z0-9_]+$/
if (!usernameRegex.test(username)) {
onUsernameAvailableChange(false)
alert(
toast.error(
"Username must be letters, numbers, or underscores only - no other characters or spacing allowed."
)
return
Expand Down
5 changes: 3 additions & 2 deletions components/utility/change-password.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {
DialogTitle
} from "../ui/dialog"
import { Input } from "../ui/input"
import { toast } from "sonner"

interface ChangePasswordProps {}

Expand All @@ -22,11 +23,11 @@ export const ChangePassword: FC<ChangePasswordProps> = () => {
const [confirmPassword, setConfirmPassword] = useState("")

const handleResetPassword = async () => {
if (!newPassword) return alert("Please enter your new password.")
if (!newPassword) return toast.info("Please enter your new password.")

await supabase.auth.updateUser({ password: newPassword })

alert("Password changed successfully.")
toast.success("Password changed successfully.")

return router.push("/login")
}
Expand Down
2 changes: 1 addition & 1 deletion components/utility/profile-settings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ export const ProfileSettings: FC<ProfileSettingsProps> = ({}) => {
const usernameRegex = /^[a-zA-Z0-9_]+$/
if (!usernameRegex.test(username)) {
setUsernameAvailable(false)
alert(
toast.error(
"Username must be letters, numbers, or underscores only - no other characters or spacing allowed."
)
return
Expand Down
3 changes: 2 additions & 1 deletion components/workspace/assign-workspaces.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
DropdownMenuTrigger
} from "../ui/dropdown-menu"
import { Input } from "../ui/input"
import { toast } from "sonner"

interface AssignWorkspaces {
selectedWorkspaces: Tables<"workspaces">[]
Expand Down Expand Up @@ -135,7 +136,7 @@ const WorkspaceItem: FC<WorkspaceItemProps> = ({
}) => {
const handleSelect = () => {
if (selected && selectedWorkspaces.length === 1) {
alert("You must select at least one workspace")
toast.info("You must select at least one workspace")
return
}

Expand Down

0 comments on commit 66f4bd6

Please sign in to comment.