Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: various fixes and enhancements #2240

Merged
merged 17 commits into from
Jul 11, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
ui: add change password item to profile dropdown
  • Loading branch information
suhailkakar committed Jul 3, 2024
commit 4ac4283b204e2f808c2dcc913b2e9f8d27798e64
30 changes: 28 additions & 2 deletions packages/www/components/Sidebar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ import {
TerminalIcon,
UsageIcon,
} from "./NavIcons";
import { toast } from "sonner";
import { canSendEmail } from "lib/utils/can-send-email";

export const NavLink = styled(A, {
fontSize: 14,
Expand Down Expand Up @@ -76,7 +78,7 @@ export type SidebarId =
| "billing/plans";

const Sidebar = ({ id }: { id: SidebarId }) => {
const { user, logout } = useApi();
const { user, logout, makePasswordResetToken } = useApi();
const router = useRouter();

const June = useJune();
Expand All @@ -93,6 +95,25 @@ const Sidebar = ({ id }: { id: SidebarId }) => {
};
}, [June]);

const changePassword = async (e) => {
suhailkakar marked this conversation as resolved.
Show resolved Hide resolved
e.preventDefault();
const response = canSendEmail("resetPassword");
if (!response.canSend) {
toast(
`Please wait ${response.waitTime} seconds before sending another email.`
);
return;
}
const res = await makePasswordResetToken(user.email);
if (res.errors) {
res.errors.forEach((error) => {
toast(error);
});
} else {
toast("Password reset link sent to your email.");
}
};

return (
<Box
css={{
Expand Down Expand Up @@ -149,13 +170,18 @@ const Sidebar = ({ id }: { id: SidebarId }) => {
}}>
Billing
</DropdownMenuItem>
<DropdownMenuItem
key="change-password-dropdown-item"
onSelect={changePassword}>
Change Password
suhailkakar marked this conversation as resolved.
Show resolved Hide resolved
</DropdownMenuItem>
<DropdownMenuItem
key="logout-dropdown-item"
onSelect={(e) => {
e.preventDefault();
logout();
}}>
Logout
Log out
</DropdownMenuItem>
</DropdownMenuGroup>
</DropdownMenuContent>
Expand Down
Loading