File tree Expand file tree Collapse file tree 2 files changed +43
-4
lines changed
src/components/quick-wins Expand file tree Collapse file tree 2 files changed +43
-4
lines changed Original file line number Diff line number Diff line change 11"use client" ;
22
3- import { useState , useMemo } from "react" ;
3+ import { useState , useMemo , useCallback } from "react" ;
44import {
55 useReactTable ,
66 getCoreRowModel ,
@@ -45,6 +45,7 @@ import {
4545
4646import { createColumns } from "./columns" ;
4747import type { GitHubIssue } from "@/types/quickWins" ;
48+ import { useKanbanStore } from "@/stores/kanban" ;
4849
4950interface QuickWinsTableProps {
5051 data : GitHubIssue [ ] ;
@@ -70,7 +71,21 @@ export function QuickWinsTable({
7071
7172 const [ languageFilter , setLanguageFilter ] = useState < string > ( "all" ) ;
7273
73- const columns = useMemo ( ( ) => createColumns ( ) , [ ] ) ;
74+ const addTask = useKanbanStore ( ( state ) => state . addTask ) ;
75+
76+ const handleAddToKanban = useCallback ( ( issue : GitHubIssue ) => {
77+ addTask ( {
78+ title : issue . title ,
79+ description : `From ${ issue . repository } ` ,
80+ type : "github-issue" ,
81+ priority : issue . priority ,
82+ githubUrl : issue . url ,
83+ labels : issue . labels . map ( ( label ) => label . name ) ,
84+ columnId : "todo" ,
85+ } ) ;
86+ } , [ addTask ] ) ;
87+
88+ const columns = useMemo ( ( ) => createColumns ( { onAddToKanban : handleAddToKanban } ) , [ handleAddToKanban ] ) ;
7489
7590 const filteredData = useMemo ( ( ) => {
7691 let filtered = data ;
Original file line number Diff line number Diff line change @@ -2,10 +2,14 @@ import { ColumnDef } from "@tanstack/react-table";
22import { Badge } from "@/components/ui/badge" ;
33import { Button } from "@/components/ui/button" ;
44import { Avatar , AvatarFallback , AvatarImage } from "@/components/ui/avatar" ;
5- import { ExternalLink , Calendar } from "lucide-react" ;
5+ import { ExternalLink , Calendar , ListPlus } from "lucide-react" ;
66import type { GitHubIssue } from "@/types/quickWins" ;
77
8- export const createColumns = ( ) : ColumnDef < GitHubIssue > [ ] => [
8+ interface CreateColumnsOptions {
9+ onAddToKanban ?: ( issue : GitHubIssue ) => void ;
10+ }
11+
12+ export const createColumns = ( options ?: CreateColumnsOptions ) : ColumnDef < GitHubIssue > [ ] => [
913 {
1014 accessorKey : "title" ,
1115 header : ( { column } ) => (
@@ -157,4 +161,24 @@ export const createColumns = (): ColumnDef<GitHubIssue>[] => [
157161 } ,
158162 enableSorting : false ,
159163 } ,
164+ {
165+ id : "actions" ,
166+ header : "Actions" ,
167+ cell : ( { row } ) => {
168+ const issue = row . original ;
169+ return (
170+ < Button
171+ size = "sm"
172+ variant = "outline"
173+ onClick = { ( ) => options ?. onAddToKanban ?.( issue ) }
174+ disabled = { ! options ?. onAddToKanban }
175+ className = "gap-1"
176+ >
177+ < ListPlus className = "w-4 h-4" />
178+ Add to Kanban
179+ </ Button >
180+ ) ;
181+ } ,
182+ enableSorting : false ,
183+ } ,
160184] ;
You can’t perform that action at this time.
0 commit comments