Skip to content

Commit

Permalink
feat: bounty tab added
Browse files Browse the repository at this point in the history
  • Loading branch information
mayank-dev07 committed Nov 6, 2024
1 parent ef3d177 commit 199a4a4
Show file tree
Hide file tree
Showing 6 changed files with 275 additions and 40 deletions.
193 changes: 193 additions & 0 deletions src/app/(pages)/listunescrowed/component/Bounty.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
"use client";
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar";
import {
Card,
CardContent,
CardDescription,
CardFooter,
CardHeader,
CardTitle,
} from "@/components/ui/card";
import { Label } from "@/components/ui/label";
import { Input } from "@/components/ui/input";
import React, { useEffect, useState } from "react";
import { ArrowBigLeft, ArrowBigRight } from "lucide-react";
import NextButton from "@/components/Button/NextButton";
import { useDispatch, useSelector } from "react-redux";

import { Textarea } from "@/components/ui/textarea";
import Image from "next/image";
import {
setBountyDescription,
setBountyName,
setPrice,
} from "@/app/Redux/Features/profile/profileSlice";

type Props = {
onPrev: () => void;
onNext: () => void;
};

const Bounty = ({ onPrev, onNext }: Props) => {
const dispatch = useDispatch();
const profile = useSelector((state: any) => state.profile);

useEffect(() => {
console.log(profile);
}, [profile]);

const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
console.log(event.target.name);
switch (event.target.name) {
case "bountyname": {
dispatch(setBountyName(event.target.value));
break;
}
case "price": {
const numericValue = event.target.value.replace(/\D/g, "");
if (/^\d*$/.test(numericValue)) {
dispatch(setPrice(numericValue ? parseInt(numericValue, 10) : 0));
}
}
default: {
break;
}
}
};

const handleDescriptionChange = (
event: React.ChangeEvent<HTMLTextAreaElement>
) => {
dispatch(setBountyDescription(event.target.value));
};

return (
<Card className="">
<CardHeader>
<CardTitle>Profile</CardTitle>
<CardDescription>
Make changes to your account here. Click save when you&apos;re done.
</CardDescription>
</CardHeader>
<CardContent className="py-4 px-12">
<div className="flex flex-col gap-4">
<div className=" flex gap-12 w-full border-[1px] border-gray-900 rounded-lg p-4 ">
<Image
src={profile.image}
alt="user image"
className="aspect-square rounded-md"
width={100}
height={100}
/>

<div className="w-full flex flex-col justify-center items-center mr-12 gap-2">
<p className="underline underline-offset-4">{profile.name}</p>
<p className="text-gray-500">{profile.description}</p>
</div>
</div>
<div className="w-full grid grid-cols-1 gap-4">
<div className=" grid grid-cols-2 gap-6">
<div className="space-y-1">
<Label htmlFor="first-name">Bounty Name</Label>
<Input
id="first-name"
placeholder="Enter your name"
name="bountyname"
value={profile.bountyname}
onChange={handleChange}
/>
</div>
<div className="space-y-1">
<Label htmlFor="first-name">Bounty Price</Label>
<Input
id="first-name"
placeholder="Enter Bounty Price"
name="price"
value={`$${profile.price || ""}`}
onChange={handleChange}
/>
</div>
</div>
</div>
<div className=" grid grid-cols-1 gap-6">
<div className="space-y-1">
<Label htmlFor="first-name">Bounty Description</Label>
<Textarea
id="first-name"
placeholder="Enter your Project Description"
name="bountyDescription"
value={profile.bountyDescription}
onChange={handleDescriptionChange}
/>
</div>
</div>{" "}
{/* <div className=" grid grid-cols-2 gap-6">
<div className="space-y-1">
<Label htmlFor="first-name">Github</Label>
<Input
id="first-name"
placeholder="https://github.com/...."
value={user?.login}
/>
</div>
<div className="space-y-1">
<Label htmlFor="first-name">Twitter</Label>
<Input
id="first-name"
placeholder="@your_twitter_handle"
name="twitter"
value={profile.twitter}
onChange={handleChange}
/>
</div>
</div> */}
{/* <div className=" grid grid-cols-2 gap-6">
<div className="space-y-1">
<Label htmlFor="first-name">Telegram</Label>
<Input
id="first-name"
placeholder="@your_telegram_handle"
name="telegram"
value={profile.telegram}
onChange={handleChange}
/>
</div>
<div className="space-y-1">
<Label htmlFor="first-name">Discord</Label>
<Input
id="first-name"
placeholder="your_discord_handle"
name="discord"
value={profile.discord}
onChange={handleChange}
/>
</div>
</div> */}
</div>
</CardContent>

<CardFooter>
<div className="w-full flex justify-between items-center">
<NextButton onClick={onPrev}>
<div className="flex gap-2 items-center">
<ArrowBigLeft size={20} />
PREV
</div>
</NextButton>

<NextButton
onClick={onNext}
disabled={!profile.name || !profile.image}
>
<div className="flex gap-2 items-center">
NEXT
<ArrowBigRight size={20} />
</div>
</NextButton>
</div>
</CardFooter>
</Card>
);
};

export default Bounty;
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { useDispatch, useSelector } from "react-redux";
import {
setDescription,
setDiscord,
setGithub,
setImage,
setLink,
setName,
Expand All @@ -37,16 +36,12 @@ type Props = {
onNext: () => void;
};

const Tab2 = ({ onPrev, onNext }: Props) => {
const Profile = ({ onPrev, onNext }: Props) => {
const [avatar, setAvatar] = useState("");
const image = useSelector((state: any) => state.profile.image);
const [isDragging, setIsDragging] = useState(false);
const user = useSelector((state: any) => state.user);
const dispatch = useDispatch();
const profile = useSelector((state: any) => state.profile);
useEffect(() => {
console.log(profile);
}, [image, profile]);

const handleAvatarChange = (event: React.ChangeEvent<HTMLInputElement>) => {
const file = event.target.files?.[0];
Expand Down Expand Up @@ -94,9 +89,6 @@ const Tab2 = ({ onPrev, onNext }: Props) => {
case "link":
dispatch(setLink(event.target.value));
break;
case "github":
dispatch(setGithub(event.target.value));
break;
case "twitter":
dispatch(setTwitter(event.target.value));
break;
Expand Down Expand Up @@ -252,7 +244,10 @@ const Tab2 = ({ onPrev, onNext }: Props) => {
</div>
</NextButton>

<NextButton onClick={onNext}>
<NextButton
onClick={onNext}
// disabled={!profile.name || !profile.image}
>
<div className="flex gap-2 items-center">
NEXT
<ArrowBigRight size={20} />
Expand All @@ -264,4 +259,4 @@ const Tab2 = ({ onPrev, onNext }: Props) => {
);
};

export default Tab2;
export default Profile;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ type Props = {
onNext: () => void;
};

const Tab1 = ({ onNext }: Props) => {
const Who = ({ onNext }: Props) => {
const dispatch = useDispatch();
const who = useSelector((state: any) => state.profile.who);

Expand Down Expand Up @@ -76,7 +76,7 @@ const Tab1 = ({ onNext }: Props) => {
</div>
</CardContent>
<CardFooter className="w-full flex justify-end">
<NextButton onClick={onNext}>
<NextButton onClick={onNext} disabled={!who}>
<div className="flex items-center gap-2">
NEXT
<ArrowBigRight size={20} />
Expand Down Expand Up @@ -109,4 +109,4 @@ const Tab1 = ({ onNext }: Props) => {
);
};

export default Tab1;
export default Who;
38 changes: 24 additions & 14 deletions src/app/(pages)/listunescrowed/page.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
"use client";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { useState } from "react";
import Tab1 from "./component/Tab1";
import Tab2 from "./component/Tab2";
import Who from "./component/Who";
import Profile from "./component/Profile";
import Bounty from "./component/Bounty";

export default function ListUnescrowed() {
const [activeTab, setActiveTab] = useState<string>("personal_Details");
const [activeTab, setActiveTab] = useState<string>("who");

const handleNextClick = (value: string) => {
setActiveTab(value);
Expand All @@ -22,21 +23,30 @@ export default function ListUnescrowed() {
onValueChange={setActiveTab}
className="w-11/12 md:w-10/12 lg:w-8/12 px-0 md:px-5"
>
<TabsList className="grid w-full h-full grid-cols-1 grid-rows-3 md:grid-cols-5 md:grid-rows-1 mb-12">
<TabsTrigger value="personal_Details" className="pointer-events-none">
Personal Details
<TabsList className="grid w-full h-full grid-cols-1 grid-rows-3 md:grid-cols-3 md:grid-rows-1 mb-12">
<TabsTrigger value="who" className="pointer-events-none">
Who
</TabsTrigger>
<TabsTrigger value="password" className="pointer-events-none">
Password
<TabsTrigger value="profile" className="pointer-events-none">
Profile
</TabsTrigger>
<TabsTrigger value="bounty" className="pointer-events-none">
Bounty
</TabsTrigger>
</TabsList>
<TabsContent value="personal_Details">
<Tab1 onNext={() => handleNextClick("password")} />
<TabsContent value="who">
<Who onNext={() => handleNextClick("profile")} />
</TabsContent>
<TabsContent value="profile">
<Profile
onPrev={() => handlePrevClick("who")}
onNext={() => handleNextClick("bounty")}
/>
</TabsContent>
<TabsContent value="password">
<Tab2
onPrev={() => handlePrevClick("personal_Details")}
onNext={() => handleNextClick("password")}
<TabsContent value="bounty">
<Bounty
onPrev={() => handlePrevClick("profile")}
onNext={() => handleNextClick("bunty")}
/>
</TabsContent>
</Tabs>
Expand Down
Loading

0 comments on commit 199a4a4

Please sign in to comment.