# Utilidades

## Advertencia de Conexión de Billetera

Cuando el usuario intenta usar la demostración sin la billetera.

```typescript
import { Button } from "@/components/ui/button";
import { AlertCircle, Wallet } from "lucide-react";
import { useWallet } from "@/components/modules/auth/hooks/wallet.hook";

export const ConnectWalletWarning = () => {
  const { handleConnect } = useWallet();

  return (
    <div className="p-8 flex flex-col items-center justify-center text-center">
      <div className="bg-amber-50 dark:bg-amber-950/30 p-3 rounded-full mb-4">
        <Wallet className="h-8 w-8 text-amber-600 dark:text-amber-500" />
      </div>
      <h3 className="text-xl font-semibold mb-2">Se requiere conexión de billetera</h3>
      <p className="text-muted-foreground max-w-md mb-6">
        Para acceder e interactuar con los endpoints de la API de Trustless Work, necesitas
        conectar primero tu billetera Stellar.
      </p>
      <div className="flex flex-col sm:flex-row gap-3">
        <Button onClick={handleConnect} className="flex items-center gap-2">
          <Wallet className="h-4 w-4" />
          Conectar Billetera
        </Button>
      </div>
      <div className="mt-6 flex items-center gap-2 text-sm text-amber-600 dark:text-amber-500 bg-amber-50 dark:bg-amber-950/30 p-3 rounded-lg">
        <AlertCircle className="h-4 w-4" />
        <p>La información de tu billetera nunca se almacena en nuestros servidores</p>
      </div>
    </div>
  );
};

```

## Visualización de Respuesta

Cuando capturamos una respuesta de endpoint, la guardamos y la mostramos mediante este componente.

```typescript
"use client";

import { useState } from "react";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import { Button } from "@/components/ui/button";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import { CheckCircle, Copy } from "lucide-react";
import { useUtils } from "@/hooks/utils.hook";
import { Escrow } from "@/@types/escrows/escrow.entity";
import {
  EscrowRequestResponse,
  InitializeEscrowResponse,
  UpdateEscrowResponse,
} from "@/@types/escrows/escrow-response.entity";

interface ResponseDisplayProps {
  response:
    | InitializeEscrowResponse
    | UpdateEscrowResponse
    | EscrowRequestResponse
    | Escrow
    | null;
}

export function ResponseDisplay({ response }: ResponseDisplayProps) {
  const [activeTab, setActiveTab] = useState("formatted");
  const { copyToClipboard, copied } = useUtils();

  if (!response) return null;

  const responseString = JSON.stringify(response, null, 2);

  return (
    <Card className="mt-6 border shadow-sm">
      <CardHeader className="flex flex-row items-center justify-between pb-2">
        <CardTitle className="text-lg">Respuesta</CardTitle>
        <Button
          variant="outline"
          size="sm"
          onClick={() => copyToClipboard(responseString)}
          className="h-8 px-2 text-xs"
        >
          {copied ? (
            <>
              <CheckCircle className="h-4 w-4 mr-1" /> Copiado
            </>
          ) : (
            <>
              <Copy className="h-4 w-4 mr-1" /> Copiar
            </>
          )}
        </Button>
      </CardHeader>
      <CardContent className="p-0">
        <Tabs defaultValue={activeTab} onValueChange={setActiveTab}>
          <TabsList className="w-full rounded-none border-b bg-transparent p-0">
            <TabsTrigger
              value="formatted"
              className="flex-1 rounded-none border-b-2 border-b-transparent data-[state=active]:border-b-primary data-[state=active]:shadow-none py-3"
            >
              Formateado
            </TabsTrigger>
            <TabsTrigger
              value="raw"
              className="flex-1 rounded-none border-b-2 border-b-transparent data-[state=active]:border-b-primary data-[state=active]:shadow-none py-3"
            >
              Sin procesar
            </TabsTrigger>
          </TabsList>
          <div className="p-4">
            <TabsContent value="formatted" className="mt-0">
              <pre className="bg-muted p-4 rounded-md overflow-auto max-h-96 text-xs">
                {responseString}
              </pre>
            </TabsContent>
            <TabsContent value="raw" className="mt-0">
              <div className="bg-muted p-4 rounded-md overflow-auto max-h-96 text-xs break-all">
                {JSON.stringify(response)}
              </div>
            </TabsContent>
          </div>
        </Tabs>
      </CardContent>
    </Card>
  );
}

```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.trustlesswork.com/trustless-work/v1-es/dapps-oss/escrow-lab/componentes-de-ui/utilidades.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
