Skip to content

Commit

Permalink
Add project
Browse files Browse the repository at this point in the history
  • Loading branch information
pontusab committed Feb 12, 2024
1 parent e7021f6 commit d645c47
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 33 deletions.
4 changes: 2 additions & 2 deletions apps/dashboard/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"@tanstack/react-table": "^8.11.8",
"@todesktop/client-active-win": "^0.15.0",
"@todesktop/client-core": "^1.2.4",
"@trigger.dev/nextjs": "^2.3.17",
"@trigger.dev/nextjs": "^2.3.18",
"@uidotdev/usehooks": "^2.4.1",
"@vercel/edge-config": "^0.4.1",
"@vercel/edge-config": "^1.0.0",
"@vercel/speed-insights": "^1.0.9",
"@zip.js/zip.js": "2.7.34",
"base64-arraybuffer": "^1.0.2",
Expand Down
4 changes: 2 additions & 2 deletions apps/dashboard/src/actions/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ export const createProjectSchema = z.object({
billable: z.boolean().optional().default(false),
rate: z.number().min(1).optional(),
currency: z.string().optional(),
status: z.enum(["in_progress", "completed"]),
status: z.enum(["in_progress", "completed"]).optional(),
});

export const updateProjectSchema = z.object({
Expand All @@ -227,7 +227,7 @@ export const updateProjectSchema = z.object({
billable: z.boolean().optional().default(false),
rate: z.number().min(1).optional(),
currency: z.string().optional(),
status: z.enum(["in_progress", "completed"]),
status: z.enum(["in_progress", "completed"]).optional(),
});

export const deleteProjectSchema = z.object({
Expand Down
3 changes: 2 additions & 1 deletion apps/dashboard/src/components/select-transaction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,8 @@ export function SelectTransaction({
onFocus={handleFocus}
hidden={isHidden}
placeholder={placeholder}
className="w-full border-0 bg-transparent px-12"
className="w-full border-0 bg-transparent px-12 placeholder:text-muted-foreground dark:placeholder:text-foreground"
classNameList="bottom-[44px]"
value={value}
defaultValue={selectedTransaction?.name}
onValueChange={handleChange}
Expand Down
2 changes: 1 addition & 1 deletion apps/dashboard/src/components/sheets/tracker-sheet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ export function TrackerSheet({ setParams, isOpen, params, project, user }) {

{params.projectId === "new" && (
<div className="mb-6">
<TrackerSelectProject />
<TrackerSelectProject setParams={setParams} />
</div>
)}

Expand Down
70 changes: 55 additions & 15 deletions apps/dashboard/src/components/tracker-select-project.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,67 @@
"use client";

import { createProjectAction } from "@/actions/project/create-project-action";
import { createClient } from "@midday/supabase/client";
import { getTrackerProjectsQuery } from "@midday/supabase/queries";
import { Combobox } from "@midday/ui/combobox";
import { useState } from "react";
import { Icons } from "@midday/ui/icons";
import { useToast } from "@midday/ui/use-toast";
import { useAction } from "next-safe-action/hooks";
import { useEffect, useState } from "react";

export function TrackerSelectProject() {
export function TrackerSelectProject({ setParams }) {
const { toast } = useToast();
const supabase = createClient();
const [value, setValue] = useState("");
const [data, setData] = useState([]);

const onSelect = (selected) => {
console.log(selected);
const action = useAction(createProjectAction, {
onSuccess: (project) => {
setParams({ projectId: project.id });
},
onError: () => {
toast({
duration: 3500,
variant: "error",
title: "Something went wrong pleaase try again.",
});
},
});

async function fetchData() {
const { data: projectsData } = await getTrackerProjectsQuery(supabase, {
teamId: "dd6a039e-d071-423a-9a4d-9ba71325d890", // TODO: Fix
to: 100,
});

setData(projectsData);
}

useEffect(() => {
if (!data.length) {
fetchData();
}
}, [data]);

const onSelect = (project) => {
setParams({ projectId: project.id });
};

return (
<Combobox
placeholder="Search or create project"
className="w-full relative"
classNameList="top-[50px] bottom-0 h-[100px]"
value={value}
onValueChange={setValue}
onSelect={onSelect}
options={[{ id: "1", name: "Hej" }]}
hidden={false}
onCreate={() => {}}
/>
<div className="relative">
<Icons.Search className="absolute pointer-events-none left-3 top-[12px] z-[51]" />

<Combobox
placeholder="Search or create project"
className="w-full relative pl-9"
classNameList="top-[37px] rounded-none rounded-b-md"
value={value}
onValueChange={setValue}
onSelect={onSelect}
options={data}
hidden={false}
onCreate={(name) => action.execute({ name })}
/>
</div>
);
}
Binary file modified bun.lockb
Binary file not shown.
8 changes: 4 additions & 4 deletions packages/jobs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
},
"dependencies": {
"@trigger.dev/openai": "latest",
"@trigger.dev/react": "^2.3.17",
"@trigger.dev/resend": "^2.3.17",
"@trigger.dev/sdk": "^2.3.17",
"@trigger.dev/supabase": "^2.3.17",
"@trigger.dev/react": "^2.3.18",
"@trigger.dev/resend": "^2.3.18",
"@trigger.dev/sdk": "^2.3.18",
"@trigger.dev/supabase": "^2.3.18",
"langchain": "0.1.17",
"nanoid": "^5.0.5",
"pdf-parse": "^1.1.1"
Expand Down
15 changes: 7 additions & 8 deletions packages/ui/src/components/combobox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,13 @@ export const Combobox = React.forwardRef<HTMLInputElement, Props>(
)}
</div>

<CommandList
hidden={hidden}
className={cn(
"absolute z-50 bg-background w-full border rounded-md bottom-[44px] left-0 right-0",
classNameList
)}
>
<CommandGroup className="max-h-[145px] overflow-auto">
<CommandList hidden={hidden}>
<CommandGroup
className={cn(
"absolute w-full bg-background z-50 max-h-[250px] overflow-auto border border-t-0 rounded-md",
classNameList
)}
>
{options?.map(({ component: Component, ...option }) => {
return (
<CommandItem
Expand Down

0 comments on commit d645c47

Please sign in to comment.