|
1 | 1 | "use client"; |
2 | 2 |
|
3 | | -import { useState } from "react"; |
4 | 3 | import ListVotings from "./ListVotings"; |
5 | 4 | import OwnedVotings from "./OwnedVotings"; |
6 | 5 | import ParticipatedVotings from "./ParticipatedVotings"; |
7 | 6 |
|
8 | 7 | interface VotingOverviewProps { |
9 | | - onCreateClick: () => void; |
| 8 | + activeTab: "all" | "owned" | "participated"; |
10 | 9 | } |
11 | 10 |
|
12 | | -const VotingOverview = ({ onCreateClick }: VotingOverviewProps) => { |
13 | | - const [activeTab, setActiveTab] = useState<"all" | "owned" | "participated">("owned"); |
14 | | - |
| 11 | +const VotingOverview = ({ activeTab }: VotingOverviewProps) => { |
15 | 12 | const tabs = [ |
16 | | - { id: "owned" as const, label: "My Votings", component: OwnedVotings }, |
17 | | - { id: "participated" as const, label: "I Can Vote", component: ParticipatedVotings }, |
18 | | - { id: "all" as const, label: "All Votings", component: ListVotings }, |
| 13 | + { id: "owned" as const, component: OwnedVotings }, |
| 14 | + { id: "participated" as const, component: ParticipatedVotings }, |
| 15 | + { id: "all" as const, component: ListVotings }, |
19 | 16 | ]; |
20 | 17 |
|
21 | 18 | const ActiveComponent = tabs.find(tab => tab.id === activeTab)?.component || ListVotings; |
22 | 19 |
|
23 | 20 | return ( |
24 | | - <div className="w-full space-y-6"> |
25 | | - <div className="flex flex-col sm:flex-row sm:items-center sm:justify-between gap-4"> |
26 | | - <div className="tabs tabs-boxed w-fit"> |
27 | | - {tabs.map(tab => ( |
28 | | - <button |
29 | | - key={tab.id} |
30 | | - className={`tab text-2xl font-medium ${activeTab === tab.id ? "tab-active" : ""}`} |
31 | | - onClick={() => setActiveTab(tab.id)} |
32 | | - > |
33 | | - {tab.label} |
34 | | - </button> |
35 | | - ))} |
36 | | - </div> |
37 | | - |
38 | | - <button |
39 | | - className="btn btn-primary gap-2 shadow-lg hover:scale-105 transition-transform" |
40 | | - onClick={onCreateClick} |
41 | | - > |
42 | | - <svg |
43 | | - className="w-6 h-6" |
44 | | - fill="none" |
45 | | - stroke="currentColor" |
46 | | - viewBox="0 0 24 24" |
47 | | - xmlns="http://www.w3.org/2000/svg" |
48 | | - > |
49 | | - <path strokeLinecap="round" strokeLinejoin="round" strokeWidth={2} d="M12 4v16m8-8H4" /> |
50 | | - </svg> |
51 | | - Create Voting |
52 | | - </button> |
53 | | - </div> |
54 | | - |
55 | | - <div className="w-full max-h-[calc(3*280px+2*1rem)] overflow-y-auto pr-2"> |
56 | | - <ActiveComponent /> |
57 | | - </div> |
| 21 | + <div className="w-full"> |
| 22 | + <ActiveComponent /> |
58 | 23 | </div> |
59 | 24 | ); |
60 | 25 | }; |
|
0 commit comments