mirror of
https://github.com/i701/sarlink-portal.git
synced 2025-08-03 21:17:44 +00:00
feat(user-update-form): display field errors in user update form ✨
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 7m52s
All checks were successful
Build and Push Docker Images / Build and Push Docker Images (push) Successful in 7m52s
This commit is contained in:
@ -6,15 +6,6 @@ import { type UpdateUserFormState, updateUser } from "@/actions/user-actions";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { FloatingLabelInput } from "@/components/ui/floating-label";
|
||||
import type { UserProfile } from "@/lib/types/user";
|
||||
// import {
|
||||
// Select,
|
||||
// SelectContent,
|
||||
// SelectGroup,
|
||||
// SelectItem,
|
||||
// SelectLabel,
|
||||
// SelectTrigger,
|
||||
// SelectValue,
|
||||
// } from "@/components/ui/select";
|
||||
|
||||
export default function UserUpdateForm({ user }: { user: UserProfile }) {
|
||||
const initialState: UpdateUserFormState = {
|
||||
@ -59,6 +50,21 @@ export default function UserUpdateForm({ user }: { user: UserProfile }) {
|
||||
Update User Information
|
||||
</h4>
|
||||
<div className="border border-dashed border-sarLinkOrange p-4 rounded-lg max-w-2xl">
|
||||
<div>
|
||||
{state.fieldErrors && Object.keys(state.fieldErrors).length > 0 ? (
|
||||
<div className="text-red-500 mb-5 border border-red-500 p-2 rounded">
|
||||
{Object.entries(state.fieldErrors).map(([field, errors]) => (
|
||||
<div key={field}>
|
||||
{errors.map((error, index) => (
|
||||
<p key={`${index + 1}`}>
|
||||
Error in {field}: {error}
|
||||
</p>
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
<fieldset
|
||||
disabled={isPending}
|
||||
className="space-y-1 my-2 grid grid-cols-1 md:grid-cols-2 gap-4"
|
||||
|
Reference in New Issue
Block a user