Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/backend/src/admin/admin.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,8 @@ export class AdminController {
@Body() updateUserStatusDto: UpdateUserStatusDto,
@GetUser('sub') adminId: number,
) {
console.log(updateUserStatusDto, id, adminId);

return this.adminService.updateUserStatus(
id,
updateUserStatusDto.isActive,
Expand Down
2 changes: 1 addition & 1 deletion packages/backend/src/admin/admin.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ export class AdminService {
throw new BadRequestException('Cannot change your own status');
}

// Check if user exists
// Check if user exists (including deleted users)
const user = await this.prisma.users.findUnique({
where: { id },
});
Expand Down
18 changes: 16 additions & 2 deletions packages/backend/src/admin/dto/user-management.dto.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import { ApiPropertyOptional } from '@nestjs/swagger';
import { IsEnum, IsInt, IsOptional, IsString, Min } from 'class-validator';
import { Type } from 'class-transformer';
import {
IsEnum,
IsInt,
IsOptional,
IsString,
Min,
IsBoolean,
} from 'class-validator';
import { Transform, Type } from 'class-transformer';
import { users_roles } from '@prisma/client';

export class UpdateUserRoleDto {
Expand All @@ -17,6 +24,13 @@ export class UpdateUserStatusDto {
type: Boolean,
description: 'User account status (true = active, false = inactive)',
})
@IsBoolean()
@Transform(({ value }) => {
if (typeof value === 'string') {
return value === 'true';
}
return value;
})
isActive: boolean;
}

Expand Down
9 changes: 6 additions & 3 deletions packages/frontend/src/features/admin/store/admin-store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,16 +202,19 @@ export const useAdminStore = create<AdminState>()(
deleteUser: async (id) => {
try {
set({ isLoading: true, error: null });
const response = await adminApi.deleteUser(id);
const response = await adminApi.updateUserStatus(id, false);

if (!response.success) {
throw new Error('Failed to delete user');
}

const updatedUser = response.data;
set((state) => ({
users: state.users.filter((user) => user.id !== id),
users: state.users.map((user) =>
user.id === id ? updatedUser : user
),
selectedUser:
state.selectedUser?.id === id ? null : state.selectedUser,
state.selectedUser?.id === id ? updatedUser : state.selectedUser,
isLoading: false
}));
return response.data;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,9 @@ export const EventCard = ({
<DollarSign className="mr-1 h-5 w-5 text-secondary-500" />
)}
{type === EventType.PRIVATE ? (
<LockIcon className="h-5 w-5 text-primary-500" />
<LockIcon className="h-5 w-5 text-white" />
) : (
<UnlockIcon className="h-5 w-5 text-primary-500" />
<UnlockIcon className="h-5 w-5 text-white" />
)}
</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ export const EventList = () => {
fetchSubscribers();
}, [fetchEvents, fetchEventSubscriptions, user?.id]);

console.log('eventSubscriptions', eventSubscriptions);

// Pagination helpers
const getPageEvents = (eventsList: Event[]) => {
const startIndex = (currentPage - 1) * eventsPerPage;
Expand Down Expand Up @@ -107,8 +105,6 @@ export const EventList = () => {
setCurrentPage(page);
};

console.log('events', events);

if (isLoading || eventsLoading) {
return (
<div className="container space-y-6">
Expand Down