Add ValidationStates type for improved domain validation handling

- Introduced `ValidationStates` type to enhance the structure and clarity of domain validation logic in the ShowDomains component.
- This addition aims to streamline the management of validation states, contributing to better code organization and maintainability.
This commit is contained in:
Mauricio Siu 2025-05-04 12:16:56 -06:00
parent 4575f16be4
commit 432f616896

View File

@ -41,6 +41,8 @@ export type ValidationState = {
message?: string; message?: string;
}; };
export type ValidationStates = Record<string, ValidationState>;
interface Props { interface Props {
id: string; id: string;
type: "application" | "compose"; type: "application" | "compose";
@ -70,8 +72,11 @@ export const ShowDomains = ({ id, type }: Props) => {
); );
const { data: ip } = api.settings.getIp.useQuery(); const { data: ip } = api.settings.getIp.useQuery();
const { data, refetch } = const {
type === "application" data,
refetch,
isLoading: isLoadingDomains,
} = type === "application"
? api.domain.byApplicationId.useQuery( ? api.domain.byApplicationId.useQuery(
{ {
applicationId: id, applicationId: id,
@ -152,7 +157,14 @@ export const ShowDomains = ({ id, type }: Props) => {
</div> </div>
</CardHeader> </CardHeader>
<CardContent className="flex w-full flex-row gap-4"> <CardContent className="flex w-full flex-row gap-4">
{data?.length === 0 ? ( {isLoadingDomains ? (
<div className="flex w-full flex-row gap-4 min-h-[40vh] justify-center items-center">
<Loader2 className="size-5 animate-spin text-muted-foreground" />
<span className="text-base text-muted-foreground">
Loading domains...
</span>
</div>
) : data?.length === 0 ? (
<div className="flex w-full flex-col items-center justify-center gap-3 min-h-[40vh]"> <div className="flex w-full flex-col items-center justify-center gap-3 min-h-[40vh]">
<GlobeIcon className="size-8 text-muted-foreground" /> <GlobeIcon className="size-8 text-muted-foreground" />
<span className="text-base text-muted-foreground"> <span className="text-base text-muted-foreground">