/** * Render helpers for * * Provides DSR_PORTAL_STYLES, buildFormHtml, and buildSuccessHtml. * Kept separate from the element class to stay under the 300-LOC target. */ import type { DSRRequestType } from '@breakpilot/compliance-sdk-types' import { COMMON_STYLES } from './base' import type { DSRTranslations } from './dsr-portal-translations' // ============================================================================= // STYLES // ============================================================================= export const DSR_PORTAL_STYLES = ` ${COMMON_STYLES} :host { max-width: 600px; margin: 0 auto; padding: 20px; } .portal { background: #fff; } .title { margin: 0 0 10px; font-size: 24px; font-weight: 600; color: #1a1a1a; } .subtitle { margin: 0 0 20px; color: #666; } .form-group { margin-bottom: 20px; } .label { display: block; font-weight: 500; margin-bottom: 10px; } .type-options { display: grid; gap: 10px; } .type-option { display: flex; padding: 15px; border: 2px solid #ddd; border-radius: 8px; cursor: pointer; background: #fff; transition: all 0.2s; } .type-option:hover { border-color: #999; } .type-option.selected { border-color: #1a1a1a; background: #f5f5f5; } .type-option input { margin-right: 15px; } .type-name { font-weight: 500; } .type-description { font-size: 13px; color: #666; } .input { width: 100%; padding: 12px; font-size: 14px; border: 1px solid #ddd; border-radius: 4px; box-sizing: border-box; } .input:focus { outline: none; border-color: #1a1a1a; } .textarea { resize: vertical; min-height: 100px; } .error { padding: 12px; background: #fef2f2; color: #dc2626; border-radius: 4px; margin-bottom: 15px; } .btn-submit { width: 100%; padding: 12px 24px; font-size: 16px; font-weight: 500; color: #fff; background: #1a1a1a; border: none; border-radius: 4px; cursor: pointer; } .btn-submit:disabled { opacity: 0.5; cursor: not-allowed; } .disclaimer { margin-top: 20px; font-size: 12px; color: #666; } .success { text-align: center; padding: 40px 20px; background: #f0fdf4; border-radius: 8px; } .success-icon { font-size: 48px; margin-bottom: 20px; } .success-title { margin: 0 0 10px; color: #166534; } .success-message { margin: 0; color: #166534; } ` // ============================================================================= // HTML BUILDERS // ============================================================================= export interface FormRenderOptions { t: DSRTranslations selectedType: DSRRequestType | null name: string email: string additionalInfo: string isSubmitting: boolean error: string | null } export function buildFormHtml(styles: string, opts: FormRenderOptions): string { const { t, selectedType, name, email, additionalInfo, isSubmitting, error } = opts const types: DSRRequestType[] = [ 'ACCESS', 'RECTIFICATION', 'ERASURE', 'PORTABILITY', 'RESTRICTION', 'OBJECTION', ] const typesHtml = types .map( type => ` ` ) .join('') const isValid = selectedType && email && name const isDisabled = !isValid || isSubmitting return `

${t.title}

${t.subtitle}

${typesHtml}
${error ? `
${error}
` : ''}

${t.disclaimer}

` } export function buildSuccessHtml(styles: string, t: DSRTranslations, email: string): string { return `

${t.successTitle}

${t.successMessage} ${email}.

` }