From 76a7f5da154f5139c2854b781d4a2e41cf750de6 Mon Sep 17 00:00:00 2001 From: Jan Hendrik Scheufen Date: Fri, 1 Nov 2024 23:38:38 -0400 Subject: [PATCH 1/3] Group members are now sorted by title Signed-off-by: Jan Hendrik Scheufen --- .../components/GroupMembers/GroupMembers.tsx | 15 +++++++++++++-- packages/quilombo/config/constants.ts | 6 ++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/quilombo/components/GroupMembers/GroupMembers.tsx b/packages/quilombo/components/GroupMembers/GroupMembers.tsx index 326eccc..a02c927 100755 --- a/packages/quilombo/components/GroupMembers/GroupMembers.tsx +++ b/packages/quilombo/components/GroupMembers/GroupMembers.tsx @@ -3,9 +3,10 @@ import { Spinner } from '@nextui-org/spinner'; import { Table, TableBody, TableCell, TableColumn, TableHeader, TableRow } from '@nextui-org/table'; import { useAtomValue } from 'jotai'; -import { useCallback } from 'react'; +import { useCallback, useMemo } from 'react'; import { GroupMembersSkeleton } from '@/components/skeletons/GroupSkeletons'; +import { TitleEnum } from '@/config/constants'; import { groupAdminIdsAtom, groupFounderAtom, @@ -27,6 +28,16 @@ const GroupMembers = () => { (userId: string): GroupMemberRole[] => getGroupMemberRoles(userId, groupFounder, groupLeader, groupAdminIds), [groupFounder, groupLeader, groupAdminIds], ); + const sortedGroupMembers = useMemo( + () => + groupMembers?.sort((a, b) => { + if (!a.title && !b.title) return 0; + if (!a.title) return -1; + if (!b.title) return 1; + return TitleEnum[a.title] - TitleEnum[b.title]; + }) ?? [], + [groupMembers], + ); const filteredColumns = [...COLUMNS].filter((column) => (isGroupAdmin ? true : column.uid !== 'actions')); @@ -42,7 +53,7 @@ const GroupMembers = () => { )} } emptyContent="No members found" diff --git a/packages/quilombo/config/constants.ts b/packages/quilombo/config/constants.ts index 81f7273..9df532c 100755 --- a/packages/quilombo/config/constants.ts +++ b/packages/quilombo/config/constants.ts @@ -20,6 +20,12 @@ export const titles = [ 'iniciante', ] as const; +// used to sort titles in the UI +export const TitleEnum = titles.reduce>((acc, title, index) => { + acc[title] = index; + return acc; +}, {}); + export const styles = ['angola', 'regional', 'contemporânea'] as const; export const linkTypes = ['twitter', 'facebook', 'instagram', 'linkedin'] as const; From d9aa34b9ed7b221c4d55438ba1c1a3b8054a6ab7 Mon Sep 17 00:00:00 2001 From: Jan Hendrik Scheufen Date: Fri, 1 Nov 2024 23:40:30 -0400 Subject: [PATCH 2/3] Removed lines from husky precommit file causing deprecation warnings Signed-off-by: Jan Hendrik Scheufen --- .husky/pre-commit | 2 -- 1 file changed, 2 deletions(-) diff --git a/.husky/pre-commit b/.husky/pre-commit index 6cdaab7..38bb628 100755 --- a/.husky/pre-commit +++ b/.husky/pre-commit @@ -1,4 +1,2 @@ -#!/usr/bin/env sh -. "$(dirname -- "$0")/_/husky.sh" yarn lint From 5d7da3866ee0a75f86d3ef44591514b4952af0a2 Mon Sep 17 00:00:00 2001 From: Jan Hendrik Scheufen Date: Sat, 2 Nov 2024 00:14:18 -0400 Subject: [PATCH 3/3] Changed order of titles enum to list female titles before males. Courtesy. Ladies always before gentlemen. Signed-off-by: Jan Hendrik Scheufen --- packages/quilombo/config/constants.ts | 14 +- .../db/migrations/0011_overrated_cloak.sql | 4 + .../db/migrations/meta/0011_snapshot.json | 427 ++++++++++++++++++ .../quilombo/db/migrations/meta/_journal.json | 7 + packages/quilombo/package.json | 4 +- yarn.lock | 37 +- 6 files changed, 467 insertions(+), 26 deletions(-) create mode 100644 packages/quilombo/db/migrations/0011_overrated_cloak.sql create mode 100644 packages/quilombo/db/migrations/meta/0011_snapshot.json diff --git a/packages/quilombo/config/constants.ts b/packages/quilombo/config/constants.ts index 9df532c..a3454df 100755 --- a/packages/quilombo/config/constants.ts +++ b/packages/quilombo/config/constants.ts @@ -3,20 +3,20 @@ import { ImageType } from '@/types/model'; import { ResizeOptions } from 'sharp'; export const titles = [ - 'mestre', 'mestra', - 'contra-mestre', + 'mestre', 'contra-mestra', - 'mestrando', + 'contra-mestre', 'mestranda', - 'professor', + 'mestrando', 'professora', - 'instrutor', + 'professor', 'instrutora', - 'monitor', + 'instrutor', 'monitora', - 'aluno', + 'monitor', 'aluna', + 'aluno', 'iniciante', ] as const; diff --git a/packages/quilombo/db/migrations/0011_overrated_cloak.sql b/packages/quilombo/db/migrations/0011_overrated_cloak.sql new file mode 100644 index 0000000..b678ba5 --- /dev/null +++ b/packages/quilombo/db/migrations/0011_overrated_cloak.sql @@ -0,0 +1,4 @@ +ALTER TABLE "public"."users" ALTER COLUMN "title" SET DATA TYPE text;--> statement-breakpoint +DROP TYPE "public"."title";--> statement-breakpoint +CREATE TYPE "public"."title" AS ENUM('mestra', 'mestre', 'contra-mestra', 'contra-mestre', 'mestranda', 'mestrando', 'professora', 'professor', 'instrutora', 'instrutor', 'monitora', 'monitor', 'aluna', 'aluno', 'iniciante');--> statement-breakpoint +ALTER TABLE "public"."users" ALTER COLUMN "title" SET DATA TYPE "public"."title" USING "title"::"public"."title"; \ No newline at end of file diff --git a/packages/quilombo/db/migrations/meta/0011_snapshot.json b/packages/quilombo/db/migrations/meta/0011_snapshot.json new file mode 100644 index 0000000..195c611 --- /dev/null +++ b/packages/quilombo/db/migrations/meta/0011_snapshot.json @@ -0,0 +1,427 @@ +{ + "id": "01550a7b-32e8-4d83-a175-75e52504de1d", + "prevId": "b2c54198-cdad-4e12-8340-68f4ee7cf1d0", + "version": "7", + "dialect": "postgresql", + "tables": { + "public.group_admins": { + "name": "group_admins", + "schema": "", + "columns": { + "group_id": { + "name": "group_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + }, + "user_id": { + "name": "user_id", + "type": "uuid", + "primaryKey": false, + "notNull": true + } + }, + "indexes": {}, + "foreignKeys": { + "group_admins_group_id_groups_id_fk": { + "name": "group_admins_group_id_groups_id_fk", + "tableFrom": "group_admins", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + }, + "group_admins_user_id_users_id_fk": { + "name": "group_admins_user_id_users_id_fk", + "tableFrom": "group_admins", + "tableTo": "users", + "columnsFrom": [ + "user_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "cascade", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": { + "group_admins_group_id_user_id_pk": { + "name": "group_admins_group_id_user_id_pk", + "columns": [ + "group_id", + "user_id" + ] + } + }, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.groups": { + "name": "groups", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "description": { + "name": "description", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "style": { + "name": "style", + "type": "style", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "logo": { + "name": "logo", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "banner": { + "name": "banner", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "leader_id": { + "name": "leader_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "founder": { + "name": "founder", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "verified": { + "name": "verified", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "city": { + "name": "city", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "country": { + "name": "country", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "links": { + "name": "links", + "type": "json", + "primaryKey": false, + "notNull": true, + "default": "'[]'::json" + } + }, + "indexes": { + "name_idx": { + "name": "name_idx", + "columns": [ + { + "expression": "name", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "groups_leader_id_users_id_fk": { + "name": "groups_leader_id_users_id_fk", + "tableFrom": "groups", + "tableTo": "users", + "columnsFrom": [ + "leader_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + }, + "public.users": { + "name": "users", + "schema": "", + "columns": { + "id": { + "name": "id", + "type": "uuid", + "primaryKey": true, + "notNull": true + }, + "created_at": { + "name": "created_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true, + "default": "now()" + }, + "updated_at": { + "name": "updated_at", + "type": "timestamp", + "primaryKey": false, + "notNull": true + }, + "name": { + "name": "name", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "nickname": { + "name": "nickname", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "title": { + "name": "title", + "type": "title", + "typeSchema": "public", + "primaryKey": false, + "notNull": false + }, + "avatar": { + "name": "avatar", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "email": { + "name": "email", + "type": "text", + "primaryKey": false, + "notNull": false + }, + "group_id": { + "name": "group_id", + "type": "uuid", + "primaryKey": false, + "notNull": false + }, + "phone": { + "name": "phone", + "type": "varchar", + "primaryKey": false, + "notNull": false + }, + "wallet_address": { + "name": "wallet_address", + "type": "varchar", + "primaryKey": false, + "notNull": true + }, + "is_global_admin": { + "name": "is_global_admin", + "type": "boolean", + "primaryKey": false, + "notNull": true, + "default": false + }, + "links": { + "name": "links", + "type": "json", + "primaryKey": false, + "notNull": true, + "default": "'[]'::json" + } + }, + "indexes": { + "nickname_idx": { + "name": "nickname_idx", + "columns": [ + { + "expression": "nickname", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "title_idx": { + "name": "title_idx", + "columns": [ + { + "expression": "title", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "group_idx": { + "name": "group_idx", + "columns": [ + { + "expression": "group_id", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": false, + "concurrently": false, + "method": "btree", + "with": {} + }, + "email_idx": { + "name": "email_idx", + "columns": [ + { + "expression": "email", + "isExpression": false, + "asc": true, + "nulls": "last" + } + ], + "isUnique": true, + "concurrently": false, + "method": "btree", + "with": {} + } + }, + "foreignKeys": { + "users_group_id_groups_id_fk": { + "name": "users_group_id_groups_id_fk", + "tableFrom": "users", + "tableTo": "groups", + "columnsFrom": [ + "group_id" + ], + "columnsTo": [ + "id" + ], + "onDelete": "set null", + "onUpdate": "no action" + } + }, + "compositePrimaryKeys": {}, + "uniqueConstraints": {}, + "policies": {}, + "checkConstraints": {}, + "isRLSEnabled": false + } + }, + "enums": { + "public.link_type": { + "name": "link_type", + "schema": "public", + "values": [ + "twitter", + "facebook", + "instagram", + "linkedin" + ] + }, + "public.style": { + "name": "style", + "schema": "public", + "values": [ + "angola", + "regional", + "contemporânea" + ] + }, + "public.title": { + "name": "title", + "schema": "public", + "values": [ + "mestra", + "mestre", + "contra-mestra", + "contra-mestre", + "mestranda", + "mestrando", + "professora", + "professor", + "instrutora", + "instrutor", + "monitora", + "monitor", + "aluna", + "aluno", + "iniciante" + ] + } + }, + "schemas": {}, + "sequences": {}, + "roles": {}, + "policies": {}, + "views": {}, + "_meta": { + "columns": {}, + "schemas": {}, + "tables": {} + } +} \ No newline at end of file diff --git a/packages/quilombo/db/migrations/meta/_journal.json b/packages/quilombo/db/migrations/meta/_journal.json index aa1c00c..bbb43ca 100755 --- a/packages/quilombo/db/migrations/meta/_journal.json +++ b/packages/quilombo/db/migrations/meta/_journal.json @@ -78,6 +78,13 @@ "when": 1729975222011, "tag": "0010_grey_cable", "breakpoints": true + }, + { + "idx": 11, + "version": "7", + "when": 1730520638751, + "tag": "0011_overrated_cloak", + "breakpoints": true } ] } \ No newline at end of file diff --git a/packages/quilombo/package.json b/packages/quilombo/package.json index 5ff9548..b3ef8b8 100755 --- a/packages/quilombo/package.json +++ b/packages/quilombo/package.json @@ -59,7 +59,7 @@ "cookies-next": "^4.2.1", "country-state-city": "^3.2.1", "dnum": "^2.13.1", - "drizzle-orm": "^0.33.0", + "drizzle-orm": "^0.36.0", "ethers": "^6.13.2", "file-type": "^19.6.0", "formik": "^2.4.6", @@ -105,7 +105,7 @@ "@wagmi/cli": "^2.1.15", "chai": "^4.5.0", "dotenv": "^16.4.5", - "drizzle-kit": "^0.24.2", + "drizzle-kit": "^0.27.1", "eslint": "^8.57.0", "eslint-config-next": "14.2.7", "eslint-config-prettier": "^9.1.0", diff --git a/yarn.lock b/yarn.lock index c942bdd..3897c3b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1305,10 +1305,10 @@ __metadata: languageName: node linkType: hard -"@drizzle-team/brocli@npm:^0.10.1": - version: 0.10.1 - resolution: "@drizzle-team/brocli@npm:0.10.1" - checksum: 10c0/64a1678a5a5cf4a16f955175fd6f9df8ff61e5de24473d5c7efa699e8145a54574584bd22f8036c77d0d35666ff97f11a5b006191ca40f5d3deb0006258cd806 +"@drizzle-team/brocli@npm:^0.10.2": + version: 0.10.2 + resolution: "@drizzle-team/brocli@npm:0.10.2" + checksum: 10c0/3d8b99d680f0b14fea32b45c59b938b6665e0840cc67f04801b1aa3c6747da3c7d01c00e321645034fa100abdba7e0c20ce07cf46fc2ca769ee4cafd97562484 languageName: node linkType: hard @@ -10962,28 +10962,29 @@ __metadata: languageName: node linkType: hard -"drizzle-kit@npm:^0.24.2": - version: 0.24.2 - resolution: "drizzle-kit@npm:0.24.2" +"drizzle-kit@npm:^0.27.1": + version: 0.27.1 + resolution: "drizzle-kit@npm:0.27.1" dependencies: - "@drizzle-team/brocli": "npm:^0.10.1" + "@drizzle-team/brocli": "npm:^0.10.2" "@esbuild-kit/esm-loader": "npm:^2.5.5" esbuild: "npm:^0.19.7" esbuild-register: "npm:^3.5.0" bin: drizzle-kit: bin.cjs - checksum: 10c0/c5416749deaf3c3fc0ce2981dbca6fd100b1f1fcb7c4f0a2c170ab24b5431c792f59d46eed45fc82097de95fb6fdb58adb5fb0dafe0c76ccf879c25362a45635 + checksum: 10c0/9813d9e4fbb5d1e3e654df8698871152cffb88b8afa27b12988c045f41815feaf18b84efd4babbed462cbc3062d76cb08b41fba26c387e10d913863afb95cfc9 languageName: node linkType: hard -"drizzle-orm@npm:^0.33.0": - version: 0.33.0 - resolution: "drizzle-orm@npm:0.33.0" +"drizzle-orm@npm:^0.36.0": + version: 0.36.0 + resolution: "drizzle-orm@npm:0.36.0" peerDependencies: "@aws-sdk/client-rds-data": ">=3" "@cloudflare/workers-types": ">=3" - "@electric-sql/pglite": ">=0.1.1" - "@libsql/client": "*" + "@electric-sql/pglite": ">=0.2.0" + "@libsql/client": ">=0.10.0" + "@libsql/client-wasm": ">=0.10.0" "@neondatabase/serverless": ">=0.1" "@op-engineering/op-sqlite": ">=2" "@opentelemetry/api": ^1.4.1 @@ -11016,6 +11017,8 @@ __metadata: optional: true "@libsql/client": optional: true + "@libsql/client-wasm": + optional: true "@neondatabase/serverless": optional: true "@op-engineering/op-sqlite": @@ -11064,7 +11067,7 @@ __metadata: optional: true sqlite3: optional: true - checksum: 10c0/62626e355c3962e963a62b3dbeb9279de709a7b00451ee6722b8b05605cf878bb54633f51d536a5df59d43efa1ae39645af7ddb4283bdbe66d9d467aee3d5b2e + checksum: 10c0/a92cc827c41f2a0642546e004848f8dc220e9630f8e0913c35be3f83272d0d9d6384236d350115078adbd929764ca6194abd29eea50410bdec842f69389c047e languageName: node linkType: hard @@ -17146,8 +17149,8 @@ __metadata: country-state-city: "npm:^3.2.1" dnum: "npm:^2.13.1" dotenv: "npm:^16.4.5" - drizzle-kit: "npm:^0.24.2" - drizzle-orm: "npm:^0.33.0" + drizzle-kit: "npm:^0.27.1" + drizzle-orm: "npm:^0.36.0" eslint: "npm:^8.57.0" eslint-config-next: "npm:14.2.7" eslint-config-prettier: "npm:^9.1.0"