Skip to content

Commit

Permalink
Merge pull request #21 from nextgen-ui-dev/issue-generator
Browse files Browse the repository at this point in the history
Issue generator
  • Loading branch information
jeremyalv authored Nov 7, 2023
2 parents 9229d8f + 15f340e commit daac0cd
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { IssuesList, type IssueData } from "./IssuesList";

import { Icon } from "@iconify/react";
import { TeamSelectionCombobox } from "./TeamSelectionCombobox";
import { useState } from "react";

interface GeneratedIssuesPageProps {
docId: string;
Expand Down Expand Up @@ -62,7 +63,7 @@ const GeneratedIssuesPage: React.FC<GeneratedIssuesPageProps> = ({
<div>
{GeneratedIssuesData ? (
<div>
<div className="flex items-center gap-x-4">
<div className="flex items-center gap-x-4 py-6">
{/* Select team + Export to linear */}
<TeamSelectionCombobox
handleSelectTeam={handleSelectTeam}
Expand Down
59 changes: 47 additions & 12 deletions src/modules/workspace/issue-generator/IssueDialog.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
Dialog,
DialogContent,
DialogDescription,
DialogFooter,
DialogClose,
DialogHeader,
DialogTitle,
DialogTrigger,
Expand All @@ -13,16 +13,41 @@ import { Label } from "~/components/ui/label";
import type { IssueData } from "./IssuesList";
import { IssuePriorityCombobox } from "./IssuePriorityCombobox";
import { Textarea } from "~/components/ui/textarea";
import React, { useState } from "react";

interface DialogProps {
trigger: string;
issue: IssueData;
changed: () => void;
}

export function IssueDialog({
trigger,
issue
issue,
changed
}: DialogProps) {
const [title, setTitle] = useState<string>(issue.title);
const [description, setDescription] = useState<string>(issue.description);
const [priority, setPriority] = useState<string>(issue.priority);

const handleTitle = (e: React.ChangeEvent<HTMLInputElement>) => {
setTitle(e.target.value);
issue.title = e.target.value;
changed();
}

const handleDesc = (e: React.ChangeEvent<HTMLTextAreaElement>) => {
setDescription(e.target.value);
issue.description = e.target.value;
changed();
}

const handlePriority = (newVal: string) => {
setPriority(newVal);
issue.priority = newVal;
changed();
}

return (
<Dialog>
<DialogTrigger asChild>
Expand All @@ -44,36 +69,46 @@ export function IssueDialog({
</DialogHeader>
<div className="grid gap-4 py-4">
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="title" className="text-xl text-right">
<Label htmlFor="title" className="text-xl text-right"
>
Title
</Label>
<Input
id="title"
defaultValue={`${issue.title}`}
defaultValue={`${title}`}
className="col-span-3"
/>
onChange={handleTitle}
/>
</div>
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="description" className="text-xl text-right">
<Label htmlFor="description" className="text-xl text-right"
>
Description
</Label>
<div className="col-span-3">
<Textarea
className="border border-white min-h-[100px]"
defaultValue={issue.description}
onChange={handleDesc}
defaultValue={description}
/>
</div>
</div>
<div className="grid grid-cols-4 items-center gap-4">
<Label htmlFor="priority" className="text-xl text-right">
<Label htmlFor="priority" className="text-xl text-right"
>
Priority
</Label>
<IssuePriorityCombobox />
<IssuePriorityCombobox
defaultVal={priority}
onChange={handlePriority}
/>
</div>
</div>
<DialogFooter>
<Button type="submit">Save changes</Button>
</DialogFooter>
<DialogClose>
<Button
type="submit"
>Save changes</Button>
</DialogClose>
</DialogContent>
</Dialog>
)
Expand Down
13 changes: 11 additions & 2 deletions src/modules/workspace/issue-generator/IssuePriorityCombobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,17 @@ const priorities = [
}
]

export function IssuePriorityCombobox() {
interface IssuePriorityType {
defaultVal?: string;
onChange: (newVal: string) => void;
}

export function IssuePriorityCombobox({
defaultVal,
onChange: handlePriority
}: IssuePriorityType) {
const [open, setOpen] = React.useState(false)
const [value, setValue] = React.useState("")
const [value, setValue] = React.useState(defaultVal)

return (
<Popover open={open} onOpenChange={setOpen}>
Expand Down Expand Up @@ -72,6 +80,7 @@ export function IssuePriorityCombobox() {
value={priority.value}
onSelect={(currentValue) => {
setValue(currentValue === value ? "" : currentValue)
handlePriority(currentValue)
setOpen(false)
}}
>
Expand Down
12 changes: 4 additions & 8 deletions src/modules/workspace/issue-generator/IssuesList.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import
React
// { useState }
React,
{ useState }
from "react";
// import { useRouter } from "next/router";
import type { User, Project } from "@linear/sdk";
Expand Down Expand Up @@ -48,12 +48,7 @@ export type IssueData = {
export const IssuesList: React.FC<{ issues: IssueData[]}> = ({
issues
}) => {
// const router = useRouter();
// const [workspaceId] = router.asPath
// .replace("/", "")
// .replace("/documents", "")
// .split("/");
// console.log("Issues", issues);
const [updated, setUpdated] = useState<boolean>();

return (
<div className="flex flex-col gap-y-2">
Expand Down Expand Up @@ -110,6 +105,7 @@ export const IssuesList: React.FC<{ issues: IssueData[]}> = ({
<IssueDialog
trigger="Edit"
issue={issue}
changed={() => setUpdated(!updated)}
/>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export function TeamSelectionCombobox({
<ChevronsUpDown className="ml-2 h-4 w-4 shrink-0 opacity-50" />
</Button>
</PopoverTrigger>
<PopoverContent className="w-[200px] p-0">
<PopoverContent className="w-[200px] p-.5">
<Command>
<CommandInput placeholder="Search team..." />
<CommandEmpty>No team found.</CommandEmpty>
Expand Down
4 changes: 0 additions & 4 deletions src/server/api/routers/workspace/issue.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,6 @@ export const issueRouter = createTRPCRouter({
"most_recent_created_at",
) as Date;

console.log(document.id);
console.log("maxTimestampResult", maxTimestampResult);
console.log("maxTimestamp", maxTimestamp);

// 1. Document Context Retrieval
const backgroundEmbedding = new Float32Array(
await embeddingModel.embedQuery(Questions.backgroundQuestion),
Expand Down

0 comments on commit daac0cd

Please sign in to comment.