Skip to content

Commit

Permalink
feat: ✨ feat(Settings-page-example): Update UI components and enhance…
Browse files Browse the repository at this point in the history
… settings page

Description:
This commit introduces updates to the user interface components and enhances the settings page. The changes are part of the ongoing work on the `Settings-page-example` branch.
-In `app/(protected)/_components/navbar.tsx`, `app/(protected)/admin/_components/page-type-card.tsx`, `app/(protected)/admin/page.tsx`, `app/(protected)/settings/page.tsx`, `components/user-info.tsx`, and `schemas/index.ts`, updates have been made to handle the UI enhancements and functionality updates.

Changes:
- Update `app/(protected)/_components/navbar.tsx` to add `shadow-md` class for shadow effect
- Update `app/(protected)/admin/_components/page-type-card.tsx`, `app/(protected)/admin/page.tsx`, `app/(protected)/settings/page.tsx`, `components/user-info.tsx`, and `schemas/index.ts` for functionality updates

This commit doesn't introduce any breaking changes. The updates are compatible with the existing codebase.
Co-authored-by: Ricardo Esteves <[email protected]>
  • Loading branch information
RicardoGEsteves and RicardoGEsteves committed Jan 15, 2024
1 parent 3326cd2 commit 232d95d
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 18 deletions.
4 changes: 2 additions & 2 deletions app/(protected)/_components/navbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const Navbar = () => {

return (
<>
<nav className="hidden lg:flex w-full fixed top-0 h-14 bg-secondary justify-between items-center p-4">
<nav className="hidden lg:flex w-full fixed top-0 h-14 bg-secondary justify-between items-center p-4 shadow-md">
<div className="flex gap-x-2">
{NAV_LINKS.map((link, index) => (
<Button
Expand All @@ -30,7 +30,7 @@ const Navbar = () => {
<UserButton />
</nav>

<nav className="flex bg-secondary items-center justify-between p-4 lg:hidden">
<nav className="flex bg-secondary items-center justify-between p-4 lg:hidden shadow-md">
<Sheet>
<SheetTrigger>
<Button
Expand Down
2 changes: 1 addition & 1 deletion app/(protected)/admin/_components/page-type-card.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type PageTypeCardProps = {

const PageTypeCard = ({ title, role }: PageTypeCardProps) => {
return (
<Card className="w-auto">
<Card className="w-auto shadow-sm">
<CardHeader>
<p className="text-2xl font-semibold text-center">{title}</p>
</CardHeader>
Expand Down
2 changes: 1 addition & 1 deletion app/(protected)/admin/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function AdminPage() {
};

return (
<Card className="w-auto">
<Card className="w-auto shadow-sm">
<CardHeader className="flex-row items-center justify-center gap-x-4">
<span>
<MdOutlineAdminPanelSettings className="h-10 w-10 text-sky-400" />
Expand Down
39 changes: 32 additions & 7 deletions app/(protected)/settings/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export default function SettingsPage() {
};

return (
<Card className="w-auto">
<Card className="w-auto shadow-sm">
<CardHeader className="flex-row items-center justify-center font-semibold gap-x-3">
<RiUserSettingsLine className="text-sky-400 text-3xl" />

Expand All @@ -104,8 +104,9 @@ export default function SettingsPage() {
<FormControl>
<Input
{...field}
placeholder="John Doe"
placeholder="Your Name"
disabled={isPending}
type="text"
/>
</FormControl>
<FormMessage />
Expand All @@ -123,7 +124,7 @@ export default function SettingsPage() {
<FormControl>
<Input
{...field}
placeholder="john.doe@example.com"
placeholder="your.email@example.com"
type="email"
disabled={isPending}
/>
Expand All @@ -132,36 +133,60 @@ export default function SettingsPage() {
</FormItem>
)}
/>

<FormField
control={form.control}
name="password"
render={({ field }) => (
<FormItem>
<FormLabel>Password</FormLabel>
<FormControl>
<Input
<PasswordInput
{...field}
placeholder="******"
type="password"
disabled={isPending}
value={field.value !== undefined ? field.value : ""}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>

<FormField
control={form.control}
name="newPassword"
render={({ field }) => (
<FormItem>
<FormLabel>New Password</FormLabel>
<FormControl>
<Input
<PasswordInput
{...field}
placeholder="******"
type="password"
disabled={isPending}
value={field.value !== undefined ? field.value : ""}
/>
</FormControl>
<FormMessage />
</FormItem>
)}
/>

<FormField
control={form.control}
name="newPasswordConfirmation"
render={({ field }) => (
<FormItem>
<FormLabel>New Password Confirmation</FormLabel>
<FormControl>
<PasswordInput
{...field}
placeholder="******"
type="password"
disabled={isPending}
value={field.value !== undefined ? field.value : ""}
/>
</FormControl>
<FormMessage />
Expand Down Expand Up @@ -200,11 +225,11 @@ export default function SettingsPage() {
control={form.control}
name="isTwoFactorEnabled"
render={({ field }) => (
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm">
<FormItem className="flex flex-row items-center justify-between rounded-lg border p-3 shadow-sm gap-x-2">
<div className="space-y-0.5">
<FormLabel>Two Factor Authentication</FormLabel>
<FormDescription>
Enable two factor authentication for your account
Enable two factor authentication for your account.
</FormDescription>
</div>
<FormControl>
Expand Down
2 changes: 1 addition & 1 deletion components/user-info.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const UserInfo = ({ user, label }: UserInfoProps) => {
};

return (
<Card className="w-auto">
<Card className="w-auto shadow-sm">
<CardHeader>
<p className="text-2xl font-semibold text-center">{label}</p>
</CardHeader>
Expand Down
22 changes: 16 additions & 6 deletions schemas/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,38 @@ export const SettingsSchema = z
isTwoFactorEnabled: z.optional(z.boolean()),
role: z.enum([UserRole.ADMIN, UserRole.USER]),
email: z.optional(z.string().email()),
password: z.optional(z.string().min(6)),
newPassword: z.optional(z.string().min(6)),
newPasswordConfirmation: z.optional(z.string().min(6)),
password: z.optional(z.string().min(1)),
newPassword: z.optional(
z.string().min(6, {
message:
"Please enter a new password with at least 6 characters, required",
})
),
newPasswordConfirmation: z.optional(
z.string().min(6, {
message:
"Please confirm your password with at least 6 characters, required",
})
),
})
.refine((data) => passwordRequired(data, "password", "newPassword"), {
message:
"Please enter a new password with at least 6 characters, required!",
path: ["newPassword"],
})
.refine((data) => passwordRequired(data, "newPassword", "password"), {
message: "Please enter your password is required!",
message: "Please enter your valid password, required!",
path: ["password"],
})
.refine((data) => data.password === data.newPasswordConfirmation, {
.refine((data) => data.newPassword === data.newPasswordConfirmation, {
message: "Passwords do not match.",
path: ["newPasswordConfirmation"],
});

export const NewPasswordSchema = z
.object({
password: z.string().min(6, {
message: "Please enter a password with at least 6 characters, required",
message: "Please enter your password, required",
}),
passwordConfirmation: z.string().min(6, {
message: "Please confirm your password, required.",
Expand Down

0 comments on commit 232d95d

Please sign in to comment.