Timify’s project actions are Next.js 16 Server Actions that run exclusively on the server. Every action first verifies the caller’s session viaDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/Aking16/timify/llms.txt
Use this file to discover all available pages before exploring further.
auth.api.getSession({ headers: await headers() }) and returns an error state immediately if no valid session is found. Successful mutations call revalidatePath and revalidateTag so the Next.js data cache stays consistent without a full page reload.
createProject
projects table, scoped to the authenticated user’s userId. After a successful insert the action revalidates the root path and two cache tags so project lists and individual project views are refreshed.
Signature
Parameters
Display name of the project. Must be at least 4 characters long. Validated by Zod before the database insert.
Optional free-text description of the project. Stored as-is;
null is accepted.Optional billing rate as a numeric string (e.g.
"75"). Converted to a number before storage. Defaults to 0 when omitted.Return Type
true when the project was created successfully; false on validation or database failure.Human-readable status message. Present on both success and failure.
The newly created project row returned by Drizzle’s
.returning() clause. Only present when success is true.Side Effects
| Operation | Value |
|---|---|
revalidatePath | / |
revalidateTag | get-projects |
revalidateTag | retrieve-project |
Usage Example
The
project field in the return value is typed as typeof projects.$inferSelect, which is Drizzle’s inferred row type for the projects table. Import CreateProjectState from the same module if you need the full state type.editProject
id. The fields id, name, and isActive are required; description, hourlyRate, and color are optional. The isActive field must always be supplied as a string ("true" or "false") because it travels through FormData.
Signature
Parameters
UUID of the project to update.
New display name. Must be between 4 and 32 characters.
Active status as a string boolean:
"true" or "false". Converted to a real boolean via convertStringToBoolean before the database update.Updated description. Optional.
Updated billing rate as a numeric string. Optional; converted to
number before storage.Hex colour string (e.g.
"#ef4444"). Optional.Return Type
true when the update succeeded.Human-readable status message.
Side Effects
| Operation | Value |
|---|---|
revalidatePath | /projects/ |
revalidateTag | get-projects |
revalidateTag | retrieve-project |
Usage Example
getProjects
projects table. This action uses Next.js "use cache" (PPR-compatible) with the get-projects cache tag, so repeated calls are served from the data cache until the tag is revalidated.
Signature
Parameters
This function accepts no parameters.Return Type
An array of all project rows. Each element has the same shape as the
project field described under createProject above. Returns an empty array when no projects exist.getProjects does not filter by userId at the query level — it relies on the cache tag get-projects being scoped correctly and is typically called inside a Server Component where route-level authentication is already enforced by the auth guard. Avoid calling it from unauthenticated contexts.Usage Example
retrieveProject
getProjects, it uses "use cache" with the retrieve-project cache tag. Results are revalidated whenever createProject, editProject, or deleteProject mutates project data.
Signature
Parameters
UUID of the project to retrieve.
Return Type
The matching project row. Has the same shape as the
project field described under createProject. The function returns undefined (as an untyped gap) if no row matches — callers should guard against this.Usage Example
deleteProject
projects table has onDelete: "cascade" on the time_entries.project_id foreign key, deleting a project also nullifies the projectId column on any associated time entries (set to null). The function takes a plain string argument rather than FormData.
Signature
Parameters
UUID of the project to delete. Returns an error state if the string is empty.
Return Type
true when deletion succeeded.Human-readable status message.
Side Effects
| Operation | Value |
|---|---|
revalidatePath | /projects/ |
revalidateTag | get-projects |
revalidateTag | retrieve-project |
