Skip to content

feat(infakt): FE plugin – connection setup + invoice detail section #1282

Description

Part of #1279
Depends on #1281 (platformType must be registered in API)

Context

Operators need a way to create and configure an Infakt connection in the OL web UI, and to see KSeF clearance status on invoice detail pages.

Pattern: apps/web/src/plugins/ksef/ structure.

The backend CorrectionIssuer capability is already implemented for inFakt in InfaktInvoicingAdapter (PR #1292, part of this epic #1279), so the correction-flow (KOR) scope item below is real, not speculative.

Scope

1. Plugin descriptor

File: apps/web/src/plugins/infakt/index.ts

export const infaktPlugin = definePlugin({
  id: 'infakt',
  platformType: 'infakt',
  platform: {
    displayName: 'inFakt',
    setupCard: {
      title: 'inFakt',
      description: 'Polish accounting platform with native KSeF integration',
    },
    StructuredConfigSection: InfaktStructuredSection,
    CredentialsPanel: InfaktCredentialsPanel,
    invoiceDetailSection: InfaktInvoiceDetailSection,
  },
});

2. Structured config section

File: apps/web/src/plugins/infakt/components/infakt-structured-section.tsx

Fields:

  • baseUrl (optional): text input, placeholder https://api.infakt.pl, used only for sandbox override
  • Helper text explaining sandbox vs production

Zod schema for form validation.

3. Credentials panel

File: apps/web/src/plugins/infakt/components/infakt-credentials-panel.tsx

  • API key display (masked: last 4 chars visible)
  • "Rotate API key" button → PUT /connections/{id}/credentials
  • Input field for new API key + confirm

Pattern: apps/web/src/plugins/ksef/components/ksef-credentials-panel.tsx

4. Invoice detail section

File: apps/web/src/plugins/infakt/components/infakt-invoice-detail-section.tsx

Renders conditional on regulatoryStatus:

  • not-applicable: nothing
  • submitted: "Pending KSeF clearance..." + spinner
  • cleared / accepted: "KSeF Cleared" + clearanceReference (KSeF number) as copyable chip
  • rejected: "KSeF Rejected" + failureReason

Data comes from the InvoiceRecord prop already fetched by host — no additional API call.

Pattern: apps/web/src/plugins/ksef/components/ksef-invoice-detail-section.tsx

5. Invoice correction flow (KOR)

File: apps/web/src/plugins/infakt/components/infakt-invoice-correction-flow.tsx

The inFakt backend adapter (InfaktInvoicingAdapter, PR #1292) implements the CorrectionIssuer capability, so inFakt supports issuing KSeF corrections (KOR) the same way the KSeF plugin does. The backend endpoint POST /invoices/:invoiceId/correct is capability-gated and platform-neutral, and the FE mutation hook useIssueCorrectionMutation (from apps/web/src/features/invoicing) is already generic — this component is mostly a near 1:1 port of the KSeF equivalent.

Pattern: apps/web/src/plugins/ksef/components/ksef-invoice-correction-flow.tsx (near 1:1 reuse of structure/logic):

  • Same line-row model: optional free-text reason, repeatable rows of originalLineNumber / newQuantity / newUnitPriceGross
  • Starts with one empty row and an "Add line" affordance
  • Content-only component conforming to the InvoiceCorrectionFlowProps slot contract; the host dialog owns the outer chrome
  • Uses the same generic useIssueCorrectionMutation hook — no inFakt-specific API call needed

Register it on the plugin descriptor's platform.invoiceCorrectionFlow slot (in apps/web/src/plugins/infakt/index.ts, alongside invoiceDetailSection).

6. Register in plugin barrel

File: apps/web/src/plugins/index.ts

import { infaktPlugin } from './infakt';
export const plugins = [ ...existing, infaktPlugin ] as const satisfies readonly OpenLinkerPlugin[];

Acceptance criteria

  • pnpm lint passes
  • pnpm type-check passes
  • /connections/new shows inFakt card
  • Selecting inFakt card shows create connection form with API key field
  • Empty API key shows form validation error
  • Successful create shows connection in list with infakt platformType
  • Credentials panel shows masked key + rotate button
  • Invoice with regulatoryStatus: 'cleared' shows KSeF number
  • Invoice with regulatoryStatus: 'submitted' shows pending state
  • Invoice with regulatoryStatus: 'rejected' shows rejection reason
  • Correction flow modal opens with one empty line row and an "Add line" affordance
  • Submitting with a missing line number shows a validation error
  • Successful correction submit shows a success toast and closes the dialog
  • Failed correction submit shows an error toast and keeps the dialog open

Metadata

Metadata

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions