Skip to content

Commit

Permalink
Updates after feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Myrfion committed Apr 13, 2023
1 parent 3dff1fb commit a93b357
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
6 changes: 3 additions & 3 deletions app/components/admin/users-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,16 @@ export default function UsersTable({ users, searchText }: UsersTableProps) {
</Form>
</Tooltip>
<Form method="post">
<Tooltip label="Deactivate user">
<Tooltip label="Delete user">
<IconButton
aria-label="Deactivate user"
aria-label="Delete user"
icon={<DeleteIcon color="black" boxSize={5} />}
variant="ghost"
type="submit"
/>
</Tooltip>
<input type="hidden" name="username" value={user.username} />
<input type="hidden" name="intent" value="deactivate-user" />
<input type="hidden" name="intent" value="delete-user" />
</Form>
</HStack>
</Td>
Expand Down
2 changes: 1 addition & 1 deletion app/lib/user.server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ import { deleteUserByUsername } from '~/models/user.server';

export async function deleteUser(username: User['username']) {
await deleteUserByUsername(username);
setIsReconciliationNeeded(true);
return setIsReconciliationNeeded(true);
}
10 changes: 5 additions & 5 deletions app/routes/__index/admin/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '@chakra-ui/react';
import type { Certificate, User } from '@prisma/client';
import { redirect } from '@remix-run/node';
import { Form, useSubmit } from '@remix-run/react';
import { useSubmit } from '@remix-run/react';
import { useCallback, useEffect, useState } from 'react';
import { FaUsers, FaSearch, FaStickyNote } from 'react-icons/fa';
import { TbFileCertificate } from 'react-icons/tb';
Expand All @@ -27,7 +27,7 @@ import { requireAdmin, setEffectiveUsername } from '~/session.server';
import type { ActionArgs, LoaderArgs } from '@remix-run/node';
import { deleteUser } from '~/lib/user.server';

export type AdminActionIntent = 'search-users' | 'impersonate-user' | 'deactivate-user';
export type AdminActionIntent = 'search-users' | 'impersonate-user' | 'delete-user';

export interface UserWithMetrics extends User {
dnsRecordCount: number;
Expand All @@ -43,7 +43,7 @@ export const action = async ({ request }: ActionArgs) => {
request,
z
.object({
intent: z.enum(['search-users', 'impersonate-user', 'deactivate-user']),
intent: z.enum(['search-users', 'impersonate-user', 'delete-user']),
searchText: z.string().min(MIN_USERS_SEARCH_TEXT).optional(),
newEffectiveUsername: z.string().optional(),
username: z.string().optional(),
Expand All @@ -56,7 +56,7 @@ export const action = async ({ request }: ActionArgs) => {
if (data.intent === 'impersonate-user') {
return !!data.newEffectiveUsername;
}
if (data.intent === 'deactivate-user') {
if (data.intent === 'delete-user') {
return !!data.username;
}
return false;
Expand Down Expand Up @@ -104,7 +104,7 @@ export const action = async ({ request }: ActionArgs) => {
'Set-Cookie': await setEffectiveUsername(admin.username, newEffectiveUsername ?? ''),
},
});
case 'deactivate-user':
case 'delete-user':
const { username } = actionParams.data;
await deleteUser(username ?? '');

Expand Down

0 comments on commit a93b357

Please sign in to comment.