Skip to content

Commit

Permalink
fix: show that domain is disabled in domain select
Browse files Browse the repository at this point in the history
  • Loading branch information
niekcandaele committed Oct 28, 2024
1 parent a5de69c commit f1940b9
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion packages/web-main/src/routes/_auth/domain.select.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Card, Chip, Company, styled } from '@takaro/lib-components';
import { DomainOutputDTO } from '@takaro/apiclient';
import { DomainOutputDTO, DomainOutputDTOStateEnum } from '@takaro/apiclient';
import { createFileRoute, useNavigate } from '@tanstack/react-router';
import { useUserSetSelectedDomain, userMeQueryOptions } from 'queries/user';
import { MdDomain as DomainIcon } from 'react-icons/md';
Expand Down Expand Up @@ -78,8 +78,12 @@ function DomainCard({ domain, isCurrentDomain }: DomainCardProps) {
const navigate = useNavigate();
const { mutate, isSuccess } = useUserSetSelectedDomain();
const queryClient = useQueryClient();
const isDisabled = domain.state === DomainOutputDTOStateEnum.Disabled;

const handleDomainSelectedClick = () => {
// Logging into a disabled domain is going to error out
if (isDisabled) return;

if (isCurrentDomain === false) {
mutate({ domainId: domain.id });
}
Expand All @@ -97,6 +101,7 @@ function DomainCard({ domain, isCurrentDomain }: DomainCardProps) {
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
<DomainIcon size={30} />
{isCurrentDomain && <Chip variant="outline" color="primary" label="current domain" />}
{isDisabled && <Chip variant="outline" color="warning" label="disabled" />}
</div>
<h2 style={{ display: 'flex', alignItems: 'center' }}>
{domain.name}
Expand Down

0 comments on commit f1940b9

Please sign in to comment.