feat: preferences states, change password layout

This commit is contained in:
mehedi-hasan 2024-04-18 17:51:14 +06:00
parent ef59ce97cb
commit 98475437a9
4 changed files with 114 additions and 82 deletions

View File

@ -3,14 +3,14 @@ import { Separator } from "@/components/ui/separator";
export default function SettingsProfilePage() { export default function SettingsProfilePage() {
return ( return (
<div className="flex-1 space-y-4 p-4 md:p-8 pt-6 max-w-[800px]"> <div className="flex-1 space-y-4 p-4 md:p-8 pt-6 h-full w-full flex justify-center items-center">
<div> {/* <div>
<h3 className="text-lg font-medium">Change Password</h3> <h3 className="text-lg font-medium">Change Password</h3>
<p className="text-sm text-muted-foreground"> <p className="text-sm text-muted-foreground">
Change your password carefully. Change your password carefully.
</p> </p>
</div> </div>
<Separator /> <Separator /> */}
<ChangePasswordForm /> <ChangePasswordForm />
</div> </div>
); );

View File

@ -77,11 +77,22 @@ const dummyPreferences = [
]; ];
const Page = () => { const Page = () => {
const [value, setValue] = useState([50]); const [preference, setPreference] = useState({
readability: [50],
refinement: [50],
modularity: [50],
optimization: [50],
portability: [50],
robustness: [50],
maintainability: [50],
conformity: [50],
security: [50],
functionality: [50],
});
return ( return (
<div className="flex-1 space-y-4 p-4 md:p-8 pt-6"> <div className="flex-1 space-y-4 p-4 md:p-8 pt-6 w-full h-full flex justify-center items-center">
<Card className="max-w-[600px]"> <Card className="max-w-[600px] w-full">
<CardHeader> <CardHeader>
<CardTitle className="mb-4 font-bold text-xl"> <CardTitle className="mb-4 font-bold text-xl">
Code Evaluation Criteria Code Evaluation Criteria
@ -90,8 +101,9 @@ const Page = () => {
</CardHeader> </CardHeader>
<CardContent> <CardContent>
<div className="grid grid-cols-2 gap-y-8 gap-x-16"> <div className="grid grid-cols-2 gap-y-4 md:gap-y-8 gap-x-8 md:gap-x-16">
{dummyPreferences.map((item) => ( {dummyPreferences.map(
(item: { id: number; name: string; description: string }) => (
<div key={item.id} className="space-y-6"> <div key={item.id} className="space-y-6">
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
<h4 className="capitalize font-semibold">{item.name}</h4> <h4 className="capitalize font-semibold">{item.name}</h4>
@ -99,28 +111,29 @@ const Page = () => {
<TooltipTrigger> <TooltipTrigger>
<CircleHelp className="size-4" /> <CircleHelp className="size-4" />
</TooltipTrigger> </TooltipTrigger>
<TooltipContent> <TooltipContent className="max-w-52">
<p>{item.description}</p> <p>{item.description}</p>
</TooltipContent> </TooltipContent>
</Tooltip> </Tooltip>
</div> </div>
<Slider <Slider
defaultValue={[50]} defaultValue={[50]}
value={value} // @ts-ignore
value={preference[item.name] as number[]}
onValueChange={(v) => { onValueChange={(v) => {
console.log(v); setPreference((p) => ({ ...p, [item.name]: v }));
setValue(v);
}} }}
min={0} min={0}
max={100} max={100}
step={1} step={1}
/> />
</div> </div>
))} )
)}
</div> </div>
</CardContent> </CardContent>
<CardFooter> <CardFooter>
<Button>Submit</Button> <Button className="w-full" size="lg">Submit</Button>
</CardFooter> </CardFooter>
</Card> </Card>
</div> </div>

View File

@ -15,6 +15,8 @@ import {
} from "@/components/ui/form"; } from "@/components/ui/form";
import { Input } from "@/components/ui/input"; import { Input } from "@/components/ui/input";
import { toast } from "@/components/ui/use-toast"; import { toast } from "@/components/ui/use-toast";
import { Card, CardContent, CardHeader, CardTitle } from "./ui/card";
import { Separator } from "./ui/separator";
const profileFormSchema = z.object({ const profileFormSchema = z.object({
currentPassword: z.string().trim().min(6, { currentPassword: z.string().trim().min(6, {
@ -66,6 +68,15 @@ export default function ChangePasswordForm() {
} }
return ( return (
<Card className="max-w-[600px] w-full">
<CardHeader>
<CardTitle className="mb-4 font-bold text-xl">
Change Password
</CardTitle>
<Separator />
</CardHeader>
<CardContent>
<Form {...form}> <Form {...form}>
<form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8"> <form onSubmit={form.handleSubmit(onSubmit)} className="space-y-8">
<FormField <FormField
@ -91,7 +102,10 @@ export default function ChangePasswordForm() {
<FormItem> <FormItem>
<FormLabel>New Password</FormLabel> <FormLabel>New Password</FormLabel>
<FormControl> <FormControl>
<Input placeholder="Enter your new password..." {...field} /> <Input
placeholder="Enter your new password..."
{...field}
/>
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>
@ -104,14 +118,19 @@ export default function ChangePasswordForm() {
<FormItem> <FormItem>
<FormLabel>Confirm New Password</FormLabel> <FormLabel>Confirm New Password</FormLabel>
<FormControl> <FormControl>
<Input placeholder="Confirm the new password..." {...field} /> <Input
placeholder="Confirm the new password..."
{...field}
/>
</FormControl> </FormControl>
<FormMessage /> <FormMessage />
</FormItem> </FormItem>
)} )}
/> />
<Button type="submit">Reset Password</Button> <Button type="submit" className="w-full" size="lg">Reset Password</Button>
</form> </form>
</Form> </Form>
</CardContent>
</Card>
); );
} }

View File

@ -12,12 +12,12 @@ const Slider = React.forwardRef<
<SliderPrimitive.Root <SliderPrimitive.Root
ref={ref} ref={ref}
className={cn( className={cn(
"relative flex w-full touch-none select-none items-center border", "relative flex w-full touch-none select-none items-center",
className className
)} )}
{...props} {...props}
> >
<SliderPrimitive.Track className="relative h-1.5 w-full grow overflow-hidden rounded-full bg-primary/20"> <SliderPrimitive.Track className="relative h-2 w-full grow overflow-hidden rounded-full bg-primary/20">
<SliderPrimitive.Range className="absolute h-full bg-primary" /> <SliderPrimitive.Range className="absolute h-full bg-primary" />
</SliderPrimitive.Track> </SliderPrimitive.Track>