feat(project-cloning): Project-Clone Endpoint + UI-Button [tsc:fail]
This commit is contained in:
parent
785b16b924
commit
c3bdf1e5f4
@ -1,9 +1,10 @@
|
||||
{
|
||||
"completed_features": [],
|
||||
"current_feature": "customer-archive",
|
||||
"current_feature": "project-cloning",
|
||||
"started_at": "2026-05-23T06:21:46.924268",
|
||||
"attempted_features": [
|
||||
"onboarding-tour",
|
||||
"time-entry-csv-import"
|
||||
"time-entry-csv-import",
|
||||
"customer-archive"
|
||||
]
|
||||
}
|
||||
@ -1361,3 +1361,22 @@ src/index.ts(27,25): error TS2769: No overload matches this call.
|
||||
Overload 2 of 3, '(plugin: FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
|
||||
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
|
||||
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTy
|
||||
- `06:27:29` **INFO** Committed feature customer-archive
|
||||
- `06:27:29` **INFO** Pushed: rc=0
|
||||
|
||||
## Phase-3 Feature: project-cloning (2026-05-23 06:27:29)
|
||||
|
||||
- `06:27:29` **INFO** Description: Project-Clone Endpoint + UI-Button
|
||||
- `06:27:29` **INFO** Generating apps/api/src/routes/projects.ts (ERWEITERT — behalte alles. Füge POST /:id/clone (body optional: {name}…)
|
||||
- `06:28:12` **INFO** wrote 4670 chars in 43.1s (attempt 1)
|
||||
- `06:28:12` **INFO** Generating apps/web/src/pages/Projects.tsx (ERWEITERT — füge Clone-Button (Copy-Icon lucide-react) pro Row. Mutati…)
|
||||
- `06:29:02` **INFO** wrote 6180 chars in 50.1s (attempt 1)
|
||||
- `06:29:02` **INFO** Running tsc --noEmit on api…
|
||||
- `06:29:04` **WARN** tsc errors:
|
||||
src/index.ts(27,25): error TS2769: No overload matches this call.
|
||||
Overload 1 of 3, '(plugin: FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
|
||||
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginCallback<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
|
||||
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTypeProvider>, opts: { ...; }, done: (err?: Error | undefined) => void): void'.
|
||||
Overload 2 of 3, '(plugin: FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>, opts?: FastifyRegisterOptions<...> | undefined): FastifyInstance<...> & PromiseLike<...>', gave the following error.
|
||||
Argument of type 'Promise<FastifyMultipartPlugin>' is not assignable to parameter of type 'FastifyPluginAsync<{ limits: { fileSize: number; }; }, RawServerDefault, FastifyTypeProvider, FastifyBaseLogger>'.
|
||||
Type 'Promise<FastifyMultipartPlugin>' provides no match for the signature '(instance: FastifyInstance<RawServerDefault, IncomingMessage, ServerResponse<IncomingMessage>, FastifyBaseLogger, FastifyTy
|
||||
|
||||
@ -11,6 +11,10 @@ const ProjectSchema = z.object({
|
||||
|
||||
const ProjectUpdateSchema = ProjectSchema.partial()
|
||||
|
||||
const ProjectCloneSchema = z.object({
|
||||
name: z.string().optional()
|
||||
})
|
||||
|
||||
export default async function projectRoutes(fastify: FastifyInstance) {
|
||||
fastify.addHook("preHandler", async (request, reply) => {
|
||||
try {
|
||||
@ -117,6 +121,32 @@ export default async function projectRoutes(fastify: FastifyInstance) {
|
||||
return reply.code(201).send(project)
|
||||
})
|
||||
|
||||
fastify.post("/:id/clone", async (request, reply) => {
|
||||
const { id } = request.params as { id: string }
|
||||
const body = ProjectCloneSchema.parse(request.body || {})
|
||||
|
||||
const [original] = await db
|
||||
.select()
|
||||
.from(projects)
|
||||
.where(eq(projects.id, id))
|
||||
.limit(1)
|
||||
|
||||
if (!original) {
|
||||
return reply.code(404).send({ message: "Project not found" })
|
||||
}
|
||||
|
||||
const [cloned] = await db
|
||||
.insert(projects)
|
||||
.values({
|
||||
name: body.name || `${original.name} (Kopie)`,
|
||||
customerId: original.customerId,
|
||||
active: original.active
|
||||
})
|
||||
.returning()
|
||||
|
||||
return reply.code(201).send(cloned)
|
||||
})
|
||||
|
||||
fastify.patch("/:id", async (request, reply) => {
|
||||
const { id } = request.params as { id: string }
|
||||
const body = ProjectUpdateSchema.parse(request.body)
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
import { useState } from "react"
|
||||
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query"
|
||||
import { Copy, Trash2 } from "lucide-react"
|
||||
import { api } from "../lib/api"
|
||||
|
||||
export default function Projects() {
|
||||
@ -27,6 +28,13 @@ export default function Projects() {
|
||||
}
|
||||
})
|
||||
|
||||
const cloneMutation = useMutation({
|
||||
mutationFn: (id: string) => api.cloneProject(id),
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries({ queryKey: ["projects"] })
|
||||
}
|
||||
})
|
||||
|
||||
const deleteMutation = useMutation({
|
||||
mutationFn: (id: string) => api.deleteProject(id),
|
||||
onSuccess: () => {
|
||||
@ -102,31 +110,37 @@ export default function Projects() {
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody className="divide-y divide-gray-200">
|
||||
{projects && projects.length > 0 ? (
|
||||
projects.map((project: any) => (
|
||||
<tr key={project.id} className="hover:bg-gray-50 transition-colors">
|
||||
<td className="px-6 py-4 text-sm text-gray-900 font-medium">{project.name}</td>
|
||||
<td className="px-6 py-4 text-sm text-gray-600">
|
||||
{customers?.find((c: any) => c.id === project.customerId)?.name || "Unknown Customer"}
|
||||
</td>
|
||||
<td className="px-6 py-4 text-right">
|
||||
<button
|
||||
onClick={() => {
|
||||
if (confirm("Are you sure you want to delete this project?")) {
|
||||
deleteMutation.mutate(project.id)
|
||||
}
|
||||
}}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="text-red-600 hover:text-red-800 text-sm font-medium disabled:text-gray-400"
|
||||
>
|
||||
Delete
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))
|
||||
) : (
|
||||
{projects?.map((project: any) => (
|
||||
<tr key={project.id} className="hover:bg-gray-50 transition-colors">
|
||||
<td className="px-6 py-4 text-sm text-gray-900">{project.name}</td>
|
||||
<td className="px-6 py-4 text-sm text-gray-500">{project.customer?.name || "N/A"}</td>
|
||||
<td className="px-6 py-4 text-right space-x-2">
|
||||
<button
|
||||
onClick={() => cloneMutation.mutate(project.id)}
|
||||
disabled={cloneMutation.isPending}
|
||||
className="p-2 text-gray-500 hover:text-blue-600 hover:bg-blue-50 rounded-md transition-colors disabled:opacity-50"
|
||||
title="Clone Project"
|
||||
>
|
||||
<Copy className="w-4 h-4" />
|
||||
</button>
|
||||
<button
|
||||
onClick={() => {
|
||||
if (confirm("Are you sure you want to delete this project?")) {
|
||||
deleteMutation.mutate(project.id)
|
||||
}
|
||||
}}
|
||||
disabled={deleteMutation.isPending}
|
||||
className="p-2 text-gray-500 hover:text-red-600 hover:bg-red-50 rounded-md transition-colors disabled:opacity-50"
|
||||
title="Delete Project"
|
||||
>
|
||||
<Trash2 className="w-4 h-4" />
|
||||
</button>
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
{projects?.length === 0 && (
|
||||
<tr>
|
||||
<td colSpan={3} className="px-6 py-10 text-center text-gray-500">No projects found. Create one above.</td>
|
||||
<td colSpan={3} className="px-6 py-10 text-center text-gray-500">No projects found.</td>
|
||||
</tr>
|
||||
)}
|
||||
</tbody>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user