|
@@ -7,13 +7,15 @@ import { toast } from "sonner"
|
|
|
import { Separator } from "@/components/ui/separator"
|
|
import { Separator } from "@/components/ui/separator"
|
|
|
import { Button } from "@/components/ui/button"
|
|
import { Button } from "@/components/ui/button"
|
|
|
import { Badge } from "@/components/ui/badge"
|
|
import { Badge } from "@/components/ui/badge"
|
|
|
|
|
+import { ServidorSelector } from "./ServidorSelector"
|
|
|
|
|
|
|
|
interface ParametrosSRIFormProps {
|
|
interface ParametrosSRIFormProps {
|
|
|
xmlFile: File | null
|
|
xmlFile: File | null
|
|
|
p12File: File | null
|
|
p12File: File | null
|
|
|
password: string
|
|
password: string
|
|
|
accessKey: string
|
|
accessKey: string
|
|
|
- ambiente: '1' | '2'
|
|
|
|
|
|
|
+ ambiente: '1' | '2' // Ambiente de envío seleccionado por usuario
|
|
|
|
|
+ ambienteDetectado: '1' | '2' | null // Ambiente detectado del XML (solo lectura)
|
|
|
signedXml: string | null
|
|
signedXml: string | null
|
|
|
isLoading: boolean
|
|
isLoading: boolean
|
|
|
onXmlFileChange: (file: File | null) => void
|
|
onXmlFileChange: (file: File | null) => void
|
|
@@ -21,6 +23,7 @@ interface ParametrosSRIFormProps {
|
|
|
onPasswordChange: (password: string) => void
|
|
onPasswordChange: (password: string) => void
|
|
|
onAccessKeyChange: (key: string) => void
|
|
onAccessKeyChange: (key: string) => void
|
|
|
onLoadSignedXml: (file: File) => void
|
|
onLoadSignedXml: (file: File) => void
|
|
|
|
|
+ onAmbienteChange: (ambiente: '1' | '2') => void
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
export function ParametrosSRIForm({
|
|
export function ParametrosSRIForm({
|
|
@@ -29,6 +32,7 @@ export function ParametrosSRIForm({
|
|
|
password,
|
|
password,
|
|
|
accessKey,
|
|
accessKey,
|
|
|
ambiente,
|
|
ambiente,
|
|
|
|
|
+ ambienteDetectado,
|
|
|
signedXml,
|
|
signedXml,
|
|
|
isLoading,
|
|
isLoading,
|
|
|
onXmlFileChange,
|
|
onXmlFileChange,
|
|
@@ -36,89 +40,115 @@ export function ParametrosSRIForm({
|
|
|
onPasswordChange,
|
|
onPasswordChange,
|
|
|
onAccessKeyChange,
|
|
onAccessKeyChange,
|
|
|
onLoadSignedXml,
|
|
onLoadSignedXml,
|
|
|
|
|
+ onAmbienteChange,
|
|
|
}: ParametrosSRIFormProps) {
|
|
}: ParametrosSRIFormProps) {
|
|
|
return (
|
|
return (
|
|
|
- <Card>
|
|
|
|
|
- <CardHeader>
|
|
|
|
|
- <CardTitle>Documentos y Parámetros</CardTitle>
|
|
|
|
|
- <CardDescription>
|
|
|
|
|
- Carga tu XML firmado y parámetros necesarios se llenan automáticamente
|
|
|
|
|
- </CardDescription>
|
|
|
|
|
- </CardHeader>
|
|
|
|
|
- <CardContent className="space-y-6">
|
|
|
|
|
- {/* Archivo XML Firmado */}
|
|
|
|
|
- <div className="space-y-2">
|
|
|
|
|
- <Dropzone
|
|
|
|
|
- accept={{
|
|
|
|
|
- "text/xml": [".xml"],
|
|
|
|
|
- "application/xml": [".xml"],
|
|
|
|
|
- }}
|
|
|
|
|
- maxFiles={1}
|
|
|
|
|
- onDrop={(acceptedFiles) => {
|
|
|
|
|
- if (acceptedFiles.length > 0) {
|
|
|
|
|
- onLoadSignedXml(acceptedFiles[0])
|
|
|
|
|
- }
|
|
|
|
|
- }}
|
|
|
|
|
- disabled={isLoading}
|
|
|
|
|
- className="border-2 border-dashed rounded-lg p-6"
|
|
|
|
|
- >
|
|
|
|
|
- <div className="flex flex-col items-center gap-2 text-center">
|
|
|
|
|
- <div className="rounded-full bg-primary/10 p-3">
|
|
|
|
|
- <Upload className="h-5 w-5 text-primary" />
|
|
|
|
|
|
|
+ <div className="space-y-6">
|
|
|
|
|
+ <Card>
|
|
|
|
|
+ <CardHeader>
|
|
|
|
|
+ <CardTitle>Documentos y Parámetros</CardTitle>
|
|
|
|
|
+ <CardDescription>
|
|
|
|
|
+ Carga tu XML firmado y parámetros necesarios se llenan automáticamente
|
|
|
|
|
+ </CardDescription>
|
|
|
|
|
+ </CardHeader>
|
|
|
|
|
+ <CardContent className="space-y-6">
|
|
|
|
|
+ {/* Archivo XML Firmado */}
|
|
|
|
|
+ <div className="space-y-2">
|
|
|
|
|
+ <Dropzone
|
|
|
|
|
+ accept={{
|
|
|
|
|
+ "text/xml": [".xml"],
|
|
|
|
|
+ "application/xml": [".xml"],
|
|
|
|
|
+ }}
|
|
|
|
|
+ maxFiles={1}
|
|
|
|
|
+ onDrop={(acceptedFiles) => {
|
|
|
|
|
+ if (acceptedFiles.length > 0) {
|
|
|
|
|
+ onLoadSignedXml(acceptedFiles[0])
|
|
|
|
|
+ }
|
|
|
|
|
+ }}
|
|
|
|
|
+ disabled={isLoading}
|
|
|
|
|
+ className="border-2 border-dashed rounded-lg p-6"
|
|
|
|
|
+ >
|
|
|
|
|
+ <div className="flex flex-col items-center gap-2 text-center">
|
|
|
|
|
+ <div className="rounded-full bg-primary/10 p-3">
|
|
|
|
|
+ <Upload className="h-5 w-5 text-primary" />
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className="space-y-1">
|
|
|
|
|
+ <p className="text-sm font-medium">
|
|
|
|
|
+ {signedXml && xmlFile ? (
|
|
|
|
|
+ <span className="flex items-center gap-2">
|
|
|
|
|
+ <Check className="h-4 w-4 text-green-500" />
|
|
|
|
|
+ {xmlFile.name}
|
|
|
|
|
+ </span>
|
|
|
|
|
+ ) : (
|
|
|
|
|
+ "Arrastra un XML firmado aquí"
|
|
|
|
|
+ )}
|
|
|
|
|
+ </p>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
- <div className="space-y-1">
|
|
|
|
|
- <p className="text-sm font-medium">
|
|
|
|
|
- {signedXml && xmlFile ? (
|
|
|
|
|
- <span className="flex items-center gap-2">
|
|
|
|
|
- <Check className="h-4 w-4 text-green-500" />
|
|
|
|
|
- {xmlFile.name}
|
|
|
|
|
- </span>
|
|
|
|
|
- ) : (
|
|
|
|
|
- "Arrastra un XML firmado aquí"
|
|
|
|
|
- )}
|
|
|
|
|
- </p>
|
|
|
|
|
- </div>
|
|
|
|
|
- </div>
|
|
|
|
|
- </Dropzone>
|
|
|
|
|
- </div>
|
|
|
|
|
- <Separator />
|
|
|
|
|
-
|
|
|
|
|
- {/* Información del XML (solo lectura) */}
|
|
|
|
|
- {signedXml && accessKey && (
|
|
|
|
|
- <div className="space-y-4 p-4 bg-muted/50 rounded-lg">
|
|
|
|
|
- <div className="space-y-2">
|
|
|
|
|
- <Label htmlFor="accessKey" className="flex items-center gap-2">
|
|
|
|
|
- <Key className="h-4 w-4" />
|
|
|
|
|
- Clave de Acceso (extraída del XML)
|
|
|
|
|
- </Label>
|
|
|
|
|
- <Input
|
|
|
|
|
- id="accessKey"
|
|
|
|
|
- type="text"
|
|
|
|
|
- value={accessKey}
|
|
|
|
|
- disabled
|
|
|
|
|
- className="font-mono bg-background"
|
|
|
|
|
- />
|
|
|
|
|
- <p className="text-xs text-muted-foreground">
|
|
|
|
|
- La clave de acceso fue extraída automáticamente del XML
|
|
|
|
|
- </p>
|
|
|
|
|
- </div>
|
|
|
|
|
|
|
+ </Dropzone>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <Separator />
|
|
|
|
|
|
|
|
- <div className="space-y-2">
|
|
|
|
|
- <Label className="flex items-center gap-2">
|
|
|
|
|
- Ambiente
|
|
|
|
|
- </Label>
|
|
|
|
|
- <div className="flex items-center gap-2">
|
|
|
|
|
- <Badge variant={ambiente === '2' ? 'default' : 'secondary'}>
|
|
|
|
|
- {ambiente === '1' ? 'Pruebas' : 'Producción'}
|
|
|
|
|
- </Badge>
|
|
|
|
|
|
|
+ {/* Información del XML (solo lectura) */}
|
|
|
|
|
+ {signedXml && accessKey && (
|
|
|
|
|
+ <div className="space-y-4 p-4 bg-muted/50 rounded-lg">
|
|
|
|
|
+ <div className="space-y-2">
|
|
|
|
|
+ <Label htmlFor="accessKey" className="flex items-center gap-2">
|
|
|
|
|
+ <Key className="h-4 w-4" />
|
|
|
|
|
+ Clave de Acceso (extraída del XML)
|
|
|
|
|
+ </Label>
|
|
|
|
|
+ <Input
|
|
|
|
|
+ id="accessKey"
|
|
|
|
|
+ type="text"
|
|
|
|
|
+ value={accessKey}
|
|
|
|
|
+ disabled
|
|
|
|
|
+ className="font-mono bg-background"
|
|
|
|
|
+ />
|
|
|
<p className="text-xs text-muted-foreground">
|
|
<p className="text-xs text-muted-foreground">
|
|
|
- Detectado del XML
|
|
|
|
|
|
|
+ La clave de acceso fue extraída automáticamente del XML
|
|
|
</p>
|
|
</p>
|
|
|
</div>
|
|
</div>
|
|
|
|
|
+
|
|
|
|
|
+ <div className="space-y-2">
|
|
|
|
|
+ <Label className="flex items-center gap-2">
|
|
|
|
|
+ Ambiente detectado del XML
|
|
|
|
|
+ </Label>
|
|
|
|
|
+ <div className="flex items-center gap-2">
|
|
|
|
|
+ <Badge variant={ambienteDetectado === '2' ? 'default' : 'secondary'}>
|
|
|
|
|
+ {ambienteDetectado === '1' ? 'Pruebas' : 'Producción'}
|
|
|
|
|
+ </Badge>
|
|
|
|
|
+ <p className="text-xs text-muted-foreground">
|
|
|
|
|
+ Detectado automáticamente del XML
|
|
|
|
|
+ </p>
|
|
|
|
|
+ </div>
|
|
|
|
|
+
|
|
|
|
|
+ {/* Mostrar advertencia si los ambientes no coinciden */}
|
|
|
|
|
+ {ambienteDetectado && ambienteDetectado !== ambiente && (
|
|
|
|
|
+ <div className="mt-2 p-2 bg-yellow-50 border border-yellow-200 rounded-lg">
|
|
|
|
|
+ <div className="flex items-start gap-2">
|
|
|
|
|
+ <div className="w-3 h-3 rounded-full bg-yellow-200 flex items-center justify-center mt-0.5">
|
|
|
|
|
+ <span className="text-yellow-800 text-xs font-bold">!</span>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div className="text-xs text-yellow-800">
|
|
|
|
|
+ <p className="font-medium">Atención:</p>
|
|
|
|
|
+ <p>El XML indica ambiente de {ambienteDetectado === '1' ? 'Pruebas' : 'Producción'}, pero estás enviando a ambiente de {ambiente === '1' ? 'Pruebas' : 'Producción'}.</p>
|
|
|
|
|
+ <p>Verifica que esta selección sea correcta.</p>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ )}
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
- </div>
|
|
|
|
|
- )}
|
|
|
|
|
- </CardContent>
|
|
|
|
|
- </Card>
|
|
|
|
|
|
|
+ )}
|
|
|
|
|
+ </CardContent>
|
|
|
|
|
+ </Card>
|
|
|
|
|
+
|
|
|
|
|
+ {/* Selector de Servidor para Envío */}
|
|
|
|
|
+ <ServidorSelector
|
|
|
|
|
+ ambiente={ambiente}
|
|
|
|
|
+ onAmbienteChange={onAmbienteChange}
|
|
|
|
|
+ disabled={isLoading}
|
|
|
|
|
+ />
|
|
|
|
|
+ </div>
|
|
|
)
|
|
)
|
|
|
}
|
|
}
|