Skip to content

Commit ed4a0c3

Browse files
committed
feat: add isAdmin field to TeamMember model and update related services
- Introduced an 'isAdmin' field in the TeamMember model to manage admin roles. - Updated AuthService to set 'isAdmin' to true for new members. - Modified ProjectManagementService to handle 'isAdmin' during member creation and updates. - Enhanced frontend components to support the new 'isAdmin' field, including updates to TeamDetailModal and Sidebar for admin-specific actions. - Updated task management to allow for drag-and-drop reordering with insert index support.
1 parent 3046a7d commit ed4a0c3

File tree

13 files changed

+1614
-639
lines changed

13 files changed

+1614
-639
lines changed

backend/prisma/schema.prisma

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ model TeamMember {
7373
photo String?
7474
phone String?
7575
isTrash Boolean @default(false)
76+
isAdmin Boolean @default(false)
7677
createdAt DateTime @default(now())
7778
updatedAt DateTime?
7879
Task Task[]

backend/src/auth/auth.service.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ export class AuthService {
9393
email,
9494
role: role ?? null,
9595
photo: photo ?? null,
96+
isAdmin: true,
9697
// optionally store clientTempId if you want mapping
9798
// clientTempId: clientTempId ?? null // uncomment if you added field
9899
createdAt: new Date(),

backend/src/project-management/dto/team.dto.ts

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { IsOptional, IsString } from "class-validator";
1+
import { IsBoolean, IsOptional, IsString } from "class-validator";
22

33
export class CreateTeamMemberDto {
44
@IsString()
@@ -12,6 +12,10 @@ export class CreateTeamMemberDto {
1212
@IsString()
1313
email?: string;
1414

15+
@IsOptional()
16+
@IsBoolean()
17+
isAdmin?: boolean;
18+
1519
@IsOptional()
1620
@IsString()
1721
password?: string;
@@ -37,6 +41,10 @@ export class UpdateTeamMemberDto {
3741
@IsString()
3842
role?: string;
3943

44+
@IsOptional()
45+
@IsBoolean()
46+
isAdmin?: boolean;
47+
4048
@IsOptional()
4149
@IsString()
4250
password?: string;

backend/src/project-management/project-management.service.ts

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -717,13 +717,23 @@ export class ProjectManagementService {
717717
email?: string;
718718
photo?: string;
719719
phone?: string;
720+
isAdmin?: boolean;
720721
password?: string;
721722
clientId?: string | null;
722723
workspaceId: string;
723724
}>
724725
) {
725-
const { clientId, email, name, role, photo, phone, password, workspaceId } =
726-
payload as any;
726+
const {
727+
clientId,
728+
email,
729+
name,
730+
role,
731+
photo,
732+
phone,
733+
isAdmin,
734+
password,
735+
workspaceId,
736+
} = payload as any;
727737

728738
// 1) If clientId provided — try to find existing TeamMember by clientId first.
729739
if (clientId) {
@@ -770,6 +780,7 @@ export class ProjectManagementService {
770780
photo: user.photo ? user.photo : photo ?? null,
771781
phone: phone ?? null,
772782
clientId: clientId ?? null,
783+
isAdmin: isAdmin ?? false,
773784
userId: user.id,
774785
workspaceId,
775786
createdAt: new Date(),
@@ -800,9 +811,11 @@ export class ProjectManagementService {
800811
role?: string;
801812
phone?: string;
802813
password?: string;
814+
isAdmin?: boolean;
803815
photo?: string;
804816
}>
805817
) {
818+
console.log(payload);
806819
// 1) ensure team member exists
807820
const exists = await prisma.teamMember.findUnique({ where: { id } });
808821
if (!exists) throw new NotFoundException("Team member not found");
@@ -813,6 +826,8 @@ export class ProjectManagementService {
813826
if (typeof payload.role !== "undefined") tmData.role = payload.role;
814827
if (typeof payload.phone !== "undefined") tmData.phone = payload.phone;
815828
if (typeof payload.photo !== "undefined") tmData.photo = payload.photo;
829+
if (typeof payload.isAdmin !== "undefined")
830+
tmData.isAdmin = payload.isAdmin;
816831
tmData.updatedAt = new Date();
817832

818833
// prepare user update/create data

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"author": "asepindrak",
55
"private": false,
66
"license": "MIT",
7-
"version": "1.1.2",
7+
"version": "1.3.1",
88
"type": "module",
99
"scripts": {
1010
"dev": "vite --host 0.0.0.0",

0 commit comments

Comments
 (0)