Skip to content

Commit

Permalink
fix: Wrap trash icon in actionIcon and remove console.log
Browse files Browse the repository at this point in the history
  • Loading branch information
AkshitSinghal224 committed Oct 15, 2023
1 parent e9e8ffb commit c32a36a
Showing 1 changed file with 24 additions and 8 deletions.
32 changes: 24 additions & 8 deletions apps/web/src/pages/tenants/components/UpdateTenantSidebar.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,31 @@
import { useEffect, useState } from 'react';
import { Group, Modal, Stack } from '@mantine/core';
import { ActionIcon, Group, Stack } from '@mantine/core';
import { Controller, useForm } from 'react-hook-form';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { format } from 'date-fns';

import { ITenantEntity, IUpdateTenantDto } from '@novu/shared';

import { Button, colors, NameInput, Sidebar, Text, Title, Tooltip } from '../../../design-system';
import { Button, colors, NameInput, Sidebar, Text, Title, Tooltip, Modal } from '../../../design-system';
import { getTenantByIdentifier, deleteTenant, updateTenant } from '../../../api/tenants';
import { errorMessage, successMessage } from '../../../utils/notifications';
import { QueryKeys } from '../../../api/query.keys';
import { TenantFormCommonFields } from './TenantFormCommonFields';
import { Trash, WarningIcon } from '../../../design-system/icons';
import styled from '@emotion/styled';

const TrashButton = styled(Group)`
text-align: center;
border-radius: 8px;
width: 20px;
height: 32px;
color: ${({ theme }) => (theme.colorScheme === 'dark' ? colors.B60 : colors.B30)};
&:hover {
background: ${({ theme }) => (theme.colorScheme === 'dark' ? colors.B30 : colors.B85)};
color: ${({ theme }) => (theme.colorScheme === 'dark' ? colors.white : colors.B30)};
}
`;

export interface ITenantForm {
identifier: string;
Expand Down Expand Up @@ -101,7 +115,6 @@ export function UpdateTenantSidebar({
});

const onDeleteTenant = async (identifier) => {
console.log(tenant);
await deleteTenantMutate({
identifier: identifier,
});
Expand All @@ -125,7 +138,7 @@ export function UpdateTenantSidebar({
}}
customHeader={
<Stack h={80}>
<Group position="apart" spacing={130}>
<Group position="apart" spacing={120}>
<Controller
control={control}
name="name"
Expand All @@ -142,15 +155,18 @@ export function UpdateTenantSidebar({
);
}}
/>

<Tooltip label={'Delete tenant'} position="bottom">
<div
<ActionIcon
onClick={() => {
setModalIsOpened(true);
}}
data-test-id="tenant-delete-btn"
variant="transparent"
>
<Trash />
</div>
<TrashButton>
<Trash />
</TrashButton>
</ActionIcon>
</Tooltip>
</Group>
</Stack>
Expand Down

0 comments on commit c32a36a

Please sign in to comment.