diff --git a/README.md b/README.md index 6690dfe..5578c39 100644 --- a/README.md +++ b/README.md @@ -44,10 +44,12 @@ The same words are used in the code, the database and the screens. | Word | Meaning | | --------------- | ------------------------------------------------------------------------------------------ | | **User** | Anyone who signed in with a FreeIPA account | -| **Role** | What a user may do, derived from their FreeIPA groups: `member` or `admin` | +| **Role** | What a user may do, derived from their FreeIPA groups: `member`, `pixel` or `admin` | | **Member** | A user in a member group (`pixels`, `members`); does tasks | +| **Pixel** | A member in the `pixels` group; may also add own tasks | | **Admin** | A user in an admin group (`team_juhatus`); reviews proofs and manages tasks, never submits | | **Task** | Something to do for the club, worth points, in a **category** | +| **Own task** | A task a pixel adds for work they already did, sent with its proof; a reviewer sets points | | **Policy** | How often a task can be done: once per user, repeatable, first one wins | | **Proof** | What a member submits to show they did a task, often with photos | | **Reviewer** | An admin asked to review a proof, like a reviewer on a pull request | @@ -64,6 +66,7 @@ Who can do what: | Visitor | Read the feed, the leaderboard and user pages | | Signed in, no group | Also like, comment, and get notified of replies | | Member | Also browse tasks, submit proofs, and request reviewers | +| Pixel | Also add own tasks | | Admin | Review proofs, manage tasks and categories; never submits proofs | A proof with requested reviewers notifies them; without any, nobody is notified and it simply waits in the review queue. Groups are set in `src/config/access.ts`. Every rule lives in `src/domain/rules.ts`. diff --git a/SPEC.md b/SPEC.md index 6bb9b14..c33d071 100644 --- a/SPEC.md +++ b/SPEC.md @@ -15,6 +15,7 @@ Everyone signs in with their existing FreeIPA account. The app never creates or | Visitor | not signed in | Reads public pages | | Account | any other FreeIPA | Likes, comments, gets notified | | Member | `pixels`, `members` | Does tasks and submits proofs | +| Pixel | `pixels` | A member who may add own tasks | | Admin | `team_juhatus` | Reviews proofs and manages tasks | Admin replaces member: someone in both groups is an admin and never submits proofs, so nobody approves their own work. @@ -32,6 +33,7 @@ Every permission is a named rule in `src/domain/rules.ts`. Services enforce them | `userCanReadNotifications` | Signed in | | `userCanBrowseTasks` | Members | | `userCanSubmitProof` | Members | +| `userCanAddOwnTask` | Pixels | | `userCanReviewProofs` | Admins | | `userCanManageTasks` | Admins | | `userCanManageCategories` | Admins | @@ -68,6 +70,12 @@ The check runs twice: once in the service for a quick answer, and again in the d A proof is reviewed once; a second review of the same proof changes nothing. +### Own tasks + +A pixel can add an own task for work that is not on the task list (`/tasks/new`): a title, details, category, suggested points and optional photos. This creates a task only they did (`tasks.created_by` is the pixel) with a pending proof on it, so it goes through the normal review queue, feed and points ledger. Own tasks never show in the task lists. + +The reviewer may change the points when approving; the task's points are updated to match. Only own tasks accept a points override. Rejecting the proof archives the own task, so it cannot be resubmitted. + ### Photos - JPEG, PNG or WebP; size and count limits come from `NEXT_PUBLIC_PHOTO_MAX_FILE_SIZE_BYTES` and `NEXT_PUBLIC_PHOTO_MAX_PER_PROOF` (default 5 MB, 5 photos). diff --git a/migrations/0002_bouncy_trauma.sql b/migrations/0002_bouncy_trauma.sql new file mode 100644 index 0000000..1d198d9 --- /dev/null +++ b/migrations/0002_bouncy_trauma.sql @@ -0,0 +1,2 @@ +ALTER TABLE "proofs" ADD COLUMN "text_answer" text;--> statement-breakpoint +ALTER TABLE "tasks" ADD COLUMN "text_required" boolean DEFAULT false NOT NULL; \ No newline at end of file diff --git a/migrations/0003_sloppy_omega_red.sql b/migrations/0003_sloppy_omega_red.sql new file mode 100644 index 0000000..96426db --- /dev/null +++ b/migrations/0003_sloppy_omega_red.sql @@ -0,0 +1,2 @@ +ALTER TABLE "tasks" ADD COLUMN "created_by" uuid;--> statement-breakpoint +ALTER TABLE "tasks" ADD CONSTRAINT "tasks_created_by_users_id_fk" FOREIGN KEY ("created_by") REFERENCES "public"."users"("id") ON DELETE restrict ON UPDATE no action; \ No newline at end of file diff --git a/migrations/meta/0002_snapshot.json b/migrations/meta/0002_snapshot.json new file mode 100644 index 0000000..c3a0acb --- /dev/null +++ b/migrations/meta/0002_snapshot.json @@ -0,0 +1,1419 @@ +{ + "id": "1c7121a0-d880-489d-b24f-bb72ae6f2ffc", + "prevId": "13ba9111-2775-441c-b7b5-d35945a40a27", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.categories": { + "name": "categories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "categories_name_key": { + "name": "categories_name_key", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "categories_slug_key": { + "name": "categories_slug_key", + "columns": [ + { + "expression": "slug", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.proof_photos": { + "name": "proof_photos", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "proof_id": { + "name": "proof_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "object_key": { + "name": "object_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content_type": { + "name": "content_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size_bytes": { + "name": "size_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "uploaded_at": { + "name": "uploaded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "proof_photos_object_key_key": { + "name": "proof_photos_object_key_key", + "columns": [ + { + "expression": "object_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "proof_photos_proof_idx": { + "name": "proof_photos_proof_idx", + "columns": [ + { + "expression": "proof_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "proof_photos_proof_id_proofs_id_fk": { + "name": "proof_photos_proof_id_proofs_id_fk", + "tableFrom": "proof_photos", + "tableTo": "proofs", + "columnsFrom": [ + "proof_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.proof_review_requests": { + "name": "proof_review_requests", + "schema": "", + "columns": { + "proof_id": { + "name": "proof_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reviewer_id": { + "name": "reviewer_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "requested_at": { + "name": "requested_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "proof_review_requests_reviewer_idx": { + "name": "proof_review_requests_reviewer_idx", + "columns": [ + { + "expression": "reviewer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "proof_review_requests_proof_id_proofs_id_fk": { + "name": "proof_review_requests_proof_id_proofs_id_fk", + "tableFrom": "proof_review_requests", + "tableTo": "proofs", + "columnsFrom": [ + "proof_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "proof_review_requests_reviewer_id_users_id_fk": { + "name": "proof_review_requests_reviewer_id_users_id_fk", + "tableFrom": "proof_review_requests", + "tableTo": "users", + "columnsFrom": [ + "reviewer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "proof_review_requests_proof_id_reviewer_id_pk": { + "name": "proof_review_requests_proof_id_reviewer_id_pk", + "columns": [ + "proof_id", + "reviewer_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.proofs": { + "name": "proofs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "policy": { + "name": "policy", + "type": "task_policy", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "proof_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "text_answer": { + "name": "text_answer", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rejection_reason": { + "name": "rejection_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "submitted_at": { + "name": "submitted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reviewed_by": { + "name": "reviewed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "proofs_one_pending_per_user": { + "name": "proofs_one_pending_per_user", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"proofs\".\"status\" = 'pending'", + "concurrently": false, + "method": "btree", + "with": {} + }, + "proofs_single_winner_exclusive": { + "name": "proofs_single_winner_exclusive", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "(\"proofs\".\"policy\" = 'single_winner' and \"proofs\".\"status\" in ('pending', 'approved'))", + "concurrently": false, + "method": "btree", + "with": {} + }, + "proofs_one_approved_per_user": { + "name": "proofs_one_approved_per_user", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "(\"proofs\".\"policy\" = 'one_per_user' and \"proofs\".\"status\" = 'approved')", + "concurrently": false, + "method": "btree", + "with": {} + }, + "proofs_status_idx": { + "name": "proofs_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "proofs_user_idx": { + "name": "proofs_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "proofs_task_user_status_idx": { + "name": "proofs_task_user_status_idx", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "proofs_feed_idx": { + "name": "proofs_feed_idx", + "columns": [ + { + "expression": "reviewed_at", + "isExpression": false, + "asc": false, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": false, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"proofs\".\"status\" = 'approved'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "proofs_task_id_tasks_id_fk": { + "name": "proofs_task_id_tasks_id_fk", + "tableFrom": "proofs", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "proofs_user_id_users_id_fk": { + "name": "proofs_user_id_users_id_fk", + "tableFrom": "proofs", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "proofs_reviewed_by_users_id_fk": { + "name": "proofs_reviewed_by_users_id_fk", + "tableFrom": "proofs", + "tableTo": "users", + "columnsFrom": [ + "reviewed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.proof_comments": { + "name": "proof_comments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "proof_id": { + "name": "proof_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "proof_comments_proof_idx": { + "name": "proof_comments_proof_idx", + "columns": [ + { + "expression": "proof_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "proof_comments_user_recent_idx": { + "name": "proof_comments_user_recent_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": false, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "proof_comments_proof_id_proofs_id_fk": { + "name": "proof_comments_proof_id_proofs_id_fk", + "tableFrom": "proof_comments", + "tableTo": "proofs", + "columnsFrom": [ + "proof_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "proof_comments_user_id_users_id_fk": { + "name": "proof_comments_user_id_users_id_fk", + "tableFrom": "proof_comments", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.proof_likes": { + "name": "proof_likes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "proof_id": { + "name": "proof_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "proof_likes_proof_user_key": { + "name": "proof_likes_proof_user_key", + "columns": [ + { + "expression": "proof_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "proof_likes_proof_id_proofs_id_fk": { + "name": "proof_likes_proof_id_proofs_id_fk", + "tableFrom": "proof_likes", + "tableTo": "proofs", + "columnsFrom": [ + "proof_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "proof_likes_user_id_users_id_fk": { + "name": "proof_likes_user_id_users_id_fk", + "tableFrom": "proof_likes", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "ipa_unique_id": { + "name": "ipa_unique_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "uid": { + "name": "uid", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "excluded": { + "name": "excluded", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "freeipa_groups": { + "name": "freeipa_groups", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "users_ipa_unique_id_key": { + "name": "users_ipa_unique_id_key", + "columns": [ + { + "expression": "ipa_unique_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_uid_key": { + "name": "users_uid_key", + "columns": [ + { + "expression": "uid", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notifications": { + "name": "notifications", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "recipient_user_id": { + "name": "recipient_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "notification_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "proof_id": { + "name": "proof_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "notifications_recipient_idx": { + "name": "notifications_recipient_idx", + "columns": [ + { + "expression": "recipient_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": false, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notifications_unread_idx": { + "name": "notifications_unread_idx", + "columns": [ + { + "expression": "recipient_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"notifications\".\"read_at\" is null", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notifications_recipient_user_id_users_id_fk": { + "name": "notifications_recipient_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "columnsFrom": [ + "recipient_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notifications_proof_id_proofs_id_fk": { + "name": "notifications_proof_id_proofs_id_fk", + "tableFrom": "notifications", + "tableTo": "proofs", + "columnsFrom": [ + "proof_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notifications_task_id_tasks_id_fk": { + "name": "notifications_task_id_tasks_id_fk", + "tableFrom": "notifications", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.points_ledger": { + "name": "points_ledger", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "proof_id": { + "name": "proof_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "points": { + "name": "points", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "awarded_at": { + "name": "awarded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "points_ledger_proof_key": { + "name": "points_ledger_proof_key", + "columns": [ + { + "expression": "proof_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "points_ledger_user_idx": { + "name": "points_ledger_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "points_ledger_user_id_users_id_fk": { + "name": "points_ledger_user_id_users_id_fk", + "tableFrom": "points_ledger", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "points_ledger_proof_id_proofs_id_fk": { + "name": "points_ledger_proof_id_proofs_id_fk", + "tableFrom": "points_ledger", + "tableTo": "proofs", + "columnsFrom": [ + "proof_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tasks": { + "name": "tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "category_id": { + "name": "category_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "points": { + "name": "points", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "policy": { + "name": "policy", + "type": "task_policy", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "cooldown_seconds": { + "name": "cooldown_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "photo_required": { + "name": "photo_required", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "photo_instructions": { + "name": "photo_instructions", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text_required": { + "name": "text_required", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "tasks_category_idx": { + "name": "tasks_category_idx", + "columns": [ + { + "expression": "category_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tasks_active_idx": { + "name": "tasks_active_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tasks_active_category_title_idx": { + "name": "tasks_active_category_title_idx", + "columns": [ + { + "expression": "category_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "title", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"tasks\".\"archived_at\" is null", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "tasks_category_id_categories_id_fk": { + "name": "tasks_category_id_categories_id_fk", + "tableFrom": "tasks", + "tableTo": "categories", + "columnsFrom": [ + "category_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.push_subscriptions": { + "name": "push_subscriptions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "p256dh": { + "name": "p256dh", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "auth": { + "name": "auth", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "push_subscriptions_endpoint_key": { + "name": "push_subscriptions_endpoint_key", + "columns": [ + { + "expression": "endpoint", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "push_subscriptions_user_idx": { + "name": "push_subscriptions_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "push_subscriptions_user_id_users_id_fk": { + "name": "push_subscriptions_user_id_users_id_fk", + "tableFrom": "push_subscriptions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.photo_backups": { + "name": "photo_backups", + "schema": "", + "columns": { + "object_key": { + "name": "object_key", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "backed_up_at": { + "name": "backed_up_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "missing": { + "name": "missing", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.proof_status": { + "name": "proof_status", + "schema": "public", + "values": [ + "pending", + "approved", + "rejected" + ] + }, + "public.notification_type": { + "name": "notification_type", + "schema": "public", + "values": [ + "proof_submitted", + "review_requested", + "proof_approved", + "proof_rejected", + "proof_commented" + ] + }, + "public.task_policy": { + "name": "task_policy", + "schema": "public", + "values": [ + "single_winner", + "one_per_user", + "repeatable" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/migrations/meta/0003_snapshot.json b/migrations/meta/0003_snapshot.json new file mode 100644 index 0000000..1080f27 --- /dev/null +++ b/migrations/meta/0003_snapshot.json @@ -0,0 +1,1438 @@ +{ + "id": "044509c9-7236-48bb-a9b5-e429ca2825a7", + "prevId": "1c7121a0-d880-489d-b24f-bb72ae6f2ffc", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.categories": { + "name": "categories", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "name": { + "name": "name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "slug": { + "name": "slug", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "categories_name_key": { + "name": "categories_name_key", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "categories_slug_key": { + "name": "categories_slug_key", + "columns": [ + { + "expression": "slug", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.proof_photos": { + "name": "proof_photos", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "proof_id": { + "name": "proof_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "object_key": { + "name": "object_key", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "content_type": { + "name": "content_type", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "size_bytes": { + "name": "size_bytes", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "uploaded_at": { + "name": "uploaded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "proof_photos_object_key_key": { + "name": "proof_photos_object_key_key", + "columns": [ + { + "expression": "object_key", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "proof_photos_proof_idx": { + "name": "proof_photos_proof_idx", + "columns": [ + { + "expression": "proof_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "proof_photos_proof_id_proofs_id_fk": { + "name": "proof_photos_proof_id_proofs_id_fk", + "tableFrom": "proof_photos", + "tableTo": "proofs", + "columnsFrom": [ + "proof_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.proof_review_requests": { + "name": "proof_review_requests", + "schema": "", + "columns": { + "proof_id": { + "name": "proof_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "reviewer_id": { + "name": "reviewer_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "requested_at": { + "name": "requested_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "proof_review_requests_reviewer_idx": { + "name": "proof_review_requests_reviewer_idx", + "columns": [ + { + "expression": "reviewer_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "proof_review_requests_proof_id_proofs_id_fk": { + "name": "proof_review_requests_proof_id_proofs_id_fk", + "tableFrom": "proof_review_requests", + "tableTo": "proofs", + "columnsFrom": [ + "proof_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "proof_review_requests_reviewer_id_users_id_fk": { + "name": "proof_review_requests_reviewer_id_users_id_fk", + "tableFrom": "proof_review_requests", + "tableTo": "users", + "columnsFrom": [ + "reviewer_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "proof_review_requests_proof_id_reviewer_id_pk": { + "name": "proof_review_requests_proof_id_reviewer_id_pk", + "columns": [ + "proof_id", + "reviewer_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.proofs": { + "name": "proofs", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "policy": { + "name": "policy", + "type": "task_policy", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "status": { + "name": "status", + "type": "proof_status", + "typeSchema": "public", + "primaryKey": false, + "notNull": true, + "default": "'pending'" + }, + "text_answer": { + "name": "text_answer", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "rejection_reason": { + "name": "rejection_reason", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "submitted_at": { + "name": "submitted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "reviewed_at": { + "name": "reviewed_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "reviewed_by": { + "name": "reviewed_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "proofs_one_pending_per_user": { + "name": "proofs_one_pending_per_user", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "\"proofs\".\"status\" = 'pending'", + "concurrently": false, + "method": "btree", + "with": {} + }, + "proofs_single_winner_exclusive": { + "name": "proofs_single_winner_exclusive", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "(\"proofs\".\"policy\" = 'single_winner' and \"proofs\".\"status\" in ('pending', 'approved'))", + "concurrently": false, + "method": "btree", + "with": {} + }, + "proofs_one_approved_per_user": { + "name": "proofs_one_approved_per_user", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "where": "(\"proofs\".\"policy\" = 'one_per_user' and \"proofs\".\"status\" = 'approved')", + "concurrently": false, + "method": "btree", + "with": {} + }, + "proofs_status_idx": { + "name": "proofs_status_idx", + "columns": [ + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "proofs_user_idx": { + "name": "proofs_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "proofs_task_user_status_idx": { + "name": "proofs_task_user_status_idx", + "columns": [ + { + "expression": "task_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "status", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "proofs_feed_idx": { + "name": "proofs_feed_idx", + "columns": [ + { + "expression": "reviewed_at", + "isExpression": false, + "asc": false, + "nulls": "last" + }, + { + "expression": "id", + "isExpression": false, + "asc": false, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"proofs\".\"status\" = 'approved'", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "proofs_task_id_tasks_id_fk": { + "name": "proofs_task_id_tasks_id_fk", + "tableFrom": "proofs", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "proofs_user_id_users_id_fk": { + "name": "proofs_user_id_users_id_fk", + "tableFrom": "proofs", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "proofs_reviewed_by_users_id_fk": { + "name": "proofs_reviewed_by_users_id_fk", + "tableFrom": "proofs", + "tableTo": "users", + "columnsFrom": [ + "reviewed_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.proof_comments": { + "name": "proof_comments", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "proof_id": { + "name": "proof_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "body": { + "name": "body", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "deleted_at": { + "name": "deleted_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "proof_comments_proof_idx": { + "name": "proof_comments_proof_idx", + "columns": [ + { + "expression": "proof_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "proof_comments_user_recent_idx": { + "name": "proof_comments_user_recent_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": false, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "proof_comments_proof_id_proofs_id_fk": { + "name": "proof_comments_proof_id_proofs_id_fk", + "tableFrom": "proof_comments", + "tableTo": "proofs", + "columnsFrom": [ + "proof_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "proof_comments_user_id_users_id_fk": { + "name": "proof_comments_user_id_users_id_fk", + "tableFrom": "proof_comments", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.proof_likes": { + "name": "proof_likes", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "proof_id": { + "name": "proof_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "proof_likes_proof_user_key": { + "name": "proof_likes_proof_user_key", + "columns": [ + { + "expression": "proof_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "proof_likes_proof_id_proofs_id_fk": { + "name": "proof_likes_proof_id_proofs_id_fk", + "tableFrom": "proof_likes", + "tableTo": "proofs", + "columnsFrom": [ + "proof_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "proof_likes_user_id_users_id_fk": { + "name": "proof_likes_user_id_users_id_fk", + "tableFrom": "proof_likes", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "ipa_unique_id": { + "name": "ipa_unique_id", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "uid": { + "name": "uid", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "display_name": { + "name": "display_name", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "excluded": { + "name": "excluded", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "freeipa_groups": { + "name": "freeipa_groups", + "type": "text[]", + "primaryKey": false, + "notNull": true, + "default": "'{}'" + }, + "last_seen_at": { + "name": "last_seen_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "users_ipa_unique_id_key": { + "name": "users_ipa_unique_id_key", + "columns": [ + { + "expression": "ipa_unique_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "users_uid_key": { + "name": "users_uid_key", + "columns": [ + { + "expression": "uid", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.notifications": { + "name": "notifications", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "recipient_user_id": { + "name": "recipient_user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "type": { + "name": "type", + "type": "notification_type", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "message": { + "name": "message", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "proof_id": { + "name": "proof_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "task_id": { + "name": "task_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "read_at": { + "name": "read_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + } + }, + "indexes": { + "notifications_recipient_idx": { + "name": "notifications_recipient_idx", + "columns": [ + { + "expression": "recipient_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "created_at", + "isExpression": false, + "asc": false, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "notifications_unread_idx": { + "name": "notifications_unread_idx", + "columns": [ + { + "expression": "recipient_user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"notifications\".\"read_at\" is null", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "notifications_recipient_user_id_users_id_fk": { + "name": "notifications_recipient_user_id_users_id_fk", + "tableFrom": "notifications", + "tableTo": "users", + "columnsFrom": [ + "recipient_user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notifications_proof_id_proofs_id_fk": { + "name": "notifications_proof_id_proofs_id_fk", + "tableFrom": "notifications", + "tableTo": "proofs", + "columnsFrom": [ + "proof_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "notifications_task_id_tasks_id_fk": { + "name": "notifications_task_id_tasks_id_fk", + "tableFrom": "notifications", + "tableTo": "tasks", + "columnsFrom": [ + "task_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.points_ledger": { + "name": "points_ledger", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "proof_id": { + "name": "proof_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "points": { + "name": "points", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "awarded_at": { + "name": "awarded_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "points_ledger_proof_key": { + "name": "points_ledger_proof_key", + "columns": [ + { + "expression": "proof_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "points_ledger_user_idx": { + "name": "points_ledger_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "points_ledger_user_id_users_id_fk": { + "name": "points_ledger_user_id_users_id_fk", + "tableFrom": "points_ledger", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "points_ledger_proof_id_proofs_id_fk": { + "name": "points_ledger_proof_id_proofs_id_fk", + "tableFrom": "points_ledger", + "tableTo": "proofs", + "columnsFrom": [ + "proof_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.tasks": { + "name": "tasks", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "title": { + "name": "title", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": true, + "default": "''" + }, + "category_id": { + "name": "category_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "points": { + "name": "points", + "type": "integer", + "primaryKey": false, + "notNull": true + }, + "policy": { + "name": "policy", + "type": "task_policy", + "typeSchema": "public", + "primaryKey": false, + "notNull": true + }, + "cooldown_seconds": { + "name": "cooldown_seconds", + "type": "integer", + "primaryKey": false, + "notNull": false + }, + "photo_required": { + "name": "photo_required", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "photo_instructions": { + "name": "photo_instructions", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "text_required": { + "name": "text_required", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "created_by": { + "name": "created_by", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "archived_at": { + "name": "archived_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": false + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "tasks_category_idx": { + "name": "tasks_category_idx", + "columns": [ + { + "expression": "category_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tasks_active_idx": { + "name": "tasks_active_idx", + "columns": [ + { + "expression": "archived_at", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "tasks_active_category_title_idx": { + "name": "tasks_active_category_title_idx", + "columns": [ + { + "expression": "category_id", + "isExpression": false, + "asc": true, + "nulls": "last" + }, + { + "expression": "title", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "where": "\"tasks\".\"archived_at\" is null", + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "tasks_category_id_categories_id_fk": { + "name": "tasks_category_id_categories_id_fk", + "tableFrom": "tasks", + "tableTo": "categories", + "columnsFrom": [ + "category_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + }, + "tasks_created_by_users_id_fk": { + "name": "tasks_created_by_users_id_fk", + "tableFrom": "tasks", + "tableTo": "users", + "columnsFrom": [ + "created_by" + ], + "columnsTo": [ + "id" + ], + "onDelete": "restrict", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.push_subscriptions": { + "name": "push_subscriptions", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true, + "default": "gen_random_uuid()" + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "endpoint": { + "name": "endpoint", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "p256dh": { + "name": "p256dh", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "auth": { + "name": "auth", + "type": "text", + "primaryKey": false, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true, + "default": "now()" + } + }, + "indexes": { + "push_subscriptions_endpoint_key": { + "name": "push_subscriptions_endpoint_key", + "columns": [ + { + "expression": "endpoint", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + }, + "push_subscriptions_user_idx": { + "name": "push_subscriptions_user_idx", + "columns": [ + { + "expression": "user_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "push_subscriptions_user_id_users_id_fk": { + "name": "push_subscriptions_user_id_users_id_fk", + "tableFrom": "push_subscriptions", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.photo_backups": { + "name": "photo_backups", + "schema": "", + "columns": { + "object_key": { + "name": "object_key", + "type": "text", + "primaryKey": true, + "notNull": true + }, + "backed_up_at": { + "name": "backed_up_at", + "type": "timestamp with time zone", + "primaryKey": false, + "notNull": true + }, + "missing": { + "name": "missing", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + } + }, + "indexes": {}, + "foreignKeys": {}, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.proof_status": { + "name": "proof_status", + "schema": "public", + "values": [ + "pending", + "approved", + "rejected" + ] + }, + "public.notification_type": { + "name": "notification_type", + "schema": "public", + "values": [ + "proof_submitted", + "review_requested", + "proof_approved", + "proof_rejected", + "proof_commented" + ] + }, + "public.task_policy": { + "name": "task_policy", + "schema": "public", + "values": [ + "single_winner", + "one_per_user", + "repeatable" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/migrations/meta/_journal.json b/migrations/meta/_journal.json index 6e3bb7c..fe61713 100644 --- a/migrations/meta/_journal.json +++ b/migrations/meta/_journal.json @@ -15,6 +15,20 @@ "when": 1791971382062, "tag": "0001_misty_shatterstar", "breakpoints": true + }, + { + "idx": 2, + "version": "7", + "when": 1792049123424, + "tag": "0002_bouncy_trauma", + "breakpoints": true + }, + { + "idx": 3, + "version": "7", + "when": 1792052207229, + "tag": "0003_sloppy_omega_red", + "breakpoints": true } ] } \ No newline at end of file diff --git a/package.json b/package.json index f664928..d8ce21b 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,9 @@ "@aws-sdk/s3-request-presigner": "^3.1134.0", "@date-fns/tz": "^1.5.0", "@hookform/resolvers": "^5.9.1", + "@radix-ui/react-accordion": "^1.3.1", "@radix-ui/react-avatar": "^1.2.6", + "@radix-ui/react-checkbox": "^1.4.1", "@radix-ui/react-dialog": "^1.1.23", "@radix-ui/react-label": "^2.1.15", "@radix-ui/react-popover": "^1.1.23", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 6cd2c6d..88c97ec 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -20,9 +20,15 @@ importers: '@hookform/resolvers': specifier: ^5.9.1 version: 5.9.1(@standard-schema/spec@1.1.0)(ajv-formats@2.1.1(ajv@8.20.0))(ajv@8.20.0)(arktype@2.2.3)(react-hook-form@7.88.0(react@19.3.0))(zod@4.6.5) + '@radix-ui/react-accordion': + specifier: ^1.3.1 + version: 1.3.1(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0) '@radix-ui/react-avatar': specifier: ^1.2.6 version: 1.2.6(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0) + '@radix-ui/react-checkbox': + specifier: ^1.4.1 + version: 1.4.1(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0) '@radix-ui/react-dialog': specifier: ^1.1.23 version: 1.1.23(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0) @@ -1326,6 +1332,22 @@ packages: '@radix-ui/primitive@1.1.7': resolution: {integrity: sha512-rqWnm76nYT8HoNNqEjpgJ7Pw/DrBj5iBTrmEPo6HTX5+VJyBNOqTdv4g89G63HuR5g0AaENoAcH7Is5fF2kZ8Q==} + '@radix-ui/primitive@1.2.0': + resolution: {integrity: sha512-KABY+VMIRPJL+Vyzv/335FEhXXD/xDv8BMb1kl48/aXJZMH0LtHCTx5ga5RnxaEP3nZHtmTLf1P9vanmFX46bw==} + + '@radix-ui/react-accordion@1.3.1': + resolution: {integrity: sha512-lCZ6sbGS/7WO0j84yx4srIgOf0MRJ/sZ13RonADXxvKBym8xrxNCq5f6DibGcr38sIlwPk8/52uYdXeOPsbEDw==} + peerDependencies: + '@types/react': '*' + '@types/react-dom': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + '@radix-ui/react-arrow@1.1.15': resolution: {integrity: sha512-v4zggRcjadnI+ClKDuijlQEW4tw3NoaeHc/PwpKnLoLLKNUG4InLegkstooLcRIUWCs+8L22dGURCVuFfOKfnA==} peerDependencies: @@ -1352,6 +1374,32 @@ packages: '@types/react-dom': optional: true + '@radix-ui/react-checkbox@1.4.1': + resolution: {integrity: sha512-KWtwhh+98ML3seZ9vO9yRY2OwaQG90dCiDAxjpSNY2AaZ3Hik3B0dsk6m0ILywo/no3A9/SozadyPMNweVT8yw==} + peerDependencies: + '@types/react': '*' + '@types/react-dom': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + + '@radix-ui/react-collapsible@1.2.1': + resolution: {integrity: sha512-fSzLb/qy1wuZSxQBcxpW0hNXYHDMWiIXDGyJGdA4+FSLknOWZsNRrTCUavxb4PI8b8lvHo/CysO6NVi5zLpo5g==} + peerDependencies: + '@types/react': '*' + '@types/react-dom': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + '@radix-ui/react-collection@1.1.15': resolution: {integrity: sha512-9W+B9NPF0NaaPh/1NJd3+KqsnlLqU9H7T2rvww+fp+T/evVXdNAyYcnfRQZFOjkR1ajQp3yORlqnI8soawLvNA==} peerDependencies: @@ -1365,6 +1413,19 @@ packages: '@types/react-dom': optional: true + '@radix-ui/react-collection@1.2.0': + resolution: {integrity: sha512-+yiQzqcc7Sy7/5s0jrMCjpPRFB3538VNrXPWdTLZhE/SCfgEws4aI6lHWN/vvcnyhHndROWBzqmqB4QBrITZ9Q==} + peerDependencies: + '@types/react': '*' + '@types/react-dom': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + '@radix-ui/react-compose-refs@1.1.5': resolution: {integrity: sha512-+48PbAAbq3didjJxa+OaWY2ZwgAKsNiRGyeHKszblZMQ+kcpd9pAaT11cMkGEie0vsOi3QdeTE6d5Fe3Gn61kA==} peerDependencies: @@ -1383,6 +1444,15 @@ packages: '@types/react': optional: true + '@radix-ui/react-context@1.3.0': + resolution: {integrity: sha512-v5AYEocMISkbJ+1fTXzZpiFv7NRr3D2WiYbLIKf+FkmJ8VkP6d503eV2n34MFussHXY1pcoq3yfJiQH77dc4Mg==} + peerDependencies: + '@types/react': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + '@radix-ui/react-dialog@1.1.23': resolution: {integrity: sha512-Ksw4WeROkO4rC9k/onilX/Ao2Cr1ku1unMNH+XSCcP4jSXYu7HDsg9n4ojMjVb22XpYjAQ9qfrFlVbru1vXDUA==} peerDependencies: @@ -1405,6 +1475,15 @@ packages: '@types/react': optional: true + '@radix-ui/react-direction@1.2.0': + resolution: {integrity: sha512-FtRA52a/r+LKStFT+neLUm+8vSe7wbzkbQGGeU8ixFiwC8NU14Evoq9ATECqL3eGbcUzJR4fyfA4KkK/q6dfqg==} + peerDependencies: + '@types/react': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + '@radix-ui/react-dismissable-layer@1.1.19': resolution: {integrity: sha512-8g4pfOL9HoKKLWGiypT+dphVqjFfmcXO5GBnhsG6zI+lxAx/8feQpr+1LSN8Re3hiZ+XkLNS4O9ztK11/LzQ6w==} peerDependencies: @@ -1514,6 +1593,19 @@ packages: '@types/react-dom': optional: true + '@radix-ui/react-presence@1.1.11': + resolution: {integrity: sha512-Z7/atlkab36Z8hm+V8zYc79r0W+tiOB1o0tun1By94JyadkekLQmtEAnBSP9XKXBNQsStoStS4+gX10JpS5akA==} + peerDependencies: + '@types/react': '*' + '@types/react-dom': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + '@radix-ui/react-primitive@2.1.10': resolution: {integrity: sha512-MucOnzh6hR5mid6VpkbglRAMYMjKLqRnGBbjXkzjK52fuQDd1qbkx78a5P40mkcnVXJdEVxm26E9OPAiUq7nBg==} peerDependencies: @@ -1527,6 +1619,19 @@ packages: '@types/react-dom': optional: true + '@radix-ui/react-primitive@2.2.0': + resolution: {integrity: sha512-HCTSPMNqv55Qk0IX4geJbpyXazmqulcimwuyjxTkKi29v+QZbG2Zho9BnbBq4YS2PF+KlNb2CXoLz66uUmblkg==} + peerDependencies: + '@types/react': '*' + '@types/react-dom': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + react-dom: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + '@types/react-dom': + optional: true + '@radix-ui/react-roving-focus@1.1.19': resolution: {integrity: sha512-V9jI6hDjT7l3jsCQD9bLNvDLM3tH/gdbOTp7Tefp3hbbgCGQoK7tUvrWiRlcoBHIZ809ElXwNQwVo0B98LuTXQ==} peerDependencies: @@ -1562,6 +1667,15 @@ packages: '@types/react': optional: true + '@radix-ui/react-slot@1.5.0': + resolution: {integrity: sha512-tyYd9ddPXAysAbdbD9eYxgwpCSv6f3PncqVSNKQFSR5lcJVLz3cb/pANDoYrLiHBpXv7skortyUgGUWsYuPPFQ==} + peerDependencies: + '@types/react': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + '@radix-ui/react-switch@1.3.7': resolution: {integrity: sha512-48tB/4dn2UVLBCYhTu9AuR63IHl73l/qLbLgxd86noTUor4/K4LFDAcYjK+isP5313qxaFpjPVogE7+Y0/V3Kw==} peerDependencies: @@ -1606,6 +1720,15 @@ packages: '@types/react': optional: true + '@radix-ui/react-use-controllable-state@1.3.0': + resolution: {integrity: sha512-TAcBI7bw2ljYCbv4+zuTSd6zICu8pRt6SDN2vJ/Z06K2MXh6I9WYFe/A9ovlFDtR5HVHGm5iDxDoABm/++dbKg==} + peerDependencies: + '@types/react': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + '@radix-ui/react-use-effect-event@0.0.5': resolution: {integrity: sha512-7cshFL8HGS/7HEiHH+9kL9HBwp2sa9yX18Knwek6KYWmXwM7pegMgta2AXMQKI+rq3JnfSj9x8wYqFMTdG1Jgg==} peerDependencies: @@ -1660,6 +1783,15 @@ packages: '@types/react': optional: true + '@radix-ui/react-use-size@1.1.5': + resolution: {integrity: sha512-V1McDQkMGzgivwqdu7u96APs7oi0Jvj9LTzgq3WWrDZqxWdAqU9yZnZQqk5OizGFR8badUQwZsrlao7MOlWYOA==} + peerDependencies: + '@types/react': '*' + react: ^16.8 || ^17.0 || ^18.0 || ^19.0 || ^19.0.0-rc + peerDependenciesMeta: + '@types/react': + optional: true + '@radix-ui/react-visually-hidden@1.2.11': resolution: {integrity: sha512-NFS86RYYZb4/exihaESBGOpMJFz8MGLAfu3mOBSGByVnVPC9JPASfYubxd/8KbkQK0sYAv8lVQDEQukDX/qXvQ==} peerDependencies: @@ -6061,6 +6193,25 @@ snapshots: '@radix-ui/primitive@1.1.7': {} + '@radix-ui/primitive@1.2.0': {} + + '@radix-ui/react-accordion@1.3.1(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)': + dependencies: + '@radix-ui/primitive': 1.2.0 + '@radix-ui/react-collapsible': 1.2.1(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0) + '@radix-ui/react-collection': 1.2.0(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0) + '@radix-ui/react-compose-refs': 1.1.5(@types/react@19.3.0)(react@19.3.0) + '@radix-ui/react-context': 1.3.0(@types/react@19.3.0)(react@19.3.0) + '@radix-ui/react-direction': 1.2.0(@types/react@19.3.0)(react@19.3.0) + '@radix-ui/react-id': 1.1.4(@types/react@19.3.0)(react@19.3.0) + '@radix-ui/react-primitive': 2.2.0(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0) + '@radix-ui/react-use-controllable-state': 1.3.0(@types/react@19.3.0)(react@19.3.0) + react: 19.3.0 + react-dom: 19.3.0(react@19.3.0) + optionalDependencies: + '@types/react': 19.3.0 + '@types/react-dom': 19.3.0(@types/react@19.3.0) + '@radix-ui/react-arrow@1.1.15(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)': dependencies: '@radix-ui/react-primitive': 2.1.10(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0) @@ -6084,6 +6235,37 @@ snapshots: '@types/react': 19.3.0 '@types/react-dom': 19.3.0(@types/react@19.3.0) + '@radix-ui/react-checkbox@1.4.1(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)': + dependencies: + '@radix-ui/primitive': 1.2.0 + '@radix-ui/react-compose-refs': 1.1.5(@types/react@19.3.0)(react@19.3.0) + '@radix-ui/react-context': 1.3.0(@types/react@19.3.0)(react@19.3.0) + '@radix-ui/react-presence': 1.1.11(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0) + '@radix-ui/react-primitive': 2.2.0(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0) + '@radix-ui/react-use-controllable-state': 1.3.0(@types/react@19.3.0)(react@19.3.0) + '@radix-ui/react-use-size': 1.1.5(@types/react@19.3.0)(react@19.3.0) + react: 19.3.0 + react-dom: 19.3.0(react@19.3.0) + optionalDependencies: + '@types/react': 19.3.0 + '@types/react-dom': 19.3.0(@types/react@19.3.0) + + '@radix-ui/react-collapsible@1.2.1(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)': + dependencies: + '@radix-ui/primitive': 1.2.0 + '@radix-ui/react-compose-refs': 1.1.5(@types/react@19.3.0)(react@19.3.0) + '@radix-ui/react-context': 1.3.0(@types/react@19.3.0)(react@19.3.0) + '@radix-ui/react-id': 1.1.4(@types/react@19.3.0)(react@19.3.0) + '@radix-ui/react-presence': 1.1.11(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0) + '@radix-ui/react-primitive': 2.2.0(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0) + '@radix-ui/react-use-controllable-state': 1.3.0(@types/react@19.3.0)(react@19.3.0) + '@radix-ui/react-use-layout-effect': 1.1.4(@types/react@19.3.0)(react@19.3.0) + react: 19.3.0 + react-dom: 19.3.0(react@19.3.0) + optionalDependencies: + '@types/react': 19.3.0 + '@types/react-dom': 19.3.0(@types/react@19.3.0) + '@radix-ui/react-collection@1.1.15(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)': dependencies: '@radix-ui/react-compose-refs': 1.1.5(@types/react@19.3.0)(react@19.3.0) @@ -6096,6 +6278,19 @@ snapshots: '@types/react': 19.3.0 '@types/react-dom': 19.3.0(@types/react@19.3.0) + '@radix-ui/react-collection@1.2.0(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)': + dependencies: + '@radix-ui/react-compose-refs': 1.1.5(@types/react@19.3.0)(react@19.3.0) + '@radix-ui/react-context': 1.3.0(@types/react@19.3.0)(react@19.3.0) + '@radix-ui/react-primitive': 2.2.0(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0) + '@radix-ui/react-slot': 1.5.0(@types/react@19.3.0)(react@19.3.0) + '@radix-ui/react-use-layout-effect': 1.1.4(@types/react@19.3.0)(react@19.3.0) + react: 19.3.0 + react-dom: 19.3.0(react@19.3.0) + optionalDependencies: + '@types/react': 19.3.0 + '@types/react-dom': 19.3.0(@types/react@19.3.0) + '@radix-ui/react-compose-refs@1.1.5(@types/react@19.3.0)(react@19.3.0)': dependencies: react: 19.3.0 @@ -6108,6 +6303,12 @@ snapshots: optionalDependencies: '@types/react': 19.3.0 + '@radix-ui/react-context@1.3.0(@types/react@19.3.0)(react@19.3.0)': + dependencies: + react: 19.3.0 + optionalDependencies: + '@types/react': 19.3.0 + '@radix-ui/react-dialog@1.1.23(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)': dependencies: '@radix-ui/primitive': 1.1.7 @@ -6137,6 +6338,12 @@ snapshots: optionalDependencies: '@types/react': 19.3.0 + '@radix-ui/react-direction@1.2.0(@types/react@19.3.0)(react@19.3.0)': + dependencies: + react: 19.3.0 + optionalDependencies: + '@types/react': 19.3.0 + '@radix-ui/react-dismissable-layer@1.1.19(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)': dependencies: '@radix-ui/primitive': 1.1.7 @@ -6243,6 +6450,15 @@ snapshots: '@types/react': 19.3.0 '@types/react-dom': 19.3.0(@types/react@19.3.0) + '@radix-ui/react-presence@1.1.11(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)': + dependencies: + '@radix-ui/react-use-layout-effect': 1.1.4(@types/react@19.3.0)(react@19.3.0) + react: 19.3.0 + react-dom: 19.3.0(react@19.3.0) + optionalDependencies: + '@types/react': 19.3.0 + '@types/react-dom': 19.3.0(@types/react@19.3.0) + '@radix-ui/react-primitive@2.1.10(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)': dependencies: '@radix-ui/react-slot': 1.3.3(@types/react@19.3.0)(react@19.3.0) @@ -6252,6 +6468,15 @@ snapshots: '@types/react': 19.3.0 '@types/react-dom': 19.3.0(@types/react@19.3.0) + '@radix-ui/react-primitive@2.2.0(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)': + dependencies: + '@radix-ui/react-slot': 1.5.0(@types/react@19.3.0)(react@19.3.0) + react: 19.3.0 + react-dom: 19.3.0(react@19.3.0) + optionalDependencies: + '@types/react': 19.3.0 + '@types/react-dom': 19.3.0(@types/react@19.3.0) + '@radix-ui/react-roving-focus@1.1.19(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)': dependencies: '@radix-ui/primitive': 1.1.7 @@ -6308,6 +6533,13 @@ snapshots: optionalDependencies: '@types/react': 19.3.0 + '@radix-ui/react-slot@1.5.0(@types/react@19.3.0)(react@19.3.0)': + dependencies: + '@radix-ui/react-compose-refs': 1.1.5(@types/react@19.3.0)(react@19.3.0) + react: 19.3.0 + optionalDependencies: + '@types/react': 19.3.0 + '@radix-ui/react-switch@1.3.7(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)': dependencies: '@radix-ui/primitive': 1.1.7 @@ -6353,6 +6585,15 @@ snapshots: optionalDependencies: '@types/react': 19.3.0 + '@radix-ui/react-use-controllable-state@1.3.0(@types/react@19.3.0)(react@19.3.0)': + dependencies: + '@radix-ui/primitive': 1.2.0 + '@radix-ui/react-use-effect-event': 0.0.5(@types/react@19.3.0)(react@19.3.0) + '@radix-ui/react-use-layout-effect': 1.1.4(@types/react@19.3.0)(react@19.3.0) + react: 19.3.0 + optionalDependencies: + '@types/react': 19.3.0 + '@radix-ui/react-use-effect-event@0.0.5(@types/react@19.3.0)(react@19.3.0)': dependencies: '@radix-ui/react-use-layout-effect': 1.1.4(@types/react@19.3.0)(react@19.3.0) @@ -6392,6 +6633,13 @@ snapshots: optionalDependencies: '@types/react': 19.3.0 + '@radix-ui/react-use-size@1.1.5(@types/react@19.3.0)(react@19.3.0)': + dependencies: + '@radix-ui/react-use-layout-effect': 1.1.4(@types/react@19.3.0)(react@19.3.0) + react: 19.3.0 + optionalDependencies: + '@types/react': 19.3.0 + '@radix-ui/react-visually-hidden@1.2.11(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0)': dependencies: '@radix-ui/react-primitive': 2.1.10(@types/react-dom@19.3.0(@types/react@19.3.0))(@types/react@19.3.0)(react-dom@19.3.0(react@19.3.0))(react@19.3.0) diff --git a/src/actions/category/index.ts b/src/actions/category/index.ts index 632de03..50f7932 100644 --- a/src/actions/category/index.ts +++ b/src/actions/category/index.ts @@ -4,7 +4,7 @@ import { categoryService } from "~/infra"; import { action } from "~/lib/action"; import { createCategorySchema, deleteCategorySchema, updateCategorySchema } from "./schema"; -const revalidate = ["/admin/categories", "/admin/tasks", "/"]; +const revalidate = ["/admin/tasks", "/"]; export const createCategoryAction = action( createCategorySchema, diff --git a/src/actions/proof/index.ts b/src/actions/proof/index.ts index 230ae82..7ce0273 100644 --- a/src/actions/proof/index.ts +++ b/src/actions/proof/index.ts @@ -2,7 +2,7 @@ import { proofService } from "~/infra"; import { action } from "~/lib/action"; -import { proofSchema } from "./schema"; +import { ownTaskSchema, proofSchema } from "./schema"; export const submitProofAction = action( proofSchema, @@ -11,3 +11,11 @@ export const submitProofAction = action( }, { revalidate: ["/tasks", "/proofs"] }, ); + +export const addOwnTaskAction = action( + ownTaskSchema, + async (user, ownTask) => { + await proofService.addOwnTask(user, ownTask); + }, + { revalidate: ["/proofs", "/admin/review"] }, +); diff --git a/src/actions/proof/schema.ts b/src/actions/proof/schema.ts index 355957d..3a9d25c 100644 --- a/src/actions/proof/schema.ts +++ b/src/actions/proof/schema.ts @@ -3,8 +3,20 @@ import { photoLimits } from "~/config/photo"; export const proofSchema = z.object({ taskId: z.string().min(1), + textAnswer: z.string().trim().max(2000), objectKeys: z.array(z.string().min(1)).max(photoLimits.maxPhotosPerProof), reviewerIds: z.array(z.uuid()).max(10), }); +export const ownTaskSchema = z.object({ + title: z.string().trim().min(1, "Say what you did.").max(120), + description: z.string().trim().max(2000), + categoryId: z.string().min(1, "Pick a category."), + points: z.number("Enter a number.").int().min(0, "Points cannot be negative."), + objectKeys: z.array(z.string().min(1)).max(photoLimits.maxPhotosPerProof), + reviewerIds: z.array(z.uuid()).max(10), +}); + +export type OwnTaskValues = z.infer; + export type ProofValues = z.infer; diff --git a/src/actions/review/index.ts b/src/actions/review/index.ts index ffd89fa..aa2d6f6 100644 --- a/src/actions/review/index.ts +++ b/src/actions/review/index.ts @@ -8,8 +8,8 @@ const revalidate = ["/", "/admin/review", "/proofs", "/tasks"]; export const approveProofAction = action( approveSchema, - async (user, { proofId }) => { - await proofService.approveProof(user, proofId); + async (user, { proofId, points }) => { + await proofService.approveProof(user, proofId, points); }, { revalidate }, ); diff --git a/src/actions/review/schema.ts b/src/actions/review/schema.ts index da5c267..c07095f 100644 --- a/src/actions/review/schema.ts +++ b/src/actions/review/schema.ts @@ -1,6 +1,9 @@ import { z } from "zod"; -export const approveSchema = z.object({ proofId: z.string().min(1) }); +export const approveSchema = z.object({ + proofId: z.string().min(1), + points: z.number("Enter a number.").int().min(0, "Points cannot be negative.").optional(), +}); export const rejectSchema = z.object({ proofId: z.string().min(1), diff --git a/src/actions/task/index.ts b/src/actions/task/index.ts index 06f176b..47b986c 100644 --- a/src/actions/task/index.ts +++ b/src/actions/task/index.ts @@ -2,7 +2,14 @@ import { taskService } from "~/infra"; import { action } from "~/lib/action"; -import { archiveTaskSchema, createTaskSchema, updateTaskSchema } from "./schema"; +import { + archiveTaskSchema, + createTaskSchema, + moveTasksSchema, + setTasksArchivedSchema, + undoMoveTasksSchema, + updateTaskSchema, +} from "./schema"; const revalidate = ["/admin/tasks", "/tasks"]; @@ -29,3 +36,21 @@ export const archiveTaskAction = action( }, { revalidate }, ); + +export const moveTasksAction = action( + moveTasksSchema, + async (user, { taskIds, categoryId }) => taskService.moveTasks(user, taskIds, categoryId), + { revalidate }, +); + +export const undoMoveTasksAction = action( + undoMoveTasksSchema, + async (user, { moves }) => taskService.undoMoveTasks(user, moves), + { revalidate }, +); + +export const setTasksArchivedAction = action( + setTasksArchivedSchema, + async (user, { taskIds, archived }) => taskService.setTasksArchived(user, taskIds, archived), + { revalidate }, +); diff --git a/src/actions/task/schema.ts b/src/actions/task/schema.ts index d82e236..5cc080b 100644 --- a/src/actions/task/schema.ts +++ b/src/actions/task/schema.ts @@ -11,6 +11,7 @@ export const taskSchema = z.object({ cooldownSeconds: z.number("Enter a number.").int().min(0, "Cooldown cannot be negative."), photoRequired: z.boolean(), photoInstructions: z.string().trim().max(200), + textRequired: z.boolean(), }) satisfies z.ZodType; export const createTaskSchema = z.object({ task: taskSchema }); @@ -25,4 +26,32 @@ export const archiveTaskSchema = z.object({ archived: z.boolean(), }); +const taskIdsSchema = z + .array(z.uuid()) + .min(1, "Select one or more tasks.") + .refine((ids) => new Set(ids).size === ids.length, "Select each task only once."); + +export const moveTasksSchema = z.object({ + taskIds: taskIdsSchema, + categoryId: z.uuid(), +}); + +export const setTasksArchivedSchema = z.object({ + taskIds: taskIdsSchema, + archived: z.boolean(), +}); + +export const undoMoveTasksSchema = z.object({ + moves: z + .array( + z.object({ + taskId: z.uuid(), + fromCategoryId: z.uuid(), + toCategoryId: z.uuid(), + }), + ) + .min(1) + .refine((moves) => new Set(moves.map(({ taskId }) => taskId)).size === moves.length), +}); + export type TaskValues = z.infer; diff --git a/src/app/(member)/proofs/page.tsx b/src/app/(member)/proofs/page.tsx index eb130a3..3aa61cd 100644 --- a/src/app/(member)/proofs/page.tsx +++ b/src/app/(member)/proofs/page.tsx @@ -1,16 +1,41 @@ import type { Metadata } from "next"; +import Link from "next/link"; import type { FC } from "react"; -import { MyProofCard } from "~/components/proof/myCard"; +import { MyProofRow } from "~/components/proof/myRow"; +import { Accordion, GroupAccordionItem } from "~/components/ui/accordion"; +import { Button } from "~/components/ui/button"; import { EmptyState } from "~/components/ui/feedback"; import { Page } from "~/components/ui/page"; +import type { ProofStatus } from "~/domain/proof"; import { proofService } from "~/infra"; import { userCanSubmitProof } from "~/domain/rules"; import { requireUser } from "~/lib/user"; export const metadata: Metadata = { title: "My proofs" }; +const sections: ReadonlyArray<{ status: ProofStatus; title: string }> = [ + { + status: "rejected", + title: "Rejected", + }, + { + status: "pending", + title: "Awaiting review", + }, + { + status: "approved", + title: "Approved", + }, +]; + const ProofsPage: FC = async () => { const entries = await proofService.listMyProofs(await requireUser(userCanSubmitProof)); + const groups = sections + .map((section) => ({ + ...section, + entries: entries.filter((entry) => entry.proof.status === section.status), + })) + .filter((group) => group.entries.length > 0); return ( @@ -18,15 +43,42 @@ const ProofsPage: FC = async () => { + > + + )} -
    - {entries.map((entry) => ( -
  • - -
  • + group.status !== "approved" || groups.length === 1) + .map((group) => group.status)} + > + {groups.map((group) => ( + + {group.title}{" "} + + · {group.entries.length} + + + } + > +
      + {group.entries.map((entry) => ( +
    • + +
    • + ))} +
    +
    ))} -
+
); }; diff --git a/src/app/(member)/tasks/[taskId]/page.tsx b/src/app/(member)/tasks/[taskId]/page.tsx index 4a7b252..0b302b6 100644 --- a/src/app/(member)/tasks/[taskId]/page.tsx +++ b/src/app/(member)/tasks/[taskId]/page.tsx @@ -1,40 +1,77 @@ +import { Camera, ChevronLeft, PenLine } from "lucide-react"; +import type { Metadata } from "next"; +import Link from "next/link"; import { notFound } from "next/navigation"; -import type { FC } from "react"; +import { type FC, cache } from "react"; import { ProofPanel } from "~/components/proof/panel"; import { Badge } from "~/components/ui/badge"; import { Card, CardContent } from "~/components/ui/card"; -import { Page } from "~/components/ui/page"; import { proofService, taskService } from "~/infra"; import { describeCooldown, describeTaskPolicy, describeUnavailability } from "~/lib/taskLabels"; import { formatDateTime } from "~/lib/utils"; import { userCanBrowseTasks } from "~/domain/rules"; import { requireUser } from "~/lib/user"; +const loadTask = cache(async (taskId: string) => + taskService.getTask(await requireUser(userCanBrowseTasks), taskId), +); + +export async function generateMetadata({ + params, +}: PageProps<"/tasks/[taskId]">): Promise { + const item = await loadTask((await params).taskId); + + return { title: item?.task.title ?? "Task" }; +} + const TaskPage: FC> = async ({ params }) => { const { taskId } = await params; const user = await requireUser(userCanBrowseTasks); - const [item, reviewers] = await Promise.all([ - taskService.getTask(user, taskId), - proofService.listReviewers(user), - ]); + const [item, reviewers] = await Promise.all([loadTask(taskId), proofService.listReviewers(user)]); if (!item) { notFound(); } const { task, categoryName } = item; const cooldown = describeCooldown(task.cooldownSeconds); - const details = [categoryName, describeTaskPolicy(task.policy), cooldown && `every ${cooldown}`]; return ( - +
+ + + Tasks + {task.points} pts - } - > +
+ +
+

{categoryName}

+

+ {task.title} +

+
+ {describeTaskPolicy(task.policy)} + {cooldown && every {cooldown}} + {task.photoRequired && ( + + + photo required + + )} + {task.textRequired && ( + + + written answer + + )} +
+
{task.description && ( @@ -46,8 +83,10 @@ const TaskPage: FC> = async ({ params }) => { )} > = async ({ params }) => { formatDateTime, )} /> -
+ ); }; diff --git a/src/app/(member)/tasks/new/page.tsx b/src/app/(member)/tasks/new/page.tsx new file mode 100644 index 0000000..2d64bd0 --- /dev/null +++ b/src/app/(member)/tasks/new/page.tsx @@ -0,0 +1,28 @@ +import type { Metadata } from "next"; +import type { FC } from "react"; +import { OwnTaskForm } from "~/components/proof/ownTaskForm"; +import { Page } from "~/components/ui/page"; +import { categoryService, proofService } from "~/infra"; +import { userCanAddOwnTask } from "~/domain/rules"; +import { requireUser } from "~/lib/user"; + +export const metadata: Metadata = { title: "Add your own task" }; + +const NewOwnTaskPage: FC = async () => { + const user = await requireUser(userCanAddOwnTask); + const [categories, reviewers] = await Promise.all([ + categoryService.listFeedCategories(user), + proofService.listReviewers(user), + ]); + + return ( + + + + ); +}; + +export default NewOwnTaskPage; diff --git a/src/app/(member)/tasks/page.tsx b/src/app/(member)/tasks/page.tsx index fd8e3bd..779a5b3 100644 --- a/src/app/(member)/tasks/page.tsx +++ b/src/app/(member)/tasks/page.tsx @@ -1,53 +1,55 @@ import type { Metadata } from "next"; import Link from "next/link"; import type { FC } from "react"; -import { ProofStatusBadge } from "~/components/proof/statusBadge"; -import { Badge } from "~/components/ui/badge"; -import { Card, CardContent } from "~/components/ui/card"; -import { EmptyState } from "~/components/ui/feedback"; +import { TaskList } from "~/components/task/list"; +import { Button } from "~/components/ui/button"; import { Page } from "~/components/ui/page"; import { taskService } from "~/infra"; -import { describeTaskPolicy } from "~/lib/taskLabels"; -import { userCanBrowseTasks } from "~/domain/rules"; +import { describeTaskPolicy, taskAvailability } from "~/lib/taskLabels"; +import { formatDate } from "~/lib/utils"; +import { userCanBrowseTasks, userCanAddOwnTask } from "~/domain/rules"; import { requireUser } from "~/lib/user"; export const metadata: Metadata = { title: "Tasks" }; const TasksPage: FC = async () => { - const items = await taskService.listOpenTasks(await requireUser(userCanBrowseTasks)); + const user = await requireUser(userCanBrowseTasks); + const items = await taskService.listOpenTasks(user); + const now = new Date(); + const tasks = items.map((item) => ({ + id: item.task.id, + title: item.task.title, + description: item.task.description, + categoryId: item.task.categoryId, + categoryName: item.categoryName, + points: item.task.points, + policy: describeTaskPolicy(item.task.policy), + photoRequired: item.task.photoRequired, + textRequired: item.task.textRequired, + availability: taskAvailability( + { + ...item, + policy: item.task.policy, + }, + now, + ), + cooldownUntil: item.userCooldownUntil && formatDate(item.userCooldownUntil), + })); + const open = tasks.filter((task) => task.availability === "open").length; return ( - - {items.length === 0 && ( - - )} -
    - {items.map(({ task, categoryName, userProofStatus, takenByAnother }) => ( -
  • - - -
    - - {task.title} - -

    - {categoryName} · {describeTaskPolicy(task.policy)} - {task.photoRequired && " · photo required"} -

    - {userProofStatus && } - {!userProofStatus && takenByAnother && Taken by someone else} -
    - - {task.points} pts - -
    -
    -
  • - ))} -
+ + Add your own task + + ) + } + > + ); }; diff --git a/src/app/(public)/page.tsx b/src/app/(public)/page.tsx index 137ac3e..798c0a8 100644 --- a/src/app/(public)/page.tsx +++ b/src/app/(public)/page.tsx @@ -28,7 +28,7 @@ const HomePage: FC> = async ({ searchParams }) => { categoryId, }), leaderboardService.listLeaderboard(user, { - limit: 50, + limit: 10, since: period === "month" ? startOfMonthInTallinn() : null, }), categoryService.listFeedCategories(user), @@ -39,9 +39,9 @@ const HomePage: FC> = async ({ searchParams }) => {

Feed and leaderboard