diff --git a/.github/workflows/build-conditions-konto.yml b/.github/workflows/build-conditions-konto.yml index 1807726e3..7dbc3324d 100644 --- a/.github/workflows/build-conditions-konto.yml +++ b/.github/workflows/build-conditions-konto.yml @@ -20,7 +20,7 @@ on: jobs: changes: name: Checking for directory changes in repository - runs-on: ubuntu-latest + runs-on: ["self-hosted", "Linux", "X64", "bratislava"] outputs: forms-shared: ${{ steps.filter.outputs.forms-shared }} next: ${{ steps.filter.outputs.next }} @@ -55,7 +55,7 @@ jobs: conditions: name: Checking build conditions needs: changes - runs-on: ubuntu-latest + runs-on: ["self-hosted", "Linux", "X64", "bratislava"] env: COUNT: 0 outputs: diff --git a/.github/workflows/cluster-deploy-conditions-konto.yml b/.github/workflows/cluster-deploy-conditions-konto.yml index ef5885733..542fdd7ca 100644 --- a/.github/workflows/cluster-deploy-conditions-konto.yml +++ b/.github/workflows/cluster-deploy-conditions-konto.yml @@ -60,7 +60,7 @@ on: jobs: conditions: name: Checking konto deployment conditions - runs-on: ubuntu-latest + runs-on: ["self-hosted", "Linux", "X64", "bratislava"] env: COUNT: 0 outputs: diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b4d730a73..070b23a0a 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -11,7 +11,7 @@ on: jobs: build-forms-shared: name: Build and push specific forms-shared image - uses: bratislava/github-actions/.github/workflows/build-with-bratiska-cli.yml@stable + uses: bratislava/github-actions/.github/workflows/build-with-bratiska-cli-inhouse.yml@stable with: directory: forms-shared/ build_image_no_registry: '' diff --git a/.github/workflows/validate-and-build.yml b/.github/workflows/validate-and-build.yml index 4887cbd31..fcd748056 100644 --- a/.github/workflows/validate-and-build.yml +++ b/.github/workflows/validate-and-build.yml @@ -12,7 +12,7 @@ jobs: build-forms-shared: name: Build image of forms-shared and push it to harbor - uses: bratislava/github-actions/.github/workflows/build-with-bratiska-cli.yml@stable + uses: bratislava/github-actions/.github/workflows/build-with-bratiska-cli-inhouse.yml@stable with: directory: forms-shared/ build_image_no_registry: '' @@ -39,7 +39,7 @@ jobs: name: build next needs: [conditions, validate-next] if: needs.conditions.outputs.next == 'true' || needs.conditions.outputs.forms-shared == 'true' - uses: bratislava/github-actions/.github/workflows/build-with-bratiska-cli.yml@stable + uses: bratislava/github-actions/.github/workflows/build-with-bratiska-cli-inhouse.yml@stable with: directory: next/ build_arg: '--build_arg="FORMS_SHARED_TAG=${{ github.sha }}"' @@ -52,7 +52,7 @@ jobs: name: build Strapi needs: conditions if: needs.conditions.outputs.strapi == 'true' - uses: bratislava/github-actions/.github/workflows/build-with-bratiska-cli.yml@stable + uses: bratislava/github-actions/.github/workflows/build-with-bratiska-cli-inhouse.yml@stable with: directory: strapi/ debug: --debug @@ -71,7 +71,7 @@ jobs: name: build nest-forms-backend needs: [conditions, validate-nest-forms-backend] if: needs.conditions.outputs.nest-forms-backend == 'true' || needs.conditions.outputs.forms-shared == 'true' - uses: bratislava/github-actions/.github/workflows/build-with-bratiska-cli.yml@stable + uses: bratislava/github-actions/.github/workflows/build-with-bratiska-cli-inhouse.yml@stable with: directory: nest-forms-backend/ build_arg: '--build_arg="FORMS_SHARED_TAG=${{ github.sha }}"' @@ -92,7 +92,7 @@ jobs: name: build nest-clamav-scanner needs: [conditions, validate-nest-clamav-scanner] if: needs.conditions.outputs.nest-clamav-scanner == 'true' - uses: bratislava/github-actions/.github/workflows/build-with-bratiska-cli.yml@stable + uses: bratislava/github-actions/.github/workflows/build-with-bratiska-cli-inhouse.yml@stable with: directory: nest-clamav-scanner/ secrets: diff --git a/.github/workflows/validate-forms-shared-konto.yml b/.github/workflows/validate-forms-shared-konto.yml index 413cc2785..782f71c5d 100644 --- a/.github/workflows/validate-forms-shared-konto.yml +++ b/.github/workflows/validate-forms-shared-konto.yml @@ -16,7 +16,7 @@ on: jobs: test: name: Forms-shared tests - runs-on: ubuntu-latest + runs-on: ["self-hosted", "Linux", "X64", "bratislava"] defaults: run: working-directory: ${{ inputs.directory }} diff --git a/.github/workflows/validate-nest-prisma-konto.yml b/.github/workflows/validate-nest-prisma-konto.yml index 58e573078..2f3549f33 100644 --- a/.github/workflows/validate-nest-prisma-konto.yml +++ b/.github/workflows/validate-nest-prisma-konto.yml @@ -26,7 +26,7 @@ on: jobs: test: name: Unit tests and lint - runs-on: ubuntu-latest + runs-on: ["self-hosted", "Linux", "X64", "bratislava"] steps: - name: Checkout code uses: actions/checkout@v4 diff --git a/forms-shared/src/definitions/devFormDefinitions.ts b/forms-shared/src/definitions/devFormDefinitions.ts index 3de7399f1..5966ec749 100644 --- a/forms-shared/src/definitions/devFormDefinitions.ts +++ b/forms-shared/src/definitions/devFormDefinitions.ts @@ -1,10 +1,8 @@ import { FormDefinition, FormDefinitionType } from './formDefinitionTypes' import { generalTermsAndConditions } from './termsAndConditions' -import mimoriadnyOdvozALikvidaciaOdpadu from '../schemas/olo/mimoriadnyOdvozALikvidaciaOdpadu' -import zevoMechanickaVykladkaAZhodnotenieOdpaduPodlaIntegrovanehoPovlenia from '../schemas/olo/zevoMechanickaVykladkaAZhodnotenieOdpaduPodlaIntegrovanehoPovlenia' -import zevoRucnaVykladkaAZhodnotenieOdpaduPodlaIntegrovanehoPovlenia from '../schemas/olo/zevoRucnaVykladkaAZhodnotenieOdpaduPodlaIntegrovanehoPovlenia' -import zevoPodrvenieAZhodnotenieOdpaduVysypanimDoZasobnika from '../schemas/olo/zevoPodrvenieAZhodnotenieOdpaduVysypanimDoZasobnika' -import zevoUzatvorenieZmluvyONakladaniSOdpadom from '../schemas/olo/zevoUzatvorenieZmluvyONakladaniSOdpadom' +import mimoriadnyOdvozAZhodnotenieOdpadu from '../schemas/olo/mimoriadnyOdvozAZhodnotenieOdpadu' +import energetickeZhodnotenieOdpaduVZevo from '../schemas/olo/energetickeZhodnotenieOdpaduVZevo' +import uzatvorenieZmluvyONakladaniSOdpadom from '../schemas/olo/uzatvorenieZmluvyONakladaniSOdpadom' import docisteniStanovistaZbernychNadob from '../schemas/olo/docisteniStanovistaZbernychNadob' import odvozOdpaduVelkokapacitnymAleboLisovacimKontajnerom from '../schemas/olo/odvozOdpaduVelkokapacitnymAleboLisovacimKontajnerom' import koloTaxi from '../schemas/olo/koloTaxi' @@ -17,9 +15,9 @@ import triedenyZberPapieraPlastovASklaPreSpravcovskeSpolocnosti from '../schemas export const devFormDefinitions: FormDefinition[] = [ { type: FormDefinitionType.Email, - slug: 'olo-mimoriadny-odvoz-a-likvidacia-odpadu', - title: 'Mimoriadny odvoz a likvidácia odpadu', - schemas: mimoriadnyOdvozALikvidaciaOdpadu, + slug: 'olo-mimoriadny-odvoz-a-zhodnotenie-odpadu', + title: 'Mimoriadny odvoz a zhodnotenie odpadu', + schemas: mimoriadnyOdvozAZhodnotenieOdpadu, email: '', termsAndConditions: generalTermsAndConditions, messageSubjectDefault: '', @@ -27,9 +25,9 @@ export const devFormDefinitions: FormDefinition[] = [ }, { type: FormDefinitionType.Email, - slug: 'olo-zevo-mechanicka-vykladka-a-zhodnotenie-odpadu-podla-integrovaneho-povolenia', - title: 'Mechanická vykládka a zhodnotenie odpadu podľa integrovaného povolenia', - schemas: zevoMechanickaVykladkaAZhodnotenieOdpaduPodlaIntegrovanehoPovlenia, + slug: 'olo-energeticke-zhodnotenie-odpadu-v-zevo', + title: 'Energetické zhodnotenie odpadu v ZEVO', + schemas: energetickeZhodnotenieOdpaduVZevo, email: '', termsAndConditions: generalTermsAndConditions, messageSubjectDefault: '', @@ -37,29 +35,9 @@ export const devFormDefinitions: FormDefinition[] = [ }, { type: FormDefinitionType.Email, - slug: 'olo-zevo-rucna-vykladka-a-zhodnotenie-odpadu-podla-integrovaneho-povolenia', - title: 'Ručná vykládka a zhodnotenie odpadu podľa integrovaného povolenia', - schemas: zevoRucnaVykladkaAZhodnotenieOdpaduPodlaIntegrovanehoPovlenia, - email: '', - termsAndConditions: generalTermsAndConditions, - messageSubjectDefault: '', - embedded: 'olo', - }, - { - type: FormDefinitionType.Email, - slug: 'olo-zevo-podrvenie-a-zhodnotenie-odpadu-vysypanim-do-zasobnika', - title: 'Podrvenie a zhodnotenie odpadu vysypaním do zásobníka', - schemas: zevoPodrvenieAZhodnotenieOdpaduVysypanimDoZasobnika, - email: '', - termsAndConditions: generalTermsAndConditions, - messageSubjectDefault: '', - embedded: 'olo', - }, - { - type: FormDefinitionType.Email, - slug: 'olo-zevo-uzatvorenie-zmluvy-o-nakladani-s-odpadom', + slug: 'olo-uzatvorenie-zmluvy-o-nakladani-s-odpadom', title: 'Uzatvorenie zmluvy o nakladaní s odpadom', - schemas: zevoUzatvorenieZmluvyONakladaniSOdpadom, + schemas: uzatvorenieZmluvyONakladaniSOdpadom, email: '', termsAndConditions: generalTermsAndConditions, messageSubjectDefault: '', diff --git a/forms-shared/src/generator/functions.ts b/forms-shared/src/generator/functions.ts index 857b32f52..074cf5402 100644 --- a/forms-shared/src/generator/functions.ts +++ b/forms-shared/src/generator/functions.ts @@ -655,15 +655,21 @@ export const schema = ( description?: string }, uiOptions: SchemaUiOptions, - steps: ReturnType[], + steps: (ReturnType | null)[], ): Schemas => { + const filteredSteps = steps.filter((stepInner) => stepInner != null) as ReturnType< + typeof step | typeof conditionalStep + >[] + return { schema: removeUndefinedValues({ ...options, - allOf: steps.map((stepInner) => stepInner.schema), + allOf: filteredSteps.map((stepInner) => stepInner.schema), }) as RJSFSchema, uiSchema: removeUndefinedValues({ - ...Object.fromEntries(steps.map((stepInner) => [stepInner.property, stepInner.uiSchema])), + ...Object.fromEntries( + filteredSteps.map((stepInner) => [stepInner.property, stepInner.uiSchema]), + ), 'ui:options': uiOptions, 'ui:hideError': true, }) as UiSchema, diff --git a/forms-shared/src/schemas/olo/docisteniStanovistaZbernychNadob.ts b/forms-shared/src/schemas/olo/docisteniStanovistaZbernychNadob.ts index 929b2b26d..217cd138a 100644 --- a/forms-shared/src/schemas/olo/docisteniStanovistaZbernychNadob.ts +++ b/forms-shared/src/schemas/olo/docisteniStanovistaZbernychNadob.ts @@ -1,5 +1,198 @@ -import { schema, step } from '../../generator/functions' +import { + checkbox, + conditionalFields, + customComponentsField, + datePicker, + input, + object, + radioGroup, + schema, + select, + step, + textArea, +} from '../../generator/functions' +import { createCondition, createStringOptions } from '../../generator/helpers' +import { sharedAddressField, sharedPhoneNumberField } from '../shared/fields' export default schema({ title: 'Dočistenie stanovišťa zberných nádob' }, {}, [ - step('ziadatel', { title: 'Žiadateľ' }, []), + step('ziadatel', { title: 'Žiadateľ' }, [ + radioGroup( + 'ziadatelTyp', + { + type: 'string', + title: 'Žiadateľ', + required: true, + options: createStringOptions(['Obyvateľ', 'Právnická osoba', 'Správcovská spoločnosť']), + }, + { variant: 'boxed', orientations: 'column' }, + ), + conditionalFields(createCondition([[['ziadatelTyp'], { const: 'Obyvateľ' }]]), [ + object( + 'menoPriezvisko', + { required: true }, + { + columns: true, + columnsRatio: '1/1', + }, + [ + input('meno', { title: 'Meno', required: true, type: 'text' }, {}), + input('priezvisko', { title: 'Priezvisko', required: true, type: 'text' }, {}), + ], + ), + sharedAddressField('adresaObyvatel', 'Adresa trvalého pobytu', true), + ]), + conditionalFields( + createCondition([[['ziadatelTyp'], { enum: ['Právnická osoba', 'Správcovská spoločnosť'] }]]), + [ + input('nazov', { type: 'text', title: 'Názov organizácie', required: true }, {}), + sharedAddressField('adresaPravnickaOsoba', 'Adresa sídla', true), + input('ico', { type: 'text', title: 'IČO', required: true }, {}), + input('dic', { type: 'text', title: 'DIČ', required: true }, {}), + checkbox( + 'platcaDph', + { title: 'Som platca DPH?', required: true }, + { checkboxLabel: 'Som platca DPH?', variant: 'boxed' }, + ), + conditionalFields(createCondition([[['platcaDph'], { const: true }]]), [ + input('icDph', { type: 'text', title: 'IČ DPH', required: true }, {}), + ]), + ], + ), + conditionalFields(createCondition([[['ziadatelTyp'], { const: 'Právnická osoba' }]]), [ + input('konatel', { type: 'text', title: 'Konateľ (meno, priezvisko)', required: true }, {}), + input( + 'zastupeny', + { type: 'text', title: 'Zastúpený - na základe splnomocnenia (meno, priezvisko)' }, + {}, + ), + ]), + conditionalFields( + createCondition([[['ziadatelTyp'], { enum: ['Právnická osoba', 'Správcovská spoločnosť'] }]]), + [ + input( + 'kontaktnaOsoba', + { type: 'text', title: 'Meno kontaktnej osoby', required: true }, + {}, + ), + ], + ), + sharedPhoneNumberField('telefon', true), + conditionalFields( + createCondition([[['ziadatelTyp'], { enum: ['Právnická osoba', 'Správcovská spoločnosť'] }]]), + [input('email', { title: 'E-mail', required: true, type: 'email' }, {})], + ), + conditionalFields(createCondition([[['ziadatelTyp'], { enum: ['Obyvateľ'] }]]), [ + input('emailObyvatel', { title: 'E-mail', type: 'email' }, {}), + ]), + object('fakturacia', { required: true }, { objectDisplay: 'boxed', title: 'Fakturácia' }, [ + input('iban', { type: 'ba-iban', title: 'IBAN', required: true }, {}), + checkbox( + 'elektronickaFaktura', + { + title: 'Zasielanie faktúry elektronicky', + required: true, + }, + { + helptextHeader: + 'V prípade vyjadrenia nesúhlasu bude zákazníkovi za zasielanie faktúry poštou účtovaný poplatok 10 € bez DPH. Osobitné ustanovenia o zasielaní faktúry v elektronickej podobe v zmysle bodu 5.9 VOP.', + checkboxLabel: 'Súhlasím so zaslaním elektronickej fakúry', + variant: 'boxed', + }, + ), + conditionalFields(createCondition([[['elektronickaFaktura'], { const: true }]]), [ + input( + 'emailPreFaktury', + { + type: 'email', + title: 'E-mail pre zasielanie elektronických faktúr', + required: true, + }, + {}, + ), + ]), + ]), + ]), + step('sluzba', { title: 'Služba' }, [ + input( + 'miestoDodania', + { + type: 'text', + title: 'Miesto dodania / výkonu služby', + required: true, + }, + { + helptextHeader: 'Presná adresa', + }, + ), + select( + 'komodita', + { + title: 'Vyberte komoditu', + required: true, + options: createStringOptions( + [ + 'Papier', + 'Plast', + 'Zmesový komunálny odpad', + 'Kuchynský biologicky rozložiteľný odpad', + 'Biologicky rozložiteľný odpad', + ], + false, + ), + }, + { + helptextHeader: 'Poplatok je účtovaný za množstvo naložených a vysypaných nádob', + }, + ), + datePicker( + 'preferovanyDatum', + { + title: 'Preferovaný dátum vykonania služby', + required: true, + }, + { + helptextHeader: + 'Vami zvolený dátum má iba informačný charakter. Objednávku je potrebné podať minimálne 2 pracovné dni pred zvoleným termínom. V prípade, ak vami zvolený termín nebude voľný, budeme vás kontaktovať.', + size: 'medium', + }, + ), + textArea( + 'doplnujuceInfo', + { + title: 'Doplňujúce info', + required: true, + }, + { + helptextHeader: 'Špecifikujte individuálne požiadavky.', + }, + ), + ]), + step('suhlasy', { title: 'Súhlasy' }, [ + checkbox( + 'suhlas', + { + title: 'Súhlas s TODO', + required: true, + constValue: true, + }, + { + checkboxLabel: 'Súhlasím s TODO', + variant: 'boxed', + }, + ), + customComponentsField( + { + type: 'additionalLinks', + props: { + links: [ + { + title: 'TODO', + href: 'https://olo.sk', + }, + ], + }, + }, + {}, + ), + ]), ]) diff --git a/forms-shared/src/schemas/olo/energetickeZhodnotenieOdpaduVZevo.ts b/forms-shared/src/schemas/olo/energetickeZhodnotenieOdpaduVZevo.ts new file mode 100644 index 000000000..3fd71b98b --- /dev/null +++ b/forms-shared/src/schemas/olo/energetickeZhodnotenieOdpaduVZevo.ts @@ -0,0 +1,8 @@ +import { schema } from '../../generator/functions' +import { getZevoSchema, ZevoType } from './shared/zevoShared' + +export default schema( + { title: 'Energetické zhodnotenie odpadu v ZEVO' }, + {}, + getZevoSchema(ZevoType.EnergetickeZhodnotenieOdpaduVZevo), +) diff --git a/forms-shared/src/schemas/olo/koloTaxi.ts b/forms-shared/src/schemas/olo/koloTaxi.ts index e5bddebfd..24bd32395 100644 --- a/forms-shared/src/schemas/olo/koloTaxi.ts +++ b/forms-shared/src/schemas/olo/koloTaxi.ts @@ -1,3 +1,152 @@ -import { schema, step } from '../../generator/functions' +import { + checkbox, + conditionalFields, + fileUpload, + input, + object, + radioGroup, + schema, + step, + textArea, +} from '../../generator/functions' +import { createCondition, createStringOptions } from '../../generator/helpers' +import { sharedAddressField, sharedPhoneNumberField } from '../shared/fields' -export default schema({ title: 'KOLO Taxi' }, {}, [step('ziadatel', { title: 'Žiadateľ' }, [])]) +export default schema({ title: 'KOLO Taxi' }, {}, [ + step('ziadatel', { title: 'Žiadateľ' }, [ + radioGroup( + 'ziadatelTyp', + { + type: 'string', + title: 'Žiadateľ', + required: true, + options: createStringOptions(['Fyzická osoba', 'Právnická osoba']), + }, + { variant: 'boxed', orientations: 'column' }, + ), + conditionalFields(createCondition([[['ziadatelTyp'], { const: 'Fyzická osoba' }]]), [ + object( + 'menoPriezvisko', + { required: true }, + { + columns: true, + columnsRatio: '1/1', + }, + [ + input('meno', { title: 'Meno', required: true, type: 'text' }, {}), + input('priezvisko', { title: 'Priezvisko', required: true, type: 'text' }, {}), + ], + ), + sharedAddressField('adresaTrvalehoPobytu', 'Adresa trvalého pobytu', true), + sharedPhoneNumberField('telefonPravnickaOsoba', true), + input('emailFyzickaOsoba', { title: 'Email', required: false, type: 'email' }, {}), + ]), + conditionalFields(createCondition([[['ziadatelTyp'], { const: 'Právnická osoba' }]]), [ + input('nazovOrganizacie', { type: 'text', title: 'Názov organizácie', required: true }, {}), + sharedAddressField('adresaSidlaOrganizacie', 'Adresa sídla organizácie', true), + input('ico', { type: 'text', title: 'IČO', required: true }, {}), + input('dic', { type: 'text', title: 'DIČ', required: true }, {}), + checkbox( + 'platcaDph', + { title: 'Som platca DPH?', required: true }, + { checkboxLabel: 'Som platca DPH', variant: 'boxed' }, + ), + conditionalFields(createCondition([[['platcaDph'], { const: true }]]), [ + input('icDph', { type: 'text', title: 'IČ DPH', required: true }, {}), + ]), + input('konatel', { type: 'text', title: 'Konateľ (meno, priezvisko)', required: true }, {}), + input( + 'zastupeny', + { + type: 'text', + title: 'Zastúpený - na základe splnomocnenia (meno, priezvisko)', + required: true, + }, + {}, + ), + input( + 'menoKontaktnejOsoby', + { type: 'text', title: 'Meno kontaktnej osoby', required: true }, + {}, + ), + sharedPhoneNumberField('telefonPravnickaOsoba', true), + input('emailPravnickaOsoba', { title: 'Email', required: true, type: 'email' }, {}), + object('fakturacia', { required: true }, { objectDisplay: 'boxed', title: 'Fakturácia' }, [ + input('iban', { type: 'ba-iban', title: 'IBAN', required: true }, {}), + checkbox( + 'elektronickaFaktura', + { + title: 'Súhlasím so zaslaním elektronickej faktúry', + required: true, + }, + { + helptextHeader: + 'V prípade vyjadrenia nesúhlasu bude zákazníkovi za zasielanie faktúry poštou účtovaný poplatok 10 € bez DPH.', + checkboxLabel: 'Súhlasím so zaslaním elektronickej faktúry', + variant: 'boxed', + }, + ), + conditionalFields(createCondition([[['elektronickaFaktura'], { const: true }]]), [ + input( + 'emailPreFaktury', + { + type: 'text', + title: 'E-mail pre zasielanie elektronických faktúr', + required: true, + }, + {}, + ), + ]), + ]), + ]), + ]), + step('sluzba', { title: 'Služba' }, [ + input( + 'miestoDodania', + { + type: 'text', + title: 'Miesto dodania / výkonu služby', + required: true, + }, + { + placeholder: 'Zadajte presnú adresu', + helptextHeader: 'Presná adresa', + }, + ), + textArea( + 'popisDarovanychVeci', + { + title: 'Popis darovaných vecí', + required: true, + }, + { + placeholder: 'Popíšte darované veci', + helptextHeader: 'Okrem čalúneného nábytku a elektrospotrebičov', + }, + ), + fileUpload( + 'fotoDarovanychVeci', + { + title: 'Foto darovaných vecí', + required: true, + multiple: true, + }, + { + type: 'dragAndDrop', + helptextHeader: 'Nahrajte fotografiu vecí, ktoré chcete darovať (jpg, jpeg, png, max. 5MB)', + }, + ), + checkbox( + 'suhlasSDarom', + { + title: 'Vyjadrenie súhlasu s platbou', + required: true, + constValue: true, + }, + { + checkboxLabel: 'Súhlasím s platbou za službu KOLO Taxi', + variant: 'boxed', + }, + ), + ]), +]) diff --git a/forms-shared/src/schemas/olo/mimoriadnyOdvozALikvidaciaOdpadu.ts b/forms-shared/src/schemas/olo/mimoriadnyOdvozALikvidaciaOdpadu.ts deleted file mode 100644 index eeb2442e2..000000000 --- a/forms-shared/src/schemas/olo/mimoriadnyOdvozALikvidaciaOdpadu.ts +++ /dev/null @@ -1,296 +0,0 @@ -import { - checkbox, - conditionalFields, - datePicker, - input, - object, - radioGroup, - schema, - select, - step, - textArea, -} from '../../generator/functions' -import { sharedAddressField, sharedPhoneNumberField } from '../shared/fields' -import { createCondition, createStringOptions } from '../../generator/helpers' - -const infoOOdpadeFields = [ - input( - 'miestoDodania', - { type: 'text', title: 'Miesto dodania / výkonu služby', required: true }, - { helptext: 'Presná adresa' }, - ), - radioGroup( - 'druhOdpadu', - { - title: 'Vyberte druh odpadu', - required: true, - type: 'string', - options: createStringOptions([ - 'Zmesový komunálny odpad', - 'Jedlé oleje a tuky', - 'Kuchynský biologicky rozložiteľný odpad', - 'Biologicky rozložiteľný odpad', - 'Papier', - 'Plasty/kovové obaly a VKM', - 'Sklo', - ]).map((option) => ({ - ...option, - description: - option.title === 'Jedlé oleje a tuky' - ? 'Dostupné iba pre právnické osoby a správcovské spoločnosti' - : undefined, - })), - }, - { variant: 'boxed', orientations: 'column' }, - ), - conditionalFields(createCondition([[['druhOdpadu'], { const: 'Zmesový komunálny odpad' }]]), [ - select( - 'objemNadobyZmesovyKomunalnyOdpad', - { - title: 'Vyberte objem nádoby', - required: true, - options: createStringOptions( - [ - '120 l zberná nádoba', - '240 l zberná nádoba', - '1100 l zberná nádoba', - '3000 l polopodzemný kontajner', - '5000 l polopodzemný kontajner', - ], - false, - ), - }, - {}, - ), - ]), - conditionalFields( - createCondition([[['druhOdpadu'], { const: 'Kuchynský biologicky rozložiteľný odpad' }]]), - [ - select( - 'objemNadobyKuchynskyBiologicky', - { - title: 'Vyberte objem nádoby', - required: true, - options: createStringOptions( - ['23 l zberná nádoba', '120 l zberná nádoba', '240 l zberná nádoba'], - false, - ), - }, - { helptext: '23 l zberná nádoba sa poskytuje iba pre odvoz z rodinných domov.' }, - ), - ], - ), - conditionalFields( - createCondition([ - [['ziadatelTyp'], { enum: ['PravnickaOsoba', 'SpravcovskaSpolocnost'] }], - [ - ['druhOdpadu'], - { const: 'Jedlé oleje a tuky (iba pre právnické osoby a správcovské spoločnosti)' }, - ], - ]), - [ - select( - 'objemNadobyJedleOlejeATuky', - { - title: 'Vyberte objem nádoby', - required: true, - options: createStringOptions(['120 l zberná nádoba'], false), - }, - { - helptext: - 'Služba sa poskytuje iba pre bytové doby a firmy. Pre rodinné domy sú určené nádoby na zberné hniezda (prelink).', - }, - ), - ], - ), - conditionalFields(createCondition([[['druhOdpadu'], { const: 'Papier' }]]), [ - select( - 'objemNadobyPapier', - { - title: 'Vyberte objem nádoby', - required: true, - options: createStringOptions( - [ - '120 l zberná nádoba', - '240 l zberná nádoba', - '1100 l zberná nádoba', - '3000 l polopodzemný kontajner', - '5000 l polopodzemný kontajner', - ], - false, - ), - }, - {}, - ), - ]), - conditionalFields(createCondition([[['druhOdpadu'], { const: 'Plasty/kovové obaly a VKM' }]]), [ - select( - 'objemNadobyPlastyKovoveObaly', - { - title: 'Vyberte objem nádoby', - required: true, - options: createStringOptions( - [ - '120 l zberná nádoba', - '240 l zberná nádoba', - '1100 l zberná nádoba', - '3000 l polopodzemný kontajner', - '5000 l polopodzemný kontajner', - ], - false, - ), - }, - {}, - ), - ]), - conditionalFields(createCondition([[['druhOdpadu'], { const: 'Sklo' }]]), [ - select( - 'objemNadobySklo', - { - title: 'Vyberte objem nádoby', - required: true, - options: createStringOptions( - [ - '120 l zberná nádoba', - '240 l zberná nádoba', - '1100 l zberná nádoba', - '1800 l zvon na sklo', - '3000 l polopodzemný kontajner', - '5000 l polopodzemný kontajner', - ], - false, - ), - }, - {}, - ), - ]), -] - -export default schema( - { - title: 'Mimoriadny odvoz a likvidácia odpadu', - }, - {}, - [ - step('ziadatel', { title: 'Žiadateľ' }, [ - radioGroup( - 'ziadatelTyp', - { - type: 'string', - title: 'Žiadateľ', - required: true, - options: createStringOptions(['Obyvateľ', 'Právnická osoba', 'Správcovská spoločnosť']), - }, - { variant: 'boxed', orientations: 'column' }, - ), - conditionalFields(createCondition([[['ziadatelTyp'], { const: 'Obyvateľ' }]]), [ - object( - 'menoPriezvisko', - { required: true }, - { - columns: true, - columnsRatio: '1/1', - }, - [ - input('meno', { title: 'Meno', required: true, type: 'text' }, {}), - input('priezvisko', { title: 'Priezvisko', required: true, type: 'text' }, {}), - ], - ), - sharedAddressField('adresaObyvatel', 'Adresa trvalého pobytu', true), - ]), - conditionalFields( - createCondition([ - [['ziadatelTyp'], { enum: ['Právnická osoba', 'Správcovská spoločnosť'] }], - ]), - [ - input('nazov', { type: 'text', title: 'Názov organizácie', required: true }, {}), - sharedAddressField('adresaPravnickaOsoba', 'Adresa sídla', true), - input('ico', { type: 'text', title: 'IČO', required: true }, {}), - input('dic', { type: 'text', title: 'DIČ', required: true }, {}), - checkbox( - 'platcaDph', - { title: 'Som platca DPH?', required: true }, - { checkboxLabel: 'Som platca DPH?', variant: 'boxed' }, - ), - conditionalFields(createCondition([[['platcaDph'], { const: true }]]), [ - input('icDph', { type: 'text', title: 'IČ DPH', required: true }, {}), - ]), - ], - ), - conditionalFields(createCondition([[['ziadatelTyp'], { const: 'Právnická osoba' }]]), [ - input('konatel', { type: 'text', title: 'Konateľ (meno, priezvisko)', required: true }, {}), - input( - 'zastupeny', - { type: 'text', title: 'Zastúpený - na základe splnomocnenia (meno, priezvisko)' }, - {}, - ), - ]), - conditionalFields( - createCondition([ - [['ziadatelTyp'], { enum: ['Právnická osoba', 'Správcovská spoločnosť'] }], - ]), - [ - input( - 'kontaktnaOsoba', - { type: 'text', title: 'Meno kontaktnej osoby', required: true }, - {}, - ), - ], - ), - sharedPhoneNumberField('telefon', true), - input('email', { title: 'E-mail', required: true, type: 'email' }, {}), - conditionalFields( - createCondition([ - [['ziadatelTyp'], { enum: ['Právnická osoba', 'Správcovská spoločnosť'] }], - ]), - [ - object( - 'fakturacia', - { required: true }, - { objectDisplay: 'boxed', title: 'Fakturácia' }, - [ - input('iban', { type: 'ba-iban', title: 'IBAN', required: true }, {}), - checkbox( - 'elektronickaFaktura', - { - title: 'Zasielanie faktúry elektronicky', - required: true, - }, - { - helptextHeader: - 'V prípade vyjadrenia nesúhlasu bude zákazníkovi za zasielanie faktúry poštou účtovaný poplatok 10 € bez DPH. Osobitné ustanovenia o zasielaní faktúry v elektronickej podobe v zmysle bodu 5.9 VOP.', - checkboxLabel: 'Súhlasím so zaslaním elektronickej fakúry', - variant: 'boxed', - }, - ), - conditionalFields(createCondition([[['elektronickaFaktura'], { const: true }]]), [ - input( - 'emailPreFaktury', - { - type: 'text', - title: 'E-mail pre zasielanie elektronických faktúr', - required: true, - }, - {}, - ), - ]), - ], - ), - ], - ), - ]), - step('sluzba', { title: 'Služba' }, [ - object('infoOOdpade', { required: true }, {}, infoOOdpadeFields), - datePicker( - 'datumVykonania', - { title: 'Preferovaný dátum vykonania služby', required: true }, - { size: 'medium' }, - ), - textArea( - 'doplnujuceInformacie', - { title: 'Doplňujúce informácie' }, - { helptext: 'Špecifikujte individuálne požiadavky.' }, - ), - ]), - ], -) diff --git a/forms-shared/src/schemas/olo/mimoriadnyOdvozAZhodnotenieOdpadu.ts b/forms-shared/src/schemas/olo/mimoriadnyOdvozAZhodnotenieOdpadu.ts new file mode 100644 index 000000000..b6ede42af --- /dev/null +++ b/forms-shared/src/schemas/olo/mimoriadnyOdvozAZhodnotenieOdpadu.ts @@ -0,0 +1,354 @@ +import { + arrayField, + checkbox, + conditionalFields, + customComponentsField, + datePicker, + input, + markdownText, + object, + radioGroup, + schema, + select, + step, + textArea, +} from '../../generator/functions' +import { sharedAddressField, sharedPhoneNumberField } from '../shared/fields' +import { createCondition, createStringOptions } from '../../generator/helpers' + +export default schema( + { + title: 'Mimoriadny odvoz a zhodnotenie odpadu', + }, + {}, + [ + step('ziadatel', { title: 'Žiadateľ' }, [ + radioGroup( + 'ziadatelTyp', + { + type: 'string', + title: 'Žiadateľ', + required: true, + options: createStringOptions(['Obyvateľ', 'Právnická osoba', 'Správcovská spoločnosť']), + }, + { variant: 'boxed', orientations: 'column' }, + ), + conditionalFields(createCondition([[['ziadatelTyp'], { const: 'Obyvateľ' }]]), [ + object( + 'menoPriezvisko', + { required: true }, + { + columns: true, + columnsRatio: '1/1', + }, + [ + input('meno', { title: 'Meno', required: true, type: 'text' }, {}), + input('priezvisko', { title: 'Priezvisko', required: true, type: 'text' }, {}), + ], + ), + sharedAddressField('adresaObyvatel', 'Adresa trvalého pobytu', true), + ]), + conditionalFields( + createCondition([ + [['ziadatelTyp'], { enum: ['Právnická osoba', 'Správcovská spoločnosť'] }], + ]), + [ + input('nazov', { type: 'text', title: 'Názov organizácie', required: true }, {}), + sharedAddressField('adresaPravnickaOsoba', 'Adresa sídla', true), + input('ico', { type: 'text', title: 'IČO', required: true }, {}), + input('dic', { type: 'text', title: 'DIČ', required: true }, {}), + checkbox( + 'platcaDph', + { title: 'Som platca DPH?', required: true }, + { checkboxLabel: 'Som platca DPH?', variant: 'boxed' }, + ), + conditionalFields(createCondition([[['platcaDph'], { const: true }]]), [ + input('icDph', { type: 'text', title: 'IČ DPH', required: true }, {}), + ]), + ], + ), + conditionalFields(createCondition([[['ziadatelTyp'], { const: 'Právnická osoba' }]]), [ + input('konatel', { type: 'text', title: 'Konateľ (meno, priezvisko)', required: true }, {}), + input( + 'zastupeny', + { type: 'text', title: 'Zastúpený - na základe splnomocnenia (meno, priezvisko)' }, + {}, + ), + ]), + conditionalFields( + createCondition([ + [['ziadatelTyp'], { enum: ['Právnická osoba', 'Správcovská spoločnosť'] }], + ]), + [ + input( + 'kontaktnaOsoba', + { type: 'text', title: 'Meno kontaktnej osoby', required: true }, + {}, + ), + ], + ), + sharedPhoneNumberField('telefon', true), + conditionalFields( + createCondition([ + [['ziadatelTyp'], { enum: ['Právnická osoba', 'Správcovská spoločnosť'] }], + ]), + [input('email', { title: 'E-mail', required: true, type: 'email' }, {})], + ), + conditionalFields(createCondition([[['ziadatelTyp'], { enum: ['Obyvateľ'] }]]), [ + input('emailObyvatel', { title: 'E-mail', type: 'email' }, {}), + ]), + conditionalFields( + createCondition([ + [['ziadatelTyp'], { enum: ['Právnická osoba', 'Správcovská spoločnosť'] }], + ]), + [ + object( + 'fakturacia', + { required: true }, + { objectDisplay: 'boxed', title: 'Fakturácia' }, + [ + input('iban', { type: 'ba-iban', title: 'IBAN', required: true }, {}), + checkbox( + 'elektronickaFaktura', + { + title: 'Zasielanie faktúry elektronicky', + required: true, + }, + { + helptextHeader: + 'V prípade vyjadrenia nesúhlasu bude zákazníkovi za zasielanie faktúry poštou účtovaný poplatok 10 € bez DPH. Osobitné ustanovenia o zasielaní faktúry v elektronickej podobe v zmysle bodu 5.9 VOP.', + checkboxLabel: 'Súhlasím so zaslaním elektronickej fakúry', + variant: 'boxed', + }, + ), + conditionalFields(createCondition([[['elektronickaFaktura'], { const: true }]]), [ + input( + 'emailPreFaktury', + { + type: 'email', + title: 'E-mail pre zasielanie elektronických faktúr', + required: true, + }, + {}, + ), + ]), + ], + ), + ], + ), + ]), + step('sluzba', { title: 'Služba' }, [ + arrayField( + 'infoOOdpade', + { title: 'Info o odpade', required: true }, + { + variant: 'topLevel', + addButtonLabel: 'Pridať ďalší odpad', + itemTitle: 'Odpad č. {index}', + }, + [ + input( + 'miestoDodania', + { type: 'text', title: 'Miesto dodania / výkonu služby', required: true }, + { helptextHeader: 'Presná adresa' }, + ), + select( + 'druhOdpadu', + { + title: 'Vyberte druh odpadu', + required: true, + options: createStringOptions([ + 'Zmesový komunálny odpad', + 'Kuchynský biologicky rozložiteľný odpad', + 'Biologicky rozložiteľný odpad', + 'Jedlé oleje a tuky', + 'Papier', + 'Plasty/kovové obaly a nápojové kartóny', + 'Sklo', + ]), + }, + {}, + ), + conditionalFields( + createCondition([[['druhOdpadu'], { const: 'Zmesový komunálny odpad' }]]), + [ + select( + 'objemNadobyZmesovyKomunalnyOdpad', + { + title: 'Vyberte objem nádoby', + required: true, + options: createStringOptions([ + '120 l zberná nádoba', + '240 l zberná nádoba', + '1100 l zberná nádoba', + '3000 l polopodzemný kontajner', + '5000 l polopodzemný kontajner', + ]), + }, + {}, + ), + ], + ), + conditionalFields( + createCondition([ + [['druhOdpadu'], { const: 'Kuchynský biologicky rozložiteľný odpad' }], + ]), + [ + select( + 'objemNadobyKuchynskyBiologicky', + { + title: 'Vyberte objem nádoby', + required: true, + options: createStringOptions([ + '23 l zberná nádoba', + '120 l zberná nádoba', + '240 l zberná nádoba', + ]), + }, + { + helptextHeader: + '23 l zberná nádoba sa poskytuje iba pre odvoz z rodinných domov.', + }, + ), + ], + ), + conditionalFields(createCondition([[['druhOdpadu'], { const: 'Jedlé oleje a tuky' }]]), [ + select( + 'objemNadobyJedleOlejeATuky', + { + title: 'Vyberte objem nádoby', + required: true, + options: createStringOptions(['120 l zberná nádoba']), + }, + { + helptextHeader: markdownText( + 'Služba sa poskytuje iba pre bytové doby a firmy. Pre rodinné domy sú určené nádoby na [zberné hniezda](https://www.olo.sk/zberne-hniezda/).', + ), + }, + ), + ]), + conditionalFields(createCondition([[['druhOdpadu'], { const: 'Papier' }]]), [ + select( + 'objemNadobyPapier', + { + title: 'Vyberte objem nádoby', + required: true, + options: createStringOptions([ + '120 l zberná nádoba', + '240 l zberná nádoba', + '1100 l zberná nádoba', + '3000 l polopodzemný kontajner', + '5000 l polopodzemný kontajner', + ]), + }, + {}, + ), + ]), + conditionalFields( + createCondition([ + [['druhOdpadu'], { const: 'Plasty/kovové obaly a nápojové kartóny' }], + ]), + [ + select( + 'objemNadobyPlastyKovoveObaly', + { + title: 'Vyberte objem nádoby', + required: true, + options: createStringOptions([ + '120 l zberná nádoba', + '240 l zberná nádoba', + '1100 l zberná nádoba', + '3000 l polopodzemný kontajner', + '5000 l polopodzemný kontajner', + ]), + }, + {}, + ), + ], + ), + conditionalFields(createCondition([[['druhOdpadu'], { const: 'Sklo' }]]), [ + select( + 'objemNadobySklo', + { + title: 'Vyberte objem nádoby', + required: true, + options: createStringOptions([ + '120 l zberná nádoba', + '240 l zberná nádoba', + '1100 l zberná nádoba', + '1800 l zvon na sklo', + '3000 l polopodzemný kontajner', + '5000 l polopodzemný kontajner', + ]), + }, + {}, + ), + ]), + conditionalFields( + createCondition([[['druhOdpadu'], { const: 'Biologicky rozložiteľný odpad' }]]), + [ + select( + 'objemNadobyBiologickyRozlozitelny', + { + title: 'Vyberte objem nádoby', + required: true, + options: createStringOptions(['120 l zberná nádoba', '240 l zberná nádoba']), + }, + {}, + ), + ], + ), + ], + ), + datePicker( + 'preferovanyDatum', + { + title: 'Preferovaný dátum vykonania služby', + required: true, + }, + { + helptextHeader: + 'Vami zvolený dátum má iba informačný charakter. Objednávku je potrebné podať minimálne 2 pracovné dni pred zvoleným termínom. V prípade, ak vami zvolený termín nebude voľný, budeme vás kontaktovať.', + }, + ), + textArea( + 'doplnujuceInfo', + { + title: 'Doplňujúce info', + required: false, + }, + { + helptextHeader: 'Špecifikujte individuálne požiadavky.', + }, + ), + ]), + step('suhlasy', { title: 'Súhlasy' }, [ + checkbox( + 'suhlas', + { + title: 'Súhlas s TODO', + required: true, + constValue: true, + }, + { + checkboxLabel: 'Súhlasím s TODO', + variant: 'boxed', + }, + ), + customComponentsField( + { + type: 'additionalLinks', + props: { + links: [ + { + title: 'TODO', + href: 'https://olo.sk', + }, + ], + }, + }, + {}, + ), + ]), + ], +) diff --git a/forms-shared/src/schemas/olo/odvozObjemnehoOdpaduValnikom.ts b/forms-shared/src/schemas/olo/odvozObjemnehoOdpaduValnikom.ts index e61fd85e9..9c758e4b4 100644 --- a/forms-shared/src/schemas/olo/odvozObjemnehoOdpaduValnikom.ts +++ b/forms-shared/src/schemas/olo/odvozObjemnehoOdpaduValnikom.ts @@ -1,5 +1,135 @@ -import { schema, step } from '../../generator/functions' +import { + checkbox, + conditionalFields, + customComponentsField, + datePicker, + input, + object, + radioGroup, + schema, + step, +} from '../../generator/functions' +import { createCondition, createStringOptions } from '../../generator/helpers' +import { sharedAddressField, sharedPhoneNumberField } from '../shared/fields' export default schema({ title: 'Odvoz objemného odpadu valníkom' }, {}, [ - step('ziadatel', { title: 'Žiadateľ' }, []), + step('ziadatel', { title: 'Žiadateľ' }, [ + radioGroup( + 'ziadatelTyp', + { + type: 'string', + title: 'Žiadateľ', + required: true, + options: createStringOptions(['Právnická osoba', 'Správcovská spoločnosť']), + }, + { variant: 'boxed', orientations: 'column' }, + ), + input('nazov', { type: 'text', title: 'Názov organizácie', required: true }, {}), + sharedAddressField('adresaSidla', 'Adresa sídla organizácie', true), + input('ico', { type: 'text', title: 'IČO', required: true }, {}), + input('dic', { type: 'text', title: 'DIČ', required: true }, {}), + checkbox( + 'platcaDph', + { title: 'Som platca DPH?', required: true }, + { checkboxLabel: 'Som platca DPH', variant: 'boxed' }, + ), + conditionalFields(createCondition([[['platcaDph'], { const: true }]]), [ + input('icDph', { type: 'text', title: 'IČ DPH', required: true }, {}), + ]), + conditionalFields(createCondition([[['ziadatelTyp'], { const: 'Právnická osoba' }]]), [ + input( + 'konatel', + { type: 'text', title: 'Konateľ (meno, priezvisko)', required: true }, + { helptext: 'Uveďte meno a priezvisko konateľa' }, + ), + input( + 'zastupeny', + { + type: 'text', + title: 'Zastúpený - na základe splnomocnenia (meno, priezvisko)', + required: true, + }, + { helptext: 'Uveďte meno a priezvisko osoby zastupujúcej na základe splnomocnenia' }, + ), + ]), + input('kontaktnaOsoba', { type: 'text', title: 'Meno kontaktnej osoby', required: true }, {}), + sharedPhoneNumberField('telefon', true), + input('email', { title: 'E-mail', required: true, type: 'email' }, {}), + object('fakturacia', { required: true }, { objectDisplay: 'boxed', title: 'Fakturácia' }, [ + input('iban', { type: 'ba-iban', title: 'IBAN', required: true }, {}), + checkbox( + 'elektronickaFaktura', + { + title: 'Súhlasím so zaslaním elektronickej faktúry', + required: true, + }, + { + helptextHeader: + 'V prípade vyjadrenia nesúhlasu bude zákazníkovi za zasielanie faktúry poštou účtovaný poplatok 10 € bez DPH. Osobitné ustanovenia o zasielaní faktúry v elektronickej podobe v zmysle bodu 5.9 VOP.', + checkboxLabel: 'Súhlasím so zaslaním elektronickej faktúry', + variant: 'boxed', + }, + ), + conditionalFields(createCondition([[['elektronickaFaktura'], { const: true }]]), [ + input( + 'emailPreFaktury', + { + type: 'email', + title: 'E-mail pre zasielanie elektronických faktúr', + required: true, + }, + {}, + ), + ]), + ]), + ]), + step('sluzba', { title: 'Služba' }, [ + input( + 'miestoDodania', + { + type: 'text', + title: 'Miesto dodania / výkonu služby', + required: true, + }, + { + helptextHeader: 'Presná adresa', + }, + ), + datePicker( + 'preferovanyDatumPristavenia', + { + title: 'Preferovaný dátum pristavenia vozidla', + required: true, + }, + { size: 'medium' }, + ), + ]), + step('suhlasy', { title: 'Súhlasy' }, [ + checkbox( + 'suhlas', + { + title: 'Súhlas s TODO', + required: true, + constValue: true, + }, + { + checkboxLabel: 'Súhlasím s TODO', + variant: 'boxed', + }, + ), + customComponentsField( + { + type: 'additionalLinks', + props: { + links: [ + { + title: 'TODO', + href: 'https://olo.sk', + }, + ], + }, + }, + {}, + ), + ]), ]) diff --git a/forms-shared/src/schemas/olo/odvozOdpaduVelkokapacitnymAleboLisovacimKontajnerom.ts b/forms-shared/src/schemas/olo/odvozOdpaduVelkokapacitnymAleboLisovacimKontajnerom.ts index 48cc64f6e..1e83387bb 100644 --- a/forms-shared/src/schemas/olo/odvozOdpaduVelkokapacitnymAleboLisovacimKontajnerom.ts +++ b/forms-shared/src/schemas/olo/odvozOdpaduVelkokapacitnymAleboLisovacimKontajnerom.ts @@ -1,5 +1,226 @@ -import { schema, step } from '../../generator/functions' +import { + checkbox, + conditionalFields, + customComponentsField, + datePicker, + input, + object, + radioGroup, + schema, + select, + step, + textArea, + timePicker, +} from '../../generator/functions' +import { createCondition, createStringOptions } from '../../generator/helpers' +import { sharedAddressField, sharedPhoneNumberField } from '../shared/fields' export default schema({ title: 'Odvoz odpadu veľkokapacitným alebo lisovacím kontajnerom' }, {}, [ - step('ziadatel', { title: 'Žiadateľ' }, []), + step('ziadatel', { title: 'Žiadateľ' }, [ + radioGroup( + 'ziadatelTyp', + { + type: 'string', + title: 'Žiadateľ', + required: true, + options: createStringOptions(['Obyvateľ', 'Právnická osoba', 'Správcovská spoločnosť']), + }, + { variant: 'boxed', orientations: 'column' }, + ), + conditionalFields(createCondition([[['ziadatelTyp'], { const: 'Obyvateľ' }]]), [ + object( + 'menoPriezvisko', + { required: true }, + { + columns: true, + columnsRatio: '1/1', + }, + [ + input('meno', { title: 'Meno', required: true, type: 'text' }, {}), + input('priezvisko', { title: 'Priezvisko', required: true, type: 'text' }, {}), + ], + ), + sharedAddressField('adresaObyvatel', 'Adresa trvalého pobytu', true), + ]), + conditionalFields( + createCondition([[['ziadatelTyp'], { enum: ['Právnická osoba', 'Správcovská spoločnosť'] }]]), + [ + input('nazov', { type: 'text', title: 'Názov organizácie', required: true }, {}), + sharedAddressField('adresaPravnickaOsoba', 'Adresa sídla', true), + input('ico', { type: 'text', title: 'IČO', required: true }, {}), + input('dic', { type: 'text', title: 'DIČ', required: true }, {}), + checkbox( + 'platcaDph', + { title: 'Som platca DPH?', required: true }, + { checkboxLabel: 'Som platca DPH?', variant: 'boxed' }, + ), + conditionalFields(createCondition([[['platcaDph'], { const: true }]]), [ + input('icDph', { type: 'text', title: 'IČ DPH', required: true }, {}), + ]), + ], + ), + conditionalFields(createCondition([[['ziadatelTyp'], { const: 'Právnická osoba' }]]), [ + input('konatel', { type: 'text', title: 'Konateľ (meno, priezvisko)', required: true }, {}), + input( + 'zastupeny', + { type: 'text', title: 'Zastúpený - na základe splnomocnenia (meno, priezvisko)' }, + {}, + ), + ]), + conditionalFields( + createCondition([[['ziadatelTyp'], { enum: ['Právnická osoba', 'Správcovská spoločnosť'] }]]), + [ + input( + 'kontaktnaOsoba', + { type: 'text', title: 'Meno kontaktnej osoby', required: true }, + {}, + ), + ], + ), + sharedPhoneNumberField('telefon', true), + conditionalFields( + createCondition([[['ziadatelTyp'], { enum: ['Právnická osoba', 'Správcovská spoločnosť'] }]]), + [input('email', { title: 'E-mail', required: true, type: 'email' }, {})], + ), + conditionalFields(createCondition([[['ziadatelTyp'], { enum: ['Obyvateľ'] }]]), [ + input('emailObyvatel', { title: 'E-mail', type: 'email' }, {}), + ]), + object('fakturacia', { required: true }, { objectDisplay: 'boxed', title: 'Fakturácia' }, [ + input('iban', { type: 'ba-iban', title: 'IBAN', required: true }, {}), + checkbox( + 'elektronickaFaktura', + { + title: 'Zasielanie faktúry elektronicky', + required: true, + }, + { + helptextHeader: + 'V prípade vyjadrenia nesúhlasu bude zákazníkovi za zasielanie faktúry poštou účtovaný poplatok 10 € bez DPH. Osobitné ustanovenia o zasielaní faktúry v elektronickej podobe v zmysle bodu 5.9 VOP.', + checkboxLabel: 'Súhlasím so zaslaním elektronickej fakúry', + variant: 'boxed', + }, + ), + conditionalFields(createCondition([[['elektronickaFaktura'], { const: true }]]), [ + input( + 'emailPreFaktury', + { + type: 'email', + title: 'E-mail pre zasielanie elektronických faktúr', + required: true, + }, + {}, + ), + ]), + ]), + ]), + step('sluzba', { title: 'Služba' }, [ + input( + 'miestoDodania', + { type: 'text', title: 'Miesto dodania / výkonu služby', required: true }, + { helptextHeader: 'Presná adresa' }, + ), + select( + 'druhOdpadu', + { + title: 'Druh odpadu', + required: true, + options: createStringOptions(['Objemný', 'Záhradný', 'Iné'], false), + }, + {}, + ), + conditionalFields(createCondition([[['druhOdpadu'], { const: 'Iné' }]]), [ + textArea( + 'druhOdpaduIne', + { + title: 'Druh odpadu iné', + required: true, + }, + { + placeholder: 'Špecifikujte, prosím, druh odpadu', + }, + ), + ]), + select( + 'objemKontajnera', + { + title: 'Objem kontajnera', + required: true, + options: [ + { value: '2.5m3_3t', title: 'objem: 2,5 m³ / nosnosť: do 3 t' }, + { value: '7m3_3t', title: 'objem: 7 m³ / nosnosť: do 3 t' }, + { value: '7m3_8t', title: 'objem: 7 m³ / nosnosť: do 8 t' }, + { value: '11m3_8t', title: 'objem: 11 m³ / nosnosť: do 8 t' }, + { value: '16m3_8t', title: 'objem: 16 m³ / nosnosť: do 8 t' }, + { value: '27m3_8t', title: 'objem: 27 m³ / nosnosť: do 8 t' }, + ], + }, + {}, + ), + datePicker( + 'preferovanyDatumPristavenia', + { + title: 'Preferovaný dátum pristavenia kontajnera', + required: true, + }, + { size: 'medium' }, + ), + timePicker( + 'casPristavenia', + { + title: 'Čas pristavenia kontajnera', + required: true, + }, + { + helptextHeader: 'V pracovné dni od 7.00 - 12.30', + size: 'medium', + }, + ), + datePicker( + 'datumOdvozu', + { + title: 'Presný dátum odvozu kontajnera', + required: true, + }, + { size: 'medium' }, + ), + timePicker( + 'casOdvozu', + { + title: 'Čas odvozu kontajnera', + required: true, + }, + { + helptextHeader: 'V pracovné dni od 7.00 - 12.30', + size: 'medium', + }, + ), + ]), + step('suhlasy', { title: 'Súhlasy' }, [ + checkbox( + 'suhlas', + { + title: 'Súhlas s TODO', + required: true, + constValue: true, + }, + { + checkboxLabel: 'Súhlasím s TODO', + variant: 'boxed', + }, + ), + customComponentsField( + { + type: 'additionalLinks', + props: { + links: [ + { + title: 'TODO', + href: 'https://olo.sk', + }, + ], + }, + }, + {}, + ), + ]), ]) diff --git a/forms-shared/src/schemas/olo/oloTaxi.ts b/forms-shared/src/schemas/olo/oloTaxi.ts index 016698ab5..c3efbea0e 100644 --- a/forms-shared/src/schemas/olo/oloTaxi.ts +++ b/forms-shared/src/schemas/olo/oloTaxi.ts @@ -1,3 +1,137 @@ -import { schema, step } from '../../generator/functions' +import { + checkbox, + customComponentsField, + datePicker, + input, + object, + radioGroup, + schema, + step, + textArea, + timePicker, +} from '../../generator/functions' +import { sharedAddressField, sharedPhoneNumberField } from '../shared/fields' +import { createStringOptions } from '../../generator/helpers' -export default schema({ title: 'OLO Taxi' }, {}, [step('ziadatel', { title: 'Žiadateľ' }, [])]) +export default schema( + { + title: 'OLO Taxi', + }, + {}, + [ + step('ziadatel', { title: 'Žiadateľ' }, [ + radioGroup( + 'ziadatelTyp', + { + type: 'string', + title: 'Žiadateľ', + required: true, + options: createStringOptions(['Fyzická osoba']), + }, + { variant: 'boxed', orientations: 'column' }, + ), + object( + 'menoPriezvisko', + { required: true }, + { + columns: true, + columnsRatio: '1/1', + }, + [ + input('meno', { title: 'Meno', required: true, type: 'text' }, {}), + input('priezvisko', { title: 'Priezvisko', required: true, type: 'text' }, {}), + ], + ), + sharedAddressField('adresaTrvalehoPobytu', 'Adresa trvalého pobytu', true), + sharedPhoneNumberField('telefon', true), + input('email', { title: 'E-mail', required: false, type: 'email' }, {}), + ]), + + step('sluzba', { title: 'Služba' }, [ + input( + 'miestoDodania', + { + type: 'text', + title: 'Miesto dodania / výkonu služby', + required: true, + }, + { + placeholder: 'Zadajte presnú adresu', + helptextHeader: 'Presná adresa', + }, + ), + datePicker( + 'preferovanyDatumOdvozu', + { + title: 'Preferovaný dátum odvozu', + required: true, + }, + { + helptextHeader: + 'Vami zvolený dátum má iba informačný charakter. Objednávku je potrebné podať minimálne 2 pracovné dni pred zvoleným termínom. V prípade, ak vami zvolený termín nebude voľný, budeme vás kontaktovať.', + }, + ), + timePicker( + 'preferovanyCasOdvozu', + { + title: 'Preferovaný čas odvozu', + required: true, + }, + { + helptextHeader: + '7:00 (Pon - Sob); 9:00 (Pon - Sob); 11:00 (Pon - Sob); 13:00 (Pon - Pia)', + }, + ), + textArea( + 'mnozstvoADruhOdpadu', + { + title: 'Množstvo a druh odpadu', + required: true, + }, + { + placeholder: 'Špecifikujte druh odpadu, uveďte počet kusov alebo množstvo v m³.', + }, + ), + checkbox( + 'suhlasSDarom', + { + title: 'Vyjadrenie súhlasu s platbou', + required: true, + constValue: true, + }, + { + checkboxLabel: 'Súhlasím s platbou za službu OLO Taxi', + variant: 'boxed', + }, + ), + ]), + step('suhlasy', { title: 'Súhlasy' }, [ + checkbox( + 'suhlas', + { + title: 'Súhlas s TODO', + required: true, + constValue: true, + }, + { + checkboxLabel: 'Súhlasím s TODO', + variant: 'boxed', + }, + ), + customComponentsField( + { + type: 'additionalLinks', + props: { + links: [ + { + title: 'TODO', + href: 'https://olo.sk', + }, + ], + }, + }, + {}, + ), + ]), + ], +) diff --git a/forms-shared/src/schemas/olo/podnetyAPochvalyObcanov.ts b/forms-shared/src/schemas/olo/podnetyAPochvalyObcanov.ts index a53dc017b..8264337a0 100644 --- a/forms-shared/src/schemas/olo/podnetyAPochvalyObcanov.ts +++ b/forms-shared/src/schemas/olo/podnetyAPochvalyObcanov.ts @@ -1,5 +1,121 @@ -import { schema, step } from '../../generator/functions' +import { + checkbox, + checkboxGroup, + conditionalFields, + datePicker, + fileUpload, + input, + schema, + step, + textArea, +} from '../../generator/functions' +import { createCondition, createStringOptions } from '../../generator/helpers' +import { sharedPhoneNumberField } from '../shared/fields' export default schema({ title: 'Podnety a pochvaly občanov' }, {}, [ - step('ziadatel', { title: 'Žiadateľ' }, []), + step('podnet', { title: 'Podať podnet' }, [ + checkboxGroup( + 'kategoriaPodnetu', + { + title: 'Kategória podnetu', + required: true, + options: createStringOptions( + ['Nevykonaný odvoz', 'Pracovníci OLO', 'Poškodená nádoba', 'Iné', 'Pochvala'], + false, + ), + }, + { + variant: 'boxed', + helptextHeader: 'Vyberte aspoň jednu možnosť', + }, + ), + conditionalFields( + createCondition([[['kategoriaPodnetu'], { contains: { const: 'Nevykonaný odvoz' } }]]), + [ + datePicker( + 'terminNevykonaniaOdvozuOdpadu', + { + title: 'Presný termín nevykonania odvozu odpadu', + required: true, + }, + {}, + ), + checkboxGroup( + 'druhOdpadu', + { + title: 'Vyberte druh odpadu', + required: true, + options: createStringOptions( + [ + 'Zmesový komunálny odpad', + 'Kuchynský biologicky rozložiteľný odpad', + 'Biologicky rozložiteľný odpad', + 'Jedlé oleje a tuky', + 'Papier', + 'Plasty/Kovové obaly a nápojové kartóny', + 'Sklo', + ], + false, + ), + }, + { + variant: 'boxed', + helptextHeader: 'Vyberte aspoň jednu možnosť', + }, + ), + input( + 'adresaMiestaOdvozu', + { + type: 'text', + title: 'Presná adresa miesta odvozu', + required: true, + }, + {}, + ), + ], + ), + conditionalFields( + createCondition([[['kategoriaPodnetu'], { contains: { const: 'Pracovníci OLO' } }]]), + [ + datePicker( + 'datumCasUdalosti', + { + title: 'Dátum a orientačný čas vzniknutej udalosti', + required: true, + }, + {}, + ), + ], + ), + input('meno', { type: 'text', title: 'Meno', required: true }, {}), + input('priezvisko', { type: 'text', title: 'Priezvisko', required: true }, {}), + sharedPhoneNumberField('telefon', true), + input('email', { title: 'Email', required: true, type: 'email' }, {}), + textArea('sprava', { title: 'Správa', required: true }, {}), + fileUpload( + 'prilohy', + { + title: 'Prílohy', + required: false, + multiple: true, + }, + { + type: 'dragAndDrop', + }, + ), + checkbox( + 'suhlasSOchranouOsobnychUdajov', + { + title: 'Súhlas s ochranou osobných údajov', + required: true, + constValue: true, + }, + { + checkboxLabel: + 'Prečítal/a som si a oboznámil/a som sa s informáciami o spracúvaní osobných údajov.', + variant: 'boxed', + helptextHeader: 'Vaše osobné údaje používame na vybavenie vašej požiadavky.', + }, + ), + ]), ]) diff --git a/forms-shared/src/schemas/olo/shared/zevoShared.ts b/forms-shared/src/schemas/olo/shared/zevoShared.ts new file mode 100644 index 000000000..cdf4d0205 --- /dev/null +++ b/forms-shared/src/schemas/olo/shared/zevoShared.ts @@ -0,0 +1,947 @@ +import { + checkbox, + conditionalFields, + customComponentsField, + datePicker, + fileUpload, + input, + number, + object, + radioGroup, + select, + selectMultiple, + step, +} from '../../../generator/functions' +import { createCondition, createStringOptions } from '../../../generator/helpers' +import { sharedAddressField, sharedPhoneNumberField } from '../../shared/fields' + +export enum ZevoType { + EnergetickeZhodnotenieOdpaduVZevo, + UzatvorenieZmluvyONakladaniSOdpadom, +} + +export const getZevoSchema = (type: ZevoType) => [ + step('ziadatel', { title: 'Žiadateľ' }, [ + radioGroup( + 'ziadatelTyp', + { + type: 'string', + title: 'Žiadateľ', + required: true, + options: createStringOptions([ + 'Fyzická osoba', + 'Právnická osoba', + 'Právnická osoba s povolením na vstup do ZEVO', + ]), + }, + { variant: 'boxed', orientations: 'column' }, + ), + conditionalFields(createCondition([[['ziadatelTyp'], { const: 'Fyzická osoba' }]]), [ + object( + 'menoPriezvisko', + { required: true }, + { + columns: true, + columnsRatio: '1/1', + }, + [ + input('meno', { title: 'Meno', required: true, type: 'text' }, {}), + input('priezvisko', { title: 'Priezvisko', required: true, type: 'text' }, {}), + ], + ), + sharedAddressField('adresaObyvatel', 'Adresa trvalého pobytu', true), + input('cisloOp', { type: 'text', title: 'Číslo OP', required: true }, {}), + ]), + conditionalFields( + createCondition([ + [ + ['ziadatelTyp'], + { enum: ['Právnická osoba', 'Právnická osoba s povolením na vstup do ZEVO'] }, + ], + ]), + [ + input('nazov', { type: 'text', title: 'Názov organizácie', required: true }, {}), + input('ico', { type: 'text', title: 'IČO', required: true }, {}), + ], + ), + conditionalFields( + createCondition([ + [['ziadatelTyp'], { const: 'Právnická osoba s povolením na vstup do ZEVO' }], + ]), + [ + input( + 'cisloPovoleniaNaVstup', + { type: 'text', title: 'Číslo povolenia na vstup', required: true }, + { + helptextHeader: 'Vo formáte: 123/45 alebo 1234/45/2026 (číslo Objednávky alebo Zmluvy)', + }, + ), + ], + ), + conditionalFields(createCondition([[['ziadatelTyp'], { const: 'Právnická osoba' }]]), [ + sharedAddressField('adresaPravnickaOsoba', 'Adresa sídla', true), + input('dic', { type: 'text', title: 'DIČ', required: true }, {}), + checkbox( + 'platcaDph', + { title: 'Som platca DPH?', required: true }, + { checkboxLabel: 'Som platca DPH', variant: 'boxed' }, + ), + conditionalFields(createCondition([[['platcaDph'], { const: true }]]), [ + input('icDph', { type: 'text', title: 'IČ DPH', required: true }, {}), + ]), + input('konatel', { type: 'text', title: 'Konateľ (meno, priezvisko)', required: true }, {}), + input( + 'zastupeny', + { + type: 'text', + title: 'Zastúpený - na základe splnomocnenia (meno, priezvisko)', + required: true, + }, + {}, + ), + input('kontaktnaOsoba', { type: 'text', title: 'Meno kontaktnej osoby', required: true }, {}), + ]), + sharedPhoneNumberField('telefon', true), + input('email', { title: 'E-mail', required: true, type: 'email' }, {}), + type === ZevoType.EnergetickeZhodnotenieOdpaduVZevo + ? radioGroup( + 'vyberSluzby', + { + type: 'string', + title: 'Výber služby', + required: true, + options: createStringOptions([ + 'Mechanická vykládka a zhodnotenie odpadu podľa integrovaného povolenia', + 'Ručná vykládka a zhodnotenie odpadu podľa integrovaného povolenia', + 'Podrvenie a zhodnotenie odpadu vysypaním do zásobníka', + ]), + }, + { variant: 'boxed', orientations: 'column' }, + ) + : null, + type === ZevoType.EnergetickeZhodnotenieOdpaduVZevo + ? datePicker( + 'preferovanyDatumDovozu', + { + title: 'Preferovaný dátum dovozu odpadu', + required: true, + }, + {}, + ) + : null, + type === ZevoType.EnergetickeZhodnotenieOdpaduVZevo + ? conditionalFields( + createCondition([ + [ + ['vyberSluzby'], + { + enum: [ + 'Ručná vykládka a zhodnotenie odpadu podľa integrovaného povolenia', + 'Podrvenie a zhodnotenie odpadu vysypaním do zásobníka', + ], + }, + ], + ]), + [ + select( + 'preferovanyCasDovozu', + { + title: 'Preferovaný čas dovozu odpadu', + required: true, + options: createStringOptions(['09:00', '10:00', '11:00', '12:00'], false), + }, + {}, + ), + ], + ) + : null, + radioGroup( + 'sposobPlatby', + { + type: 'string', + title: 'Spôsob platby', + required: true, + options: createStringOptions(['Platba kartou', 'Platba na faktúru']), + }, + { variant: 'boxed', orientations: 'column' }, + ), + conditionalFields(createCondition([[['sposobPlatby'], { const: 'Platba na faktúru' }]]), [ + checkbox( + 'elektronickaFaktura', + { + title: 'Súhlasím so zaslaním elektronickej faktúry', + required: true, + }, + { + helptextHeader: + 'V prípade vyjadrenia nesúhlasu bude zákazníkovi za zasielanie faktúry poštou účtovaný poplatok 10 € bez DPH. Osobitné ustanovenia o zasielaní faktúry v elektronickej podobe v zmysle bodu 5.9 VOP.', + checkboxLabel: 'Súhlasím so zaslaním elektronickej faktúry', + variant: 'boxed', + }, + ), + conditionalFields(createCondition([[['elektronickaFaktura'], { const: true }]]), [ + input( + 'emailPreFaktury', + { + type: 'email', + title: 'E-mail pre zasielanie elektronických faktúr', + required: true, + }, + {}, + ), + ]), + ]), + conditionalFields( + createCondition([ + [ + ['ziadatelTyp'], + { enum: ['Právnická osoba', 'Právnická osoba s povolením na vstup do ZEVO'] }, + ], + ]), + [input('iban', { type: 'ba-iban', title: 'IBAN', required: true }, {})], + ), + ]), + step('povodcaOdpadu', { title: 'Identifikačné údaje pôvodcu odpadu' }, [ + radioGroup( + 'stePovodcaOdpadu', + { + type: 'boolean', + title: 'Ste zároveň aj pôvodca odpadu?', + required: true, + options: [ + { value: true, title: 'Áno', isDefault: true }, + { value: false, title: 'Nie' }, + ], + }, + { + variant: 'boxed', + orientations: 'row', + helptextHeader: + 'Definícia zo Zákona č. 79/2015 Z. z. o odpadoch v znení neskorších predpisov', + }, + ), + conditionalFields(createCondition([[['stePovodcaOdpadu'], { const: false }]]), [ + radioGroup( + 'typPovodcuOdpadu', + { + type: 'string', + title: 'Typ pôvodcu odpadu', + required: true, + options: createStringOptions(['Fyzická osoba', 'Právnická osoba']), + }, + { variant: 'boxed', orientations: 'column' }, + ), + conditionalFields(createCondition([[['typPovodcuOdpadu'], { const: 'Právnická osoba' }]]), [ + input('nazovOrganizacie', { type: 'text', title: 'Názov organizácie', required: true }, {}), + sharedAddressField('sidloOrganizacie', 'Sídlo organizácie', true), + input('ico', { type: 'text', title: 'IČO', required: true }, {}), + ]), + conditionalFields(createCondition([[['typPovodcuOdpadu'], { const: 'Fyzická osoba' }]]), [ + input('menoAPriezvisko', { type: 'text', title: 'Meno a priezvisko', required: true }, {}), + sharedAddressField('adresa', 'Adresa', true), + input('cisloOp', { type: 'text', title: 'Číslo OP', required: true }, {}), + ]), + input( + 'emailPovodcuOdpadu', + { title: 'E-mail pôvodcu odpadu', required: true, type: 'email' }, + {}, + ), + ]), + ]), + step('drzitelOdpadu', { title: 'Identifikačné údaje držiteľa odpadu' }, [ + radioGroup( + 'steDrzitelOdpadu', + { + type: 'boolean', + title: 'Ste zároveň aj držiteľ odpadu?', + required: true, + options: [ + { value: true, title: 'Áno', isDefault: true }, + { value: false, title: 'Nie' }, + ], + }, + { + variant: 'boxed', + orientations: 'row', + helptextHeader: + 'Definícia zo Zákona č. 79/2015 Z. z. o odpadoch v znení neskorších predpisov', + }, + ), + conditionalFields(createCondition([[['steDrzitelOdpadu'], { const: false }]]), [ + radioGroup( + 'typDrzitelaOdpadu', + { + type: 'string', + title: 'Typ držiteľa odpadu', + required: true, + options: createStringOptions(['Fyzická osoba', 'Právnická osoba']), + }, + { variant: 'boxed', orientations: 'column' }, + ), + conditionalFields(createCondition([[['typDrzitelaOdpadu'], { const: 'Právnická osoba' }]]), [ + input('nazovOrganizacie', { type: 'text', title: 'Názov organizácie', required: true }, {}), + sharedAddressField('sidloOrganizacie', 'Sídlo organizácie', true), + input('ico', { type: 'text', title: 'IČO', required: true }, {}), + ]), + conditionalFields(createCondition([[['typDrzitelaOdpadu'], { const: 'Fyzická osoba' }]]), [ + input('menoAPriezvisko', { type: 'text', title: 'Meno a priezvisko', required: true }, {}), + sharedAddressField('adresa', 'Adresa', true), + input('cisloOp', { type: 'text', title: 'Číslo OP', required: true }, {}), + ]), + input( + 'emailDrzitelaOdpadu', + { title: 'E-mail držiteľa odpadu', required: true, type: 'email' }, + {}, + ), + ]), + ]), + step('vyberDruhuOdpadu', { title: 'Výber druhu odpadu na základe katalogizácie' }, [ + selectMultiple( + 'separovaneZlozky', + { + title: '20 01 Separovane zbierané zložky komunálnych odpadov (okrem 15 01)', + options: [ + { value: '20_01_01', title: '20 01 01 Papier a lepenka' }, + { + value: '20_01_08', + title: '20 01 08 Biologicky rozložiteľný kuchynský a reštauračný odpad', + }, + { value: '20_01_10', title: '20 01 10 Šatstvo' }, + { value: '20_01_11', title: '20 01 11 Textílie' }, + { value: '20_01_25', title: '20 01 25 Jedlé oleje a tuky' }, + { + value: '20_01_28', + title: + '20 01 28 Farby, tlačiarenské farby, lepidlá a živice iné ako uvedené v 20 01 27', + }, + { value: '20_01_30', title: '20 01 30 Detergenty iné ako uvedené v 20 01 29' }, + { value: '20_01_32', title: '20 01 32 Liečivá iné ako uvedené v 20 01 31' }, + { value: '20_01_38', title: '20 01 38 Drevo iné ako uvedené v 20 01 37' }, + { value: '20_01_39', title: '20 01 39 Plasty' }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZoZahrad', + { + title: '20 02 Odpady zo záhrad a z parkov (vrátane odpadu z cintorínov)', + options: [ + { + value: '20_02_01', + title: '20 02 01 Biologicky rozložiteľný odpad s max. obsahom biologickej zložky 40%', + }, + { value: '20_02_03', title: '20 02 03 Iné biologicky nerozložiteľné odpady' }, + ], + }, + {}, + ), + selectMultiple( + 'ineKomunalneOdpady', + { + title: '20 03 Iné komunálne odpady', + options: [ + { value: '20_03_01', title: '20 03 01 Zmesový komunálny odpad' }, + { value: '20_03_02', title: '20 03 02 Odpad z trhovísk' }, + { value: '20_03_03', title: '20 03 03 Odpad z čistenia ulíc' }, + { value: '20_03_07', title: '20 03 07 Objemný odpad' }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZAerobnejUpravy', + { + title: '19 05 Odpady z aeróbnej úpravy tuhých odpadov', + options: [ + { + value: '19_05_01', + title: '19 05 01 Nekompostované zložky komunálnych odpadov a podobných odpadov', + }, + { + value: '19_05_02', + title: '19 05 02 Nekompostované zložky živočíšneho a rastlinného odpadu', + }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZCistiarni', + { + title: '19 08 Odpady z čistiarní odpadových vôd inak nešpecifikované', + options: [ + { value: '19_08_01', title: '19 08 01 Zhrabky z hrablíc' }, + { value: '19_08_02', title: '19 08 02 Odpad z lapačov piesku' }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZUpravyVody', + { + title: '19 09 Odpady z úpravy pitnej vody alebo vody na priemyselné použitie', + options: [ + { value: '19_09_01', title: '19 09 01 Tuhé odpady z primárnych filtrov a hrablíc' }, + { value: '19_09_04', title: '19 09 04 Použité aktívne uhlie' }, + { value: '19_09_05', title: '19 09 05 Nasýtené alebo použité iontomeničové živice' }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZMechanickehoSpracovania', + { + title: + '19 12 Odpady z mechanického spracovania odpadu (napr. triedenia, drvenia, lisovania, hutnenia a peletizovania) inak nešpecifikované', + options: [ + { value: '19_12_01', title: '19 12 01 Papier a lepenka' }, + { value: '19_12_04', title: '19 12 04 Plasty a guma' }, + { value: '19_12_07', title: '19 12 07 Drevo iné ako uvedené v 19 12 06' }, + { value: '19_12_08', title: '19 12 08 Textílie' }, + { value: '19_12_10', title: '19 12 10 Horľavý odpad (palivo z odpadov)' }, + { + value: '19_12_12', + title: + '19 12 12 Iné odpady vrátane zmiešaných materiálov z mechanického spracovania odpadu iné ako uvedené v 19 12 11', + }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZPorodnictva', + { + title: + '18 01 Odpady z pôrodníckej starostlivosti, diagnostiky, liečby alebo zdravotnej prevencie', + options: [ + { + value: '18_01_04', + title: + '18 01 04 Odpady, ktorých zber a zneškodňovanie nepodliehajú osobitným požiadavkám z hľadiska prevencie nákazy (napr. obväzy, sadrové odtlačky a obväzy, posteľná bielizeň, jednorazové odevy, plienky)', + }, + { value: '18_01_09', title: '18 01 09 Liečivá iné ako uvedené v 18 01 08' }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZVeterinarnehoVyskumu', + { + title: + '18 02 Odpady z veterinárneho výskumu, diagnostiky, liečby a preventívnej starostlivosti', + options: [ + { + value: '18_02_03', + title: + '18 02 03 Odpady, ktorých zber a zneškodňovanie nepodliehajú osobitným požiadavkám z hľadiska prevencie nákazy', + }, + { value: '18_02_08', title: '18 02 08 Liečivá iné ako uvedené v 18 02 07' }, + ], + }, + {}, + ), + selectMultiple( + 'drevoSkloPlasty', + { + title: '17 02 Drevo, sklo a plasty', + options: [ + { value: '17_02_01', title: '17 02 01 Drevo' }, + { value: '17_02_03', title: '17 02 03 Plasty' }, + ], + }, + {}, + ), + selectMultiple( + 'izolacneMaterialy', + { + title: '17 06 Izolačné materiály a stavebné materiály obsahujúce azbest', + options: [ + { + value: '17_06_04', + title: '17 06 04 Izolačné materiály iné ako uvedené v 17 06 01 a 17 06 03', + }, + ], + }, + {}, + ), + selectMultiple( + 'ineOdpadyZoStavieb', + { + title: '17 09 Iné odpady zo stavieb a demolácií', + options: [ + { + value: '17_09_04', + title: + '17 09 04 Zmiešané odpady zo stavieb a demolácií iné ako uvedené v 17 09 01, 17 09 02, a 17 09 03', + }, + ], + }, + {}, + ), + selectMultiple( + 'stareVozidla', + { + title: + '16 01 Staré vozidlá z rozličných dopravných prostriedkov (vrátane strojov neurčených na cestnú premávku) a odpady z demontáže starých vozidiel a údržby vozidiel (okrem 13, 14, 16 06 a 16 08)', + options: [ + { value: '16_01_19', title: '16 01 19 Plasty' }, + { value: '16_01_22', title: '16 01 22 Časti inak nešpecifikované' }, + ], + }, + {}, + ), + selectMultiple( + 'vyrobneZarze', + { + title: '16 03 Výrobné šarže a výrobky nevyhovujúcej kvality', + options: [ + { value: '16_03_04', title: '16 03 04 Anorganické výrobky iné ako uvedené v 16 03 03' }, + { value: '16_03_06', title: '16 03 06 Organické výrobky iné ako uvedené v 16 03 05' }, + ], + }, + {}, + ), + selectMultiple( + 'obaly', + { + title: '15 01 Obaly (vrátane odpadových obalov zo separovaného zberu komunálnych odpadov)', + options: [ + { value: '15_01_01', title: '15 01 01 Obaly z papiera a lepenky' }, + { value: '15_01_02', title: '15 01 02 Obaly z plastov' }, + { value: '15_01_03', title: '15 01 03 Obaly z dreva' }, + { value: '15_01_04', title: '15 01 04 Obaly z kovu' }, + { value: '15_01_05', title: '15 01 05 Kompozitné obaly' }, + { value: '15_01_06', title: '15 01 06 Zmiešané obaly' }, + { value: '15_01_09', title: '15 01 09 Obaly z textilu' }, + ], + }, + {}, + ), + selectMultiple( + 'absorbenty', + { + title: '15 02 Absorbenty, filtračné materiály, handry na čistenie a ochranné odevy', + options: [ + { + value: '15_02_03', + title: + '15 02 03 Absorbenty, filtračné materiály, handry na čistenie a ochranné odevy iné ako uvedené v 15 02 02', + }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZTvarovania', + { + title: + '12 01 Odpady z tvarovania a fyzikálnej a mechanickej úpravy povrchov kovov a plastov', + options: [ + { value: '12_01_05', title: '12 01 05 Hobliny a triesky z plastov' }, + { + value: '12_01_21', + title: '12 01 21 Použité brúsne nástroje a brúsne materiály iné ako uvedené v 12 01 20', + }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZElektrarni', + { + title: '10 01 Odpady z elektrární a iných spaľovacích zariadení (okrem 19)', + options: [{ value: '10_01_26', title: '10 01 26 Odpady z úpravy chladiacej vody' }], + }, + {}, + ), + selectMultiple( + 'odpadyZVyrobySkla', + { + title: '10 11 Odpady z výroby skla a sklených výrobkov', + options: [ + { value: '10_11_03', title: '10 11 03 Odpadové vláknité materiály na báze skla' }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZFotografickehoPriemyslu', + { + title: '09 01 Odpady z fotografického priemyslu', + options: [ + { + value: '09_01_07', + title: + '09 01 07 Fotografický film a papiere obsahujúce striebro alebo zlúčeniny striebra', + }, + { + value: '09_01_08', + title: + '09 01 08 Fotografický film a papiere neobsahujúce striebro alebo zlúčeniny striebra', + }, + { value: '09_01_10', title: '09 01 10 Jednorázové kamery bez batérií' }, + { + value: '09_01_12', + title: '09 01 12 Jednorázové kamery s batériami iné ako uvedené 09 01 11', + }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZFariebALakov', + { + title: '08 01 Odpady z VSDP a odstraňovania farieb a lakov', + options: [ + { + value: '08_01_12', + title: '08 01 12 Odpadové farby a laky iné ako uvedené v 08 01 11', + }, + { + value: '08_01_18', + title: '08 01 18 Odpady z odstraňovania farby alebo laku iné ako uvedené v 08 01 17', + }, + { + value: '08_01_20', + title: + '08 01 20 Vodné suspenzie obsahujúce farby alebo laky iné ako uvedené v 08 01 19', + }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZInychNaterovychHmot', + { + title: '08 02 Odpady z VSDP iných náterových hmôt (vrátane keramických materiálov)', + options: [{ value: '08_02_01', title: '08 02 01 Odpadové náterové prášky' }], + }, + {}, + ), + selectMultiple( + 'odpadyZTlaciarenskychFarieb', + { + title: '08 03 Odpady z VSDP tlačiarenských farieb', + options: [ + { + value: '08_03_13', + title: '08 03 13 Odpadová tlačiarenská farba iná ako uvedená v 08 03 12', + }, + { + value: '08_03_18', + title: '08 03 18 Odpadový toner do tlačiarne iný ako uvedený v 08 03 17', + }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZLepidiel', + { + title: + '08 04 Odpady z VSDP lepidiel a tesniacich materiálov (vrátane vodotesniacich výrobkov)', + options: [ + { + value: '08_04_10', + title: '08 04 10 Odpadové lepidlá a tesniace materiály iné ako uvedené v 08 04 09', + }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZPlastov', + { + title: '07 02 Odpady z VSDP plastov, syntetického kaučuku a syntetických vlákien', + options: [ + { value: '07_02_13', title: '07 02 13 Odpadový plast' }, + { value: '07_02_15', title: '07 02 15 Odpadové prísady iné ako uvedené v 07 02 14' }, + { + value: '07_02_17', + title: '07 02 17 Odpady obsahujúce silikóny iné ako uvedené v 07 02 16', + }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZFarmaceutickychVyrobkov', + { + title: '07 05 Odpady z VSDP farmaceutických výrobkov', + options: [{ value: '07_05_14', title: '07 05 14 Tuhé odpady iné ako uvedené v 07 05 13' }], + }, + {}, + ), + selectMultiple( + 'odpadyZTukovAMydiel', + { + title: + '07 06 Odpady z VSDP tukov, mazív, mydiel, detergentov, dezinfekčných a kozmetických prostriedkov', + options: [ + { + value: '07_06_12', + title: + '07 06 12 Kaly zo spracovania odpadu v mieste jeho vzniku iné ako uvedené v 07 06 11', + }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZCistychChemikalii', + { + title: + '07 07 Odpady z VSDP čistých chemikálií a chemických výrobkov inak nešpecifikovaných', + options: [ + { + value: '07_07_12', + title: + '07 07 12 Kaly zo spracovania odpadu v mieste jeho vzniku iné ako uvedené v 07 07 11', + }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZPyrolyznehoSpracovania', + { + title: '05 06 Odpady z pyrolýzneho spracovania uhlia', + options: [{ value: '05_06_04', title: '05 06 04 Odpad z chladiacich kolón' }], + }, + {}, + ), + selectMultiple( + 'odpadyZKoziarskehoPriemyslu', + { + title: '04 01 Odpady z kožiarskeho a kožušníckeho priemyslu', + options: [{ value: '04_01_09', title: '04 01 09 Odpady z vypracúvania a apretácie' }], + }, + {}, + ), + selectMultiple( + 'odpadyZTextilnehoPriemyslu', + { + title: '04 02 Odpady z textilného priemyslu', + options: [ + { + value: '04_02_09', + title: + '04 02 09 Odpad z kompozitných materiálov (impregnovaný textil, elastomer, plastomér)', + }, + { + value: '04_02_10', + title: '04 02 10 Organické látky prírodného pôvodu (napr. tuky, vosky)', + }, + { value: '04_02_15', title: '04 02 15 Odpad z apretácie iný ako uvedený v 04 02 14' }, + { value: '04_02_17', title: '04 02 17 Farbivá a pigmenty iné ako uvedené v 04 02 16' }, + { value: '04_02_21', title: '04 02 21 Odpady z nespracovaných textilných vlákien' }, + { value: '04_02_22', title: '04 02 22 Odpady zo spracovaných textilných vlákien' }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZoSpracovaniaDreva', + { + title: '03 01 Odpady zo spracovania dreva a z výroby reziva a nábytku', + options: [ + { value: '03_01_01', title: '03 01 01 Odpadová kôra a korok' }, + { + value: '03_01_05', + title: + '03 01 05 Piliny, hobliny, odrezky, odpadové rezivo alebo drevotrieskové/drevovláknité dosky, dyhy iné ako uvedené v 03 01 04', + }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZVyrobyPapiera', + { + title: '03 03 Odpady z výroby a spracovania celulózy, papiera a lepenky', + options: [ + { value: '03_03_01', title: '03 03 01 Odpadová kôra a drevo' }, + { + value: '03_03_07', + title: '03 03 07 Mechanicky oddelené výmety z recyklácie papiera a lepenky', + }, + { + value: '03_03_08', + title: '03 03 08 Odpady z triedenia papiera a lepenky určených na recykláciu', + }, + { + value: '03_03_10', + title: '03 03 10 Výmety z vlákien, plnív a náterov z mechanickej separácie', + }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZPolnohospodarstva', + { + title: '02 01 Odpady z poľnohospodárstva, záhradníctva, lesníctva, poľovníctva a rybárstva', + options: [ + { value: '02_01_02', title: '02 01 02 Odpadové živočíšne tkanivá' }, + { value: '02_01_03', title: '02 01 03 Odpadové rastlinné tkanivá' }, + { value: '02_01_04', title: '02 01 04 Odpadové plasty (okrem obalov)' }, + { + value: '02_01_06', + title: + '02 01 06 Zvierací trus, moč a hnoj (vrátane znečistenej slamy), kvapalné odpady, oddelene zhromažďované a spracúvané mimo miesta ich vzniku', + }, + { value: '02_01_07', title: '02 01 07 Odpady z lesného hospodárstva' }, + { value: '02_01_09', title: '02 01 09 Agrochemické odpady iné ako uvedené v 02 01 08' }, + { value: '02_01_10', title: '02 01 10 Odpadové kovy' }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZPripravyMasa', + { + title: + '02 02 Odpady z prípravy a spracovania mäsa, rýb a ostatných potravín živočíšneho pôvodu', + options: [ + { + value: '02_02_03', + title: '02 02 03 Materiál nevhodný na spotrebu alebo spracovanie', + }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZoSpracovaniaOvocia', + { + title: + '02 03 Odpady zo spracovania ovocia, zeleniny, obilnín, jedlých olejov, kávy, čaju a tabaku', + options: [ + { value: '02_03_02', title: '02 03 02 Odpady z konzervačných činidiel' }, + { value: '02_03_04', title: '02 03 04 Látky nevhodné na spotrebu alebo spracovanie' }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZPriemysluMliecnychVyrobkov', + { + title: '02 05 Odpady z priemyslu mliečnych výrobkov', + options: [ + { value: '02_05_01', title: '02 05 01 Látky nevhodné na spotrebu alebo spracovanie' }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZPekarenskehoACukrovinkarskeho', + { + title: '02 06 Odpady z pekárenského a cukrovinkárskeho priemyslu', + options: [ + { + value: '02_06_01', + title: '02 06 01 Materiály nevhodné na spotrebu alebo spracovanie', + }, + { value: '02_06_02', title: '02 06 02 Odpady z konzervačných činidiel' }, + ], + }, + {}, + ), + selectMultiple( + 'odpadyZVyrobyNapojov', + { + title: '02 07 Odpady z výroby alkoholických a nealkoholických nápojov', + options: [ + { + value: '02_07_04', + title: '02 07 04 Materiály nevhodné na spotrebu alebo spracovanie', + }, + ], + }, + {}, + ), + ]), + type === ZevoType.EnergetickeZhodnotenieOdpaduVZevo + ? step('informacieODovoze', { title: 'Informácie o dovoze odpadu do ZEVO' }, [ + input( + 'spzVozidla', + { + type: 'text', + title: 'ŠPZ vozidla', + required: true, + }, + { + helptextHeader: 'ŠPZ vozidla, ktoré odpad dovezie do ZEVO', + }, + ), + number( + 'predpokladaneMnozstvo', + { + title: 'Predpokladané množstvo dovezeného odpadu (kg)', + required: true, + minimum: 0, + }, + { + placeholder: 'Zadajte množstvo v kg', + }, + ), + fileUpload( + 'fotoOdpadu', + { + title: 'Foto odpadu', + required: false, + multiple: true, + }, + { + type: 'dragAndDrop', + helptextHeader: + 'Nahrajte fotografie odpadu, ktorý priveziete na zhodnotenie (povolené typy súborov jpg, gif, png, max. veľkosť 1 súboru 10 MB, maximálne 5 súborov.)', + }, + ), + ]) + : null, + type === ZevoType.UzatvorenieZmluvyONakladaniSOdpadom + ? step('informacieOMnozstve', { title: 'Informácie o indikovanom množstve' }, [ + number( + 'predpokladaneMnozstvo', + { + title: 'Prosím uveďte predpokladané množstvo odpadu za obdobie / rok (kg)', + required: true, + minimum: 0, + }, + { + placeholder: 'Zadajte množstvo v kg', + }, + ), + ]) + : null, + step('suhlasy', { title: 'Súhlasy' }, [ + checkbox( + 'suhlas', + { + title: 'Súhlas s TODO', + required: true, + constValue: true, + }, + { + checkboxLabel: 'Súhlasím s TODO', + variant: 'boxed', + }, + ), + customComponentsField( + { + type: 'additionalLinks', + props: { + links: [ + { + title: 'TODO', + href: 'https://olo.sk', + }, + ], + }, + }, + {}, + ), + ]), +] diff --git a/forms-shared/src/schemas/olo/triedenyZberPapieraPlastovASklaPrePravnickeOsoby.ts b/forms-shared/src/schemas/olo/triedenyZberPapieraPlastovASklaPrePravnickeOsoby.ts index 6d665b9f8..6cdc4d15c 100644 --- a/forms-shared/src/schemas/olo/triedenyZberPapieraPlastovASklaPrePravnickeOsoby.ts +++ b/forms-shared/src/schemas/olo/triedenyZberPapieraPlastovASklaPrePravnickeOsoby.ts @@ -1,5 +1,408 @@ -import { schema, step } from '../../generator/functions' +import { + arrayField, + checkbox, + conditionalFields, + customComponentsField, + datePicker, + input, + number, + radioGroup, + schema, + select, + step, +} from '../../generator/functions' +import { createCondition, createStringOptions } from '../../generator/helpers' +import { sharedAddressField, sharedPhoneNumberField } from '../shared/fields' -export default schema({ title: 'Triedený zber papiera, plastov a skla pre právnické osoby' }, {}, [ - step('ziadatel', { title: 'Žiadateľ' }, []), -]) +export default schema( + { + title: 'Triedený zber papiera, plastov a skla pre právnické osoby', + }, + {}, + [ + step('ziadatel', { title: 'Žiadateľ' }, [ + radioGroup( + 'typOdberatela', + { + type: 'string', + title: 'Typ odberateľa', + required: true, + options: createStringOptions([ + 'Nový', + 'Existujúci', + 'Zmena poplatkovej povinnosti pre existujúceho zákazníka', + 'Zmena odberateľa', + ]), + }, + { + variant: 'boxed', + orientations: 'column', + helptextHeader: + 'Nový (nemám uzavretú zmluvu), Existujúci (mám uzavretú zmluvu), Zmena poplatkovej povinnosti (spoplatnenie služby), Zmena odberateľa (napr. preberám prevádzku alebo správu nehnuteľnosti)', + }, + ), + input('nazovOrganizacie', { type: 'text', title: 'Názov organizácie', required: true }, {}), + sharedAddressField('adresaSidla', 'Adresa sídla organizácie', true), + conditionalFields(createCondition([[['typOdberatela'], { const: 'Existujúci' }]]), [ + input('cisloZmluvy', { type: 'text', title: 'Číslo zmluvy', required: true }, {}), + ]), + conditionalFields( + createCondition([ + [ + ['typOdberatela'], + { + enum: [ + 'Nový', + 'Existujúci', + 'Zmena poplatkovej povinnosti pre existujúceho zákazníka', + ], + }, + ], + ]), + [input('ico', { type: 'text', title: 'IČO', required: true }, {})], + ), + conditionalFields(createCondition([[['typOdberatela'], { const: 'Zmena odberateľa' }]]), [ + input( + 'icoPovodnehOdberatela', + { type: 'text', title: 'IČO pôvodného odberateľa', required: true }, + {}, + ), + input('noveIco', { type: 'text', title: 'Nové IČO', required: true }, {}), + datePicker( + 'datumZmeny', + { title: 'Dátum zmeny', required: true }, + { helptextHeader: 'Uveďte dátum predpokladanej zmeny odberateľa' }, + ), + ]), + input('dic', { type: 'text', title: 'DIČ', required: true }, {}), + checkbox( + 'platcaDph', + { title: 'Som platca DPH?', required: true }, + { checkboxLabel: 'Som platca DPH', variant: 'boxed' }, + ), + conditionalFields(createCondition([[['platcaDph'], { const: true }]]), [ + input('icDph', { type: 'text', title: 'IČ DPH', required: true }, {}), + ]), + input( + 'konatel', + { type: 'text', title: 'Konateľ (meno, priezvisko)', required: true }, + { helptextHeader: 'Uveďte meno a priezvisko konateľa' }, + ), + input( + 'zastupeny', + { + type: 'text', + title: 'Zastúpený - na základe splnomocnenia (meno, priezvisko)', + required: true, + }, + { helptextHeader: 'Uveďte meno a priezvisko zástupcu na základe splnomocnenia' }, + ), + input( + 'menoKontaktnejOsoby', + { type: 'text', title: 'Meno kontaktnej osoby', required: true }, + {}, + ), + sharedPhoneNumberField('telefon', true), + input('email', { title: 'Email', required: true, type: 'email' }, {}), + input('iban', { type: 'ba-iban', title: 'IBAN', required: true }, {}), + checkbox( + 'elektronickaFaktura', + { + title: 'Súhlasím so zaslaním elektronickej faktúry', + required: true, + }, + { + helptextHeader: + 'V prípade vyjadrenia nesúhlasu bude zákazníkovi za zasielanie faktúry poštou účtovaný poplatok 10 € bez DPH. Osobitné ustanovenia o zasielaní faktúry v elektronickej podobe v zmysle bodu 5.9 VOP.', + checkboxLabel: 'Súhlasím so zaslaním elektronickej faktúry', + variant: 'boxed', + }, + ), + conditionalFields(createCondition([[['elektronickaFaktura'], { const: true }]]), [ + input( + 'emailPreFaktury', + { type: 'text', title: 'E-mail pre zasielanie elektronických faktúr', required: true }, + {}, + ), + ]), + conditionalFields( + createCondition([ + [ + ['typOdberatela'], + { + enum: [ + 'Existujúci', + 'Zmena poplatkovej povinnosti pre existujúceho zákazníka', + 'Zmena odberateľa', + ], + }, + ], + ]), + [ + checkbox( + 'zmenyVPocteNadob', + { + title: 'Chcem vykonať zmeny v počte nádob alebo ohľadom frekvencie odvozu', + required: true, + }, + { + checkboxLabel: 'Áno, chcem vykonať zmeny', + variant: 'boxed', + }, + ), + ], + ), + ]), + step('sluzba', { title: 'Služba' }, [ + arrayField( + 'infoOOdpade', + { title: 'Info o odpade', required: true }, + { + variant: 'topLevel', + addButtonLabel: 'Pridať ďalší odpad', + itemTitle: 'Odpad {index}', + }, + [ + input( + 'miestoDodania', + { type: 'text', title: 'Miesto dodania / výkonu služby', required: true }, + { helptextHeader: 'Presná adresa' }, + ), + select( + 'druhOdpadu', + { + title: 'Vyberte druh odpadu', + required: true, + options: createStringOptions([ + 'Papier (Pravidelný odvoz odpadových obalov kat. číslo 15)', + 'Papier (Pravidelný odvoz vytriedených zložiek komunálneho odpadu kat. číslo 20)', + 'Plasty (Pravidelný odvoz odpadových obalov kat. číslo 15)', + 'Plasty (Pravidelný odvoz vytriedených zložiek komunálneho odpadu kat. číslo 20)', + 'Sklo (Pravidelný odvoz odpadových obalov kat. číslo 15)', + 'Sklo (Pravidelný odvoz vytriedených zložiek komunálneho odpadu kat. číslo 20)', + 'Kuchynský biologicky rozložiteľný odpad (Pravidelný odvoz vytriedených zložiek komunálneho odpadu kat. číslo 20)', + ]), + }, + { helptextHeader: 'Vyberte len 1 komoditu' }, + ), + conditionalFields( + createCondition([ + [ + ['druhOdpadu'], + { + enum: [ + 'Papier (Pravidelný odvoz odpadových obalov kat. číslo 15)', + 'Papier (Pravidelný odvoz vytriedených zložiek komunálneho odpadu kat. číslo 20)', + ], + }, + ], + ]), + [ + select( + 'objemNadobyPapier', + { + title: 'Vyberte objem nádoby', + required: true, + options: createStringOptions([ + '120 l zberná nádoba', + '240 l zberná nádoba', + '1100 l zberná nádoba', + '3000 l polopodzemný kontajner', + '5000 l polopodzemný kontajner', + ]), + }, + {}, + ), + select( + 'frekvenciaOdvozov', + { + title: 'Frekvencia odvozov', + required: true, + options: createStringOptions(['1 x do týždňa', '2 x do týždňa']), + }, + {}, + ), + ], + ), + conditionalFields( + createCondition([ + [ + ['druhOdpadu'], + { + enum: [ + 'Plasty (Pravidelný odvoz odpadových obalov kat. číslo 15)', + 'Plasty (Pravidelný odvoz vytriedených zložiek komunálneho odpadu kat. číslo 20)', + ], + }, + ], + ]), + [ + select( + 'objemNadobyPlasty', + { + title: 'Vyberte objem nádoby', + required: true, + options: createStringOptions([ + '120 l zberná nádoba', + '240 l zberná nádoba', + '1100 l zberná nádoba', + '3000 l polopodzemný kontajner', + '5000 l polopodzemný kontajner', + ]), + }, + {}, + ), + select( + 'frekvenciaOdvozovPlasty', + { + title: 'Frekvencia odvozov', + required: true, + options: createStringOptions(['1 x do týždňa', '2 x do týždňa']), + }, + {}, + ), + ], + ), + conditionalFields( + createCondition([ + [ + ['druhOdpadu'], + { + enum: [ + 'Sklo (Pravidelný odvoz odpadových obalov kat. číslo 15)', + 'Sklo (Pravidelný odvoz vytriedených zložiek komunálneho odpadu kat. číslo 20)', + ], + }, + ], + ]), + [ + select( + 'objemNadobySklo', + { + title: 'Vyberte objem nádoby', + required: true, + options: createStringOptions([ + '120 l zberná nádoba', + '240 l zberná nádoba', + '1800 l zvon na sklo', + '3000 l polopodzemný kontajner', + ]), + }, + {}, + ), + conditionalFields( + createCondition([ + [['objemNadobySklo'], { enum: ['120 l zberná nádoba', '240 l zberná nádoba'] }], + ]), + [ + select( + 'frekvenciaOdvozovSklo1', + { + title: 'Frekvencia odvozov', + required: true, + options: [{ value: '1x_do_tyzdna', title: '1 x do týždňa' }], + }, + {}, + ), + ], + ), + conditionalFields( + createCondition([[['objemNadobySklo'], { const: '1800 l zvon na sklo' }]]), + [ + select( + 'frekvenciaOdvozovSklo2', + { + title: 'Frekvencia odvozov', + required: true, + options: [{ value: '1x_za_4_tyzdne', title: '1 x za 4 týždne' }], + }, + {}, + ), + ], + ), + ], + ), + conditionalFields( + createCondition([ + [ + ['druhOdpadu'], + { + const: + 'Kuchynský biologicky rozložiteľný odpad (Pravidelný odvoz vytriedených zložiek komunálneho odpadu kat. číslo 20)', + }, + ], + ]), + [ + select( + 'objemNadobyKuchynskyOdpad', + { + title: 'Vyberte objem nádoby', + required: true, + options: createStringOptions([ + '23 l zberná nádoba', + '120 l zberná nádoba', + '240 l zberná nádoba', + ]), + }, + { + helptextHeader: + '23 l zberná nádoba je možná vybrať iba pre právnické osoby, ktoré majú sídlo v rodinných domoch', + }, + ), + select( + 'frekvenciaOdvozovKuchynskyOdpad', + { + title: 'Frekvencia odvozov', + required: true, + options: createStringOptions(['1 x do týždňa', '2 x do týždňa']), + }, + { + helptextHeader: + 'Kuchynský biologicky rozložiteľný odpad sa v Bratislave zbiera celoročne. Interval odvozov sa mení sezónne, a to dvakrát ročne. Od začiatku marca do konca novembra je zber realizovaný 2x za 7 dní. Od začiatku decembra do konca februára bude zber 1x do týždňa.', + }, + ), + ], + ), + number( + 'pocetNadob', + { type: 'number', title: 'Počet nádob', required: true }, + { helptextHeader: 'Uveďte počet nádob' }, + ), + ], + ), + input( + 'emailPotvrdenie', + { type: 'email', title: 'E-mail (potvrdenie o prevzatí odpadov/obalov)', required: true }, + {}, + ), + ]), + step('suhlasy', { title: 'Súhlasy' }, [ + checkbox( + 'suhlas', + { + title: 'Súhlas s TODO', + required: true, + constValue: true, + }, + { + checkboxLabel: 'Súhlasím s TODO', + variant: 'boxed', + }, + ), + customComponentsField( + { + type: 'additionalLinks', + props: { + links: [ + { + title: 'TODO', + href: 'https://olo.sk', + }, + ], + }, + }, + {}, + ), + ]), + ], +) diff --git a/forms-shared/src/schemas/olo/triedenyZberPapieraPlastovASklaPreSpravcovskeSpolocnosti.ts b/forms-shared/src/schemas/olo/triedenyZberPapieraPlastovASklaPreSpravcovskeSpolocnosti.ts index e7810f77d..62539625e 100644 --- a/forms-shared/src/schemas/olo/triedenyZberPapieraPlastovASklaPreSpravcovskeSpolocnosti.ts +++ b/forms-shared/src/schemas/olo/triedenyZberPapieraPlastovASklaPreSpravcovskeSpolocnosti.ts @@ -1,7 +1,283 @@ -import { schema, step } from '../../generator/functions' +import { + arrayField, + checkbox, + conditionalFields, + customComponentsField, + datePicker, + input, + number, + radioGroup, + schema, + select, + step, +} from '../../generator/functions' +import { createCondition, createStringOptions } from '../../generator/helpers' +import { sharedAddressField, sharedPhoneNumberField } from '../shared/fields' export default schema( - { title: 'Triedený zber papiera, plastov a skla pre správcovské spoločnosti' }, + { + title: 'Triedený zber papiera, plastov a skla pre správcovské spoločnosti', + }, {}, - [step('ziadatel', { title: 'Žiadateľ' }, [])], + [ + step('ziadatel', { title: 'Žiadateľ' }, [ + radioGroup( + 'typOdberatela', + { + type: 'string', + title: 'Typ odberateľa', + required: true, + options: createStringOptions(['Nový', 'Existujúci', 'Zmena odberateľa']), + }, + { + variant: 'boxed', + orientations: 'column', + helptextHeader: + 'Nový (nemám uzavretú zmluvu), Existujúci (mám uzavretú zmluvu), Zmena odberateľa (napr. preberám prevádzku alebo správu nehnuteľnosti)', + }, + ), + input('nazovOrganizacie', { type: 'text', title: 'Názov organizácie', required: true }, {}), + sharedAddressField('adresaSidla', 'Adresa sídla organizácie', true), + conditionalFields(createCondition([[['typOdberatela'], { const: 'Existujúci' }]]), [ + input('cisloZmluvy', { type: 'text', title: 'Číslo zmluvy', required: true }, {}), + ]), + conditionalFields(createCondition([[['typOdberatela'], { enum: ['Nový', 'Existujúci'] }]]), [ + input('ico', { type: 'text', title: 'IČO', required: true }, {}), + ]), + conditionalFields(createCondition([[['typOdberatela'], { const: 'Zmena odberateľa' }]]), [ + input( + 'icoPovodnehOdberatela', + { type: 'text', title: 'IČO pôvodného odberateľa', required: true }, + {}, + ), + input('noveIco', { type: 'text', title: 'Nové IČO', required: true }, {}), + datePicker( + 'datumZmeny', + { title: 'Dátum zmeny', required: true }, + { helptextHeader: 'Uveďte dátum predpokladanej zmeny odberateľa' }, + ), + ]), + input('dic', { type: 'text', title: 'DIČ', required: true }, {}), + checkbox( + 'platcaDph', + { title: 'Som platca DPH?', required: true }, + { checkboxLabel: 'Som platca DPH', variant: 'boxed' }, + ), + conditionalFields(createCondition([[['platcaDph'], { const: true }]]), [ + input('icDph', { type: 'text', title: 'IČ DPH', required: true }, {}), + ]), + input( + 'menoKontaktnejOsoby', + { type: 'text', title: 'Meno kontaktnej osoby', required: true }, + {}, + ), + sharedPhoneNumberField('telefon', true), + input('email', { title: 'Email', required: true, type: 'email' }, {}), + input('iban', { type: 'ba-iban', title: 'IBAN', required: true }, {}), + checkbox( + 'elektronickaFaktura', + { + title: 'Súhlasím so zaslaním elektronickej faktúry', + required: true, + }, + { + helptextHeader: + 'V prípade vyjadrenia nesúhlasu bude zákazníkovi za zasielanie faktúry poštou účtovaný poplatok 10 € bez DPH. Osobitné ustanovenia o zasielaní faktúry v elektronickej podobe v zmysle bodu 5.9 VOP.', + checkboxLabel: 'Súhlasím so zaslaním elektronickej faktúry', + variant: 'boxed', + }, + ), + conditionalFields(createCondition([[['elektronickaFaktura'], { const: true }]]), [ + input( + 'emailPreFaktury', + { type: 'text', title: 'E-mail pre zasielanie elektronických faktúr', required: true }, + {}, + ), + ]), + conditionalFields( + createCondition([[['typOdberatela'], { enum: ['Existujúci', 'Zmena odberateľa'] }]]), + [ + checkbox( + 'zmenyVPocteNadob', + { + title: 'Chcem vykonať zmeny v počte nádob alebo ohľadom frekvencie odvozu', + required: true, + }, + { + checkboxLabel: 'Áno, chcem vykonať zmeny', + variant: 'boxed', + }, + ), + ], + ), + ]), + step('sluzba', { title: 'Služba' }, [ + arrayField( + 'infoOOdpade', + { title: 'Info o odpade', required: true }, + { + variant: 'topLevel', + addButtonLabel: 'Pridať ďalší odpad', + itemTitle: 'Odpad {index}', + }, + [ + input( + 'miestoDodania', + { type: 'text', title: 'Miesto dodania / výkonu služby', required: true }, + { helptextHeader: 'Presná adresa' }, + ), + select( + 'druhOdpadu', + { + title: 'Vyberte druh odpadu', + required: true, + options: createStringOptions([ + 'Papier (Pravidelný odvoz vytriedených zložiek komunálneho odpadu kat. číslo 20)', + 'Plasty (Pravidelný odvoz vytriedených zložiek komunálneho odpadu kat. číslo 20)', + 'Sklo (Pravidelný odvoz vytriedených zložiek komunálneho odpadu kat. číslo 20)', + ]), + }, + { + helptextHeader: + 'Vyberte len 1 komoditu. Správcovia nehnuteľností v prípade Kuchynského biologicky rozložiteľného odpadu riešia zapojenie a zmeny v systéme zapojenia na Magistráte hlavného mesta. Zmesový komunálny odpad sa rieši na Magistráte hlavného mesta (https://bratislava.sk/mesto-bratislava/dane-a-poplatky/poplatok-za-komunalne-odpady-a-drobne-stavebne-odpady).', + }, + ), + conditionalFields( + createCondition([ + [ + ['druhOdpadu'], + { + enum: [ + 'Papier (Pravidelný odvoz vytriedených zložiek komunálneho odpadu kat. číslo 20)', + 'Plasty (Pravidelný odvoz vytriedených zložiek komunálneho odpadu kat. číslo 20)', + ], + }, + ], + ]), + [ + select( + 'objemNadobyPapierPlasty', + { + title: 'Vyberte objem nádoby', + required: true, + options: createStringOptions([ + '120 l zberná nádoba', + '240 l zberná nádoba', + '1100 l zberná nádoba', + '3000 l polopodzemný kontajner', + '5000 l polopodzemný kontajner', + ]), + }, + {}, + ), + select( + 'frekvenciaOdvozovPapierPlasty', + { + title: 'Frekvencia odvozov', + required: true, + options: createStringOptions(['1 x do týždňa', '2 x do týždňa']), + }, + {}, + ), + ], + ), + conditionalFields( + createCondition([ + [ + ['druhOdpadu'], + { + const: + 'Sklo (Pravidelný odvoz vytriedených zložiek komunálneho odpadu kat. číslo 20)', + }, + ], + ]), + [ + select( + 'objemNadobySklo', + { + title: 'Vyberte objem nádoby', + required: true, + options: createStringOptions([ + '120 l zberná nádoba', + '240 l zberná nádoba', + '1800 l zvon na sklo', + '3000 l polopodzemný kontajner', + ]), + }, + {}, + ), + conditionalFields( + createCondition([ + [['objemNadobySklo'], { enum: ['120 l zberná nádoba', '240 l zberná nádoba'] }], + ]), + [ + select( + 'frekvenciaOdvozovSklo1', + { + title: 'Frekvencia odvozov', + required: true, + options: createStringOptions(['1 x do týždňa']), + }, + {}, + ), + ], + ), + conditionalFields( + createCondition([[['objemNadobySklo'], { const: '1800 l zvon na sklo' }]]), + [ + select( + 'frekvenciaOdvozovSklo2', + { + title: 'Frekvencia odvozov', + required: true, + options: [{ value: '1x_za_4_tyzdne', title: '1 x za 4 týždne' }], + }, + {}, + ), + ], + ), + ], + ), + number( + 'pocetNadob', + { type: 'number', title: 'Počet nádob', required: true }, + { helptextHeader: 'Uveďte počet nádob' }, + ), + ], + ), + input( + 'emailPotvrdenie', + { type: 'email', title: 'E-mail (potvrdenie o prevzatí odpadov/obalov)', required: true }, + {}, + ), + ]), + step('suhlasy', { title: 'Súhlasy' }, [ + checkbox( + 'suhlas', + { + title: 'Súhlas s TODO', + required: true, + constValue: true, + }, + { + checkboxLabel: 'Súhlasím s TODO', + variant: 'boxed', + }, + ), + customComponentsField( + { + type: 'additionalLinks', + props: { + links: [ + { + title: 'TODO', + href: 'https://olo.sk', + }, + ], + }, + }, + {}, + ), + ]), + ], ) diff --git a/forms-shared/src/schemas/olo/uzatvorenieZmluvyONakladaniSOdpadom.ts b/forms-shared/src/schemas/olo/uzatvorenieZmluvyONakladaniSOdpadom.ts new file mode 100644 index 000000000..f4ff4b2ed --- /dev/null +++ b/forms-shared/src/schemas/olo/uzatvorenieZmluvyONakladaniSOdpadom.ts @@ -0,0 +1,8 @@ +import { schema } from '../../generator/functions' +import { getZevoSchema, ZevoType } from './shared/zevoShared' + +export default schema( + { title: 'Uzatvorenie zmluvy o nakladaní s odpadom' }, + {}, + getZevoSchema(ZevoType.UzatvorenieZmluvyONakladaniSOdpadom), +) diff --git a/forms-shared/src/schemas/olo/zevoMechanickaVykladkaAZhodnotenieOdpaduPodlaIntegrovanehoPovlenia.ts b/forms-shared/src/schemas/olo/zevoMechanickaVykladkaAZhodnotenieOdpaduPodlaIntegrovanehoPovlenia.ts deleted file mode 100644 index 9cade047d..000000000 --- a/forms-shared/src/schemas/olo/zevoMechanickaVykladkaAZhodnotenieOdpaduPodlaIntegrovanehoPovlenia.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { schema, step } from '../../generator/functions' - -export default schema( - { title: 'Mechanická vykládka a zhodnotenie odpadu podľa integrovaného povolenia' }, - {}, - [step('ziadatel', { title: 'Žiadateľ' }, [])], -) diff --git a/forms-shared/src/schemas/olo/zevoPodrvenieAZhodnotenieOdpaduVysypanimDoZasobnika.ts b/forms-shared/src/schemas/olo/zevoPodrvenieAZhodnotenieOdpaduVysypanimDoZasobnika.ts deleted file mode 100644 index 48ac1518b..000000000 --- a/forms-shared/src/schemas/olo/zevoPodrvenieAZhodnotenieOdpaduVysypanimDoZasobnika.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { schema, step } from '../../generator/functions' - -export default schema({ title: 'Podrvenie a zhodnotenie odpadu vysypaním do zásobníka' }, {}, [ - step('ziadatel', { title: 'Žiadateľ' }, []), -]) diff --git a/forms-shared/src/schemas/olo/zevoRucnaVykladkaAZhodnotenieOdpaduPodlaIntegrovanehoPovlenia.ts b/forms-shared/src/schemas/olo/zevoRucnaVykladkaAZhodnotenieOdpaduPodlaIntegrovanehoPovlenia.ts deleted file mode 100644 index 6bf5f145b..000000000 --- a/forms-shared/src/schemas/olo/zevoRucnaVykladkaAZhodnotenieOdpaduPodlaIntegrovanehoPovlenia.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { schema, step } from '../../generator/functions' - -export default schema( - { title: 'Ručná vykládka a zhodnotenie odpadu podľa integrovaného povolenia' }, - {}, - [step('ziadatel', { title: 'Žiadateľ' }, [])], -) diff --git a/forms-shared/src/schemas/olo/zevoUzatvorenieZmluvyONakladaniSOdpadom.ts b/forms-shared/src/schemas/olo/zevoUzatvorenieZmluvyONakladaniSOdpadom.ts deleted file mode 100644 index e6e2771c9..000000000 --- a/forms-shared/src/schemas/olo/zevoUzatvorenieZmluvyONakladaniSOdpadom.ts +++ /dev/null @@ -1,5 +0,0 @@ -import { schema, step } from '../../generator/functions' - -export default schema({ title: 'Uzatvorenie zmluvy o nakladaní s odpadom' }, {}, [ - step('ziadatel', { title: 'Žiadateľ' }, []), -]) diff --git a/forms-shared/src/slovensko-sk/containerFiles.ts b/forms-shared/src/slovensko-sk/containerFiles.ts index 5d5d8024f..235dfd9e6 100644 --- a/forms-shared/src/slovensko-sk/containerFiles.ts +++ b/forms-shared/src/slovensko-sk/containerFiles.ts @@ -3,11 +3,11 @@ import { attachementsXml } from './file-templates/attachementsXml' import { attachementsPospXml } from './file-templates/attachmentsPospXml' import { getFoXslt } from './file-templates/foXslt' import { getHtmlSbXslt } from './file-templates/htmlSbXslt' -import { getEmptySlovenskoSkXml } from './generateXml' import { manifestXml } from './file-templates/manifestXml' import { getMetaXml } from './file-templates/metaXml' import { getSchemaXsd } from './file-templates/schemaXsd' import { mimetype } from './file-templates/mimetype' +import { getEmptyXml } from './file-templates/emptyXml' export function getSlovenskoSkContainerFiles( formDefinition: FormDefinitionSlovenskoSk, @@ -20,7 +20,7 @@ export function getSlovenskoSkContainerFiles( 'Content/form.html.xslt': getHtmlSbXslt(formDefinition), 'Content/form.sb.xslt': getHtmlSbXslt(formDefinition), 'META-INF/manifest.xml': manifestXml, - 'data.xml': getEmptySlovenskoSkXml(formDefinition), + 'data.xml': getEmptyXml(formDefinition), 'meta.xml': getMetaXml(formDefinition, validFrom), 'schema.xsd': getSchemaXsd(formDefinition), mimetype: mimetype, diff --git a/forms-shared/src/slovensko-sk/file-templates/emptyXml.ts b/forms-shared/src/slovensko-sk/file-templates/emptyXml.ts new file mode 100644 index 000000000..d2acd3012 --- /dev/null +++ b/forms-shared/src/slovensko-sk/file-templates/emptyXml.ts @@ -0,0 +1,8 @@ +import { FormDefinitionSlovenskoSk } from '../../definitions/formDefinitionTypes' +import { getEmptySlovenskoSkXmlObject } from '../generateXml' +import { buildSlovenskoSkXml } from '../xmlBuilder' + +export const getEmptyXml = (formDefinition: FormDefinitionSlovenskoSk) => { + const emptyXmlObject = getEmptySlovenskoSkXmlObject(formDefinition) + return buildSlovenskoSkXml(emptyXmlObject, { headless: false, pretty: true }) +} diff --git a/forms-shared/src/slovensko-sk/file-templates/metaXml.ts b/forms-shared/src/slovensko-sk/file-templates/metaXml.ts index 2165e9acf..b72b6653d 100644 --- a/forms-shared/src/slovensko-sk/file-templates/metaXml.ts +++ b/forms-shared/src/slovensko-sk/file-templates/metaXml.ts @@ -1,6 +1,6 @@ import { FormDefinitionSlovenskoSk } from '../../definitions/formDefinitionTypes' -import { slovenskoSkXmlBuilder } from '../xmlBuilder' import { getSlovenskoSkMetaIdentifier } from '../urls' +import { buildSlovenskoSkXml } from '../xmlBuilder' export const getMetaXml = (formDefinition: FormDefinitionSlovenskoSk, validFrom: string) => { const metaData = { @@ -29,5 +29,5 @@ export const getMetaXml = (formDefinition: FormDefinitionSlovenskoSk, validFrom: }, } - return slovenskoSkXmlBuilder.buildObject(metaData) + return buildSlovenskoSkXml(metaData, { headless: false, pretty: true }) } diff --git a/forms-shared/src/slovensko-sk/generateXml.ts b/forms-shared/src/slovensko-sk/generateXml.ts index 2c6bbd822..4afb5887a 100644 --- a/forms-shared/src/slovensko-sk/generateXml.ts +++ b/forms-shared/src/slovensko-sk/generateXml.ts @@ -4,9 +4,11 @@ import { renderSlovenskoXmlSummary } from './renderXmlSummary' import removeMarkdown from 'remove-markdown' import { FormsBackendFile } from '../form-files/serverFilesTypes' import { getSlovenskoSkXmlns } from './urls' -import { slovenskoSkXmlBuilder, slovenskoSkXmlBuilderHeadless } from './xmlBuilder' -function getSlovenskoSkXmlBase(formDefinition: FormDefinitionSlovenskoSk, body: GenericObjectType) { +function getSlovenskoSkXmlObjectBase( + formDefinition: FormDefinitionSlovenskoSk, + body: GenericObjectType, +) { return { eform: { $: { @@ -18,8 +20,11 @@ function getSlovenskoSkXmlBase(formDefinition: FormDefinitionSlovenskoSk, body: } } -export function getEmptySlovenskoSkXml(formDefinition: FormDefinitionSlovenskoSk) { - const xml = getSlovenskoSkXmlBase(formDefinition, { +/** + * Generates an empty Slovensko SK XML object that can be built with "xml2js" to create a valid XML. + */ +export function getEmptySlovenskoSkXmlObject(formDefinition: FormDefinitionSlovenskoSk) { + return getSlovenskoSkXmlObjectBase(formDefinition, { Json: JSON.stringify({}), Summary: { Form: { @@ -30,22 +35,19 @@ export function getEmptySlovenskoSkXml(formDefinition: FormDefinitionSlovenskoSk }, TermsAndConditions: '', }) - - return slovenskoSkXmlBuilder.buildObject(xml) } -export async function generateSlovenskoSkXml( +/** + * Generates a Slovensko SK XML object that can be built with "xml2js" to create a valid XML. + */ +export async function generateSlovenskoSkXmlObject( formDefinition: FormDefinitionSlovenskoSk, formData: GenericObjectType, serverFiles?: FormsBackendFile[], - headless = false, ) { - const xml = getSlovenskoSkXmlBase(formDefinition, { + return getSlovenskoSkXmlObjectBase(formDefinition, { Json: JSON.stringify(formData), Summary: await renderSlovenskoXmlSummary(formDefinition, formData, serverFiles), TermsAndConditions: removeMarkdown(formDefinition.termsAndConditions), }) - - const builder = headless ? slovenskoSkXmlBuilderHeadless : slovenskoSkXmlBuilder - return builder.buildObject(xml) } diff --git a/forms-shared/src/slovensko-sk/xmlBuilder.ts b/forms-shared/src/slovensko-sk/xmlBuilder.ts index f0fbf3f37..fddec1048 100644 --- a/forms-shared/src/slovensko-sk/xmlBuilder.ts +++ b/forms-shared/src/slovensko-sk/xmlBuilder.ts @@ -1,15 +1,26 @@ import { Builder } from 'xml2js' +import { GenericObjectType } from '@rjsf/utils' -const builderOptionsBase = { - xmldec: { - version: '1.0', - encoding: 'UTF-8', +export const buildSlovenskoSkXml = ( + xmlObject: GenericObjectType, + { + headless, + pretty, + }: { + headless: boolean + pretty: boolean }, - renderOpts: { - pretty: true, - }, -} +) => { + const builder = new Builder({ + xmldec: { + version: '1.0', + encoding: 'UTF-8', + }, + renderOpts: { + pretty, + }, + headless, + }) -export const slovenskoSkXmlBuilder = new Builder(builderOptionsBase) - -export const slovenskoSkXmlBuilderHeadless = new Builder({ ...builderOptionsBase, headless: true }) + return builder.buildObject(xmlObject) +} diff --git a/forms-shared/tests/slovensko-sk/slovenskoSkForm.ts b/forms-shared/tests/slovensko-sk/slovenskoSkForm.ts index 4d806bce3..70d24797d 100644 --- a/forms-shared/tests/slovensko-sk/slovenskoSkForm.ts +++ b/forms-shared/tests/slovensko-sk/slovenskoSkForm.ts @@ -1,5 +1,5 @@ import { getExampleFormPairs } from '../../src/example-forms/getExampleFormPairs' -import { generateSlovenskoSkXml } from '../../src/slovensko-sk/generateXml' +import { generateSlovenskoSkXmlObject } from '../../src/slovensko-sk/generateXml' import { isSlovenskoSkFormDefinition } from '../../src/definitions/formDefinitionTypes' import { renderApacheFopPdf } from '../../test-utils/apache-fop/renderApacheFopPdf' import { expectPdfToMatchSnapshot } from '../../test-utils/expectPdfToMatchSnapshot' @@ -12,6 +12,7 @@ import { formDefinitions } from '../../src/definitions/formDefinitions' import { validateXml } from '../../test-utils/validateXml' import { fetchSlovenskoSkFormMetadata } from '../../test-utils/fetchSlovenskoSkFormMetadata' import { extractJsonFromSlovenskoSkXml } from '../../src/slovensko-sk/extractJson' +import { buildSlovenskoSkXml } from '../../src/slovensko-sk/xmlBuilder' describe('slovenskoSkForm', () => { formDefinitions.filter(isSlovenskoSkFormDefinition).forEach((formDefinition) => { @@ -43,11 +44,12 @@ describe('slovenskoSkForm', () => { describe(`${exampleForm.name}`, () => { let xmlString: string beforeAll(async () => { - xmlString = await generateSlovenskoSkXml( + const xmlObject = await generateSlovenskoSkXmlObject( formDefinition, exampleForm.formData, exampleForm.serverFiles, ) + xmlString = buildSlovenskoSkXml(xmlObject, { headless: false, pretty: true }) }) it('XML should match snapshot', async () => { diff --git a/nest-forms-backend/package-lock.json b/nest-forms-backend/package-lock.json index 43105a712..41a08bf61 100644 --- a/nest-forms-backend/package-lock.json +++ b/nest-forms-backend/package-lock.json @@ -13,11 +13,11 @@ "@golevelup/nestjs-rabbitmq": "^5.3.0", "@golevelup/ts-jest": "^0.5.4", "@nestjs/bull": "^10.1.1", - "@nestjs/common": "^10.3.8", + "@nestjs/common": "^10.4.2", "@nestjs/config": "^3.2.2", - "@nestjs/core": "^10.3.8", + "@nestjs/core": "^10.4.2", "@nestjs/passport": "^10.0.3", - "@nestjs/platform-express": "^10.3.8", + "@nestjs/platform-express": "^10.4.4", "@nestjs/schedule": "^4.1.0", "@nestjs/swagger": "^7.3.1", "@pdf-lib/fontkit": "^1.1.1", @@ -60,7 +60,7 @@ "@darraghor/eslint-plugin-nestjs-typed": "^4.0.1", "@nestjs/cli": "^10.3.2", "@nestjs/schematics": "^10.1.1", - "@nestjs/testing": "^10.3.8", + "@nestjs/testing": "^10.4.2", "@types/amqplib": "^0.10.5", "@types/express": "^4.17.21", "@types/jest": "29.5.12", @@ -2588,12 +2588,12 @@ } }, "node_modules/@nestjs/common": { - "version": "10.3.8", - "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-10.3.8.tgz", - "integrity": "sha512-P+vPEIvqx2e+fonsYVlFXKvoChyJ8Tq+lfpqdVFqblovHbFr3kZ/nYX0cPs+XuW6bnRT8tz0SSR9XBGU43kJhw==", + "version": "10.4.2", + "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-10.4.2.tgz", + "integrity": "sha512-7uLRj/1WBX93qM78keTE8b5SqIgz5Rhe0BPnOdCL1QnA7mLVcj0aEyLuHryeZJfx26FDoeAEMrLCC/RAdmIHog==", "dependencies": { "iterare": "1.2.1", - "tslib": "2.6.2", + "tslib": "2.7.0", "uid": "2.0.2" }, "funding": { @@ -2615,6 +2615,11 @@ } } }, + "node_modules/@nestjs/common/node_modules/tslib": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==" + }, "node_modules/@nestjs/config": { "version": "3.2.2", "resolved": "https://registry.npmjs.org/@nestjs/config/-/config-3.2.2.tgz", @@ -2631,16 +2636,16 @@ } }, "node_modules/@nestjs/core": { - "version": "10.3.8", - "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-10.3.8.tgz", - "integrity": "sha512-AxF4tpYLDNn5Wfb3C4bNaaHJ4pREH5FJrSisR2A5zkYpQFORFs0Tc36lOFPMwBTy8Iv2wUwWLUVc5ftBnxEv4w==", + "version": "10.4.2", + "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-10.4.2.tgz", + "integrity": "sha512-h2sjNzFHzoxOHU5Ag/pCVn0CrYHKTa0HfjGAa6GOrffRAsIa1H2nJaUzg89yHZXkHgWi+UynRsp8A4HJ1JVg9w==", "hasInstallScript": true, "dependencies": { "@nuxtjs/opencollective": "0.3.2", "fast-safe-stringify": "2.1.1", "iterare": "1.2.1", - "path-to-regexp": "3.2.0", - "tslib": "2.6.2", + "path-to-regexp": "3.3.0", + "tslib": "2.7.0", "uid": "2.0.2" }, "funding": { @@ -2667,6 +2672,16 @@ } } }, + "node_modules/@nestjs/core/node_modules/path-to-regexp": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-3.3.0.tgz", + "integrity": "sha512-qyCH421YQPS2WFDxDjftfc1ZR5WKQzVzqsp4n9M2kQhVOo/ByahFoUNJfl58kOcEGfQ//7weFTDhm+ss8Ecxgw==" + }, + "node_modules/@nestjs/core/node_modules/tslib": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==" + }, "node_modules/@nestjs/mapped-types": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/@nestjs/mapped-types/-/mapped-types-2.0.5.tgz", @@ -2696,15 +2711,15 @@ } }, "node_modules/@nestjs/platform-express": { - "version": "10.3.8", - "resolved": "https://registry.npmjs.org/@nestjs/platform-express/-/platform-express-10.3.8.tgz", - "integrity": "sha512-sifLoxgEJvAgbim1UuW6wyScMfkS9SVQRH+lN33N/9ZvZSjO6NSDLOe+wxqsnZkia+QrjFC0qy0ITRAsggfqbg==", + "version": "10.4.4", + "resolved": "https://registry.npmjs.org/@nestjs/platform-express/-/platform-express-10.4.4.tgz", + "integrity": "sha512-y52q1MxhbHaT3vAgWd08RgiYon0lJgtTa8U6g6gV0KI0IygwZhDQFJVxnrRDUdxQGIP5CKHmfQu3sk9gTNFoEA==", "dependencies": { - "body-parser": "1.20.2", + "body-parser": "1.20.3", "cors": "2.8.5", - "express": "4.19.2", + "express": "4.21.0", "multer": "1.4.4-lts.1", - "tslib": "2.6.2" + "tslib": "2.7.0" }, "funding": { "type": "opencollective", @@ -2715,6 +2730,11 @@ "@nestjs/core": "^10.0.0" } }, + "node_modules/@nestjs/platform-express/node_modules/tslib": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==" + }, "node_modules/@nestjs/schedule": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/@nestjs/schedule/-/schedule-4.1.0.tgz", @@ -2795,12 +2815,12 @@ } }, "node_modules/@nestjs/testing": { - "version": "10.3.8", - "resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-10.3.8.tgz", - "integrity": "sha512-hpX9das2TdFTKQ4/2ojhjI6YgXtCfXRKui3A4Qaj54VVzc5+mtK502Jj18Vzji98o9MVS6skmYu+S/UvW3U6Fw==", + "version": "10.4.2", + "resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-10.4.2.tgz", + "integrity": "sha512-jiQU3l/D4B1/LxfmC7eMtJCHEsQ1/frvpQKiYAALEZU4N2VQ9U9pGJzVOR5EAtiMx5Ng1PGks8MTOjsFp6/eww==", "dev": true, "dependencies": { - "tslib": "2.6.2" + "tslib": "2.7.0" }, "funding": { "type": "opencollective", @@ -2821,6 +2841,12 @@ } } }, + "node_modules/@nestjs/testing/node_modules/tslib": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==", + "dev": true + }, "node_modules/@nodelib/fs.scandir": { "version": "2.1.5", "resolved": "https://registry.npmjs.org/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz", @@ -4689,9 +4715,9 @@ "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" }, "node_modules/body-parser": { - "version": "1.20.2", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", - "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", + "version": "1.20.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", + "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==", "dependencies": { "bytes": "3.1.2", "content-type": "~1.0.5", @@ -4701,7 +4727,7 @@ "http-errors": "2.0.0", "iconv-lite": "0.4.24", "on-finished": "2.4.1", - "qs": "6.11.0", + "qs": "6.13.0", "raw-body": "2.5.2", "type-is": "~1.6.18", "unpipe": "1.0.0" @@ -6142,9 +6168,9 @@ "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==" }, "node_modules/encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==", "engines": { "node": ">= 0.8" } @@ -6553,21 +6579,6 @@ "integrity": "sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ==", "dev": true }, - "node_modules/eslint-config-adjunct/node_modules/qs": { - "version": "6.12.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.12.3.tgz", - "integrity": "sha512-AWJm14H1vVaO/iNZ4/hO+HyaTehuy9nRqVdkTqlJt0HWvBiBIEXFmb4C0DGeYo3Xes9rrEW+TxHsaigCbN5ICQ==", - "dev": true, - "dependencies": { - "side-channel": "^1.0.6" - }, - "engines": { - "node": ">=0.6" - }, - "funding": { - "url": "https://github.com/sponsors/ljharb" - } - }, "node_modules/eslint-config-adjunct/node_modules/url": { "version": "0.11.3", "resolved": "https://registry.npmjs.org/url/-/url-0.11.3.tgz", @@ -7634,36 +7645,36 @@ "integrity": "sha512-4EMSHGOPSwAfBiibw3ndnP0AvjDWLsMvGOvWEZ2F96IGk0bIVdjQisOHxReSkE13mHcfbuCiXw+G4y0zv6N8Eg==" }, "node_modules/express": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", - "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", + "version": "4.21.0", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.0.tgz", + "integrity": "sha512-VqcNGcj/Id5ZT1LZ/cfihi3ttTn+NJmkli2eZADigjq29qTlWi/hAQ43t/VLPq8+UX06FCEx3ByOYet6ZFblng==", "dependencies": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.2", + "body-parser": "1.20.3", "content-disposition": "0.5.4", "content-type": "~1.0.4", "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "etag": "~1.8.1", - "finalhandler": "1.2.0", + "finalhandler": "1.3.1", "fresh": "0.5.2", "http-errors": "2.0.0", - "merge-descriptors": "1.0.1", + "merge-descriptors": "1.0.3", "methods": "~1.1.2", "on-finished": "2.4.1", "parseurl": "~1.3.3", - "path-to-regexp": "0.1.7", + "path-to-regexp": "0.1.10", "proxy-addr": "~2.0.7", - "qs": "6.11.0", + "qs": "6.13.0", "range-parser": "~1.2.1", "safe-buffer": "5.2.1", - "send": "0.18.0", - "serve-static": "1.15.0", + "send": "0.19.0", + "serve-static": "1.16.2", "setprototypeof": "1.2.0", "statuses": "2.0.1", "type-is": "~1.6.18", @@ -7688,9 +7699,9 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, "node_modules/express/node_modules/path-to-regexp": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" + "version": "0.1.10", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz", + "integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==" }, "node_modules/external-editor": { "version": "3.1.0", @@ -7851,12 +7862,12 @@ } }, "node_modules/finalhandler": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", - "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz", + "integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==", "dependencies": { "debug": "2.6.9", - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "on-finished": "2.4.1", "parseurl": "~1.3.3", @@ -11031,9 +11042,12 @@ } }, "node_modules/merge-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==", + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } }, "node_modules/merge-stream": { "version": "2.0.0", @@ -12402,11 +12416,11 @@ ] }, "node_modules/qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", + "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", "dependencies": { - "side-channel": "^1.0.4" + "side-channel": "^1.0.6" }, "engines": { "node": ">=0.6" @@ -13194,9 +13208,9 @@ "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" }, "node_modules/send": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", - "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz", + "integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==", "dependencies": { "debug": "2.6.9", "depd": "2.0.0", @@ -13229,6 +13243,14 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, + "node_modules/send/node_modules/encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==", + "engines": { + "node": ">= 0.8" + } + }, "node_modules/send/node_modules/ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -13244,14 +13266,14 @@ } }, "node_modules/serve-static": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", - "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz", + "integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==", "dependencies": { - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "parseurl": "~1.3.3", - "send": "0.18.0" + "send": "0.19.0" }, "engines": { "node": ">= 0.8.0" @@ -16822,13 +16844,20 @@ } }, "@nestjs/common": { - "version": "10.3.8", - "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-10.3.8.tgz", - "integrity": "sha512-P+vPEIvqx2e+fonsYVlFXKvoChyJ8Tq+lfpqdVFqblovHbFr3kZ/nYX0cPs+XuW6bnRT8tz0SSR9XBGU43kJhw==", + "version": "10.4.2", + "resolved": "https://registry.npmjs.org/@nestjs/common/-/common-10.4.2.tgz", + "integrity": "sha512-7uLRj/1WBX93qM78keTE8b5SqIgz5Rhe0BPnOdCL1QnA7mLVcj0aEyLuHryeZJfx26FDoeAEMrLCC/RAdmIHog==", "requires": { "iterare": "1.2.1", - "tslib": "2.6.2", + "tslib": "2.7.0", "uid": "2.0.2" + }, + "dependencies": { + "tslib": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==" + } } }, "@nestjs/config": { @@ -16843,16 +16872,28 @@ } }, "@nestjs/core": { - "version": "10.3.8", - "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-10.3.8.tgz", - "integrity": "sha512-AxF4tpYLDNn5Wfb3C4bNaaHJ4pREH5FJrSisR2A5zkYpQFORFs0Tc36lOFPMwBTy8Iv2wUwWLUVc5ftBnxEv4w==", + "version": "10.4.2", + "resolved": "https://registry.npmjs.org/@nestjs/core/-/core-10.4.2.tgz", + "integrity": "sha512-h2sjNzFHzoxOHU5Ag/pCVn0CrYHKTa0HfjGAa6GOrffRAsIa1H2nJaUzg89yHZXkHgWi+UynRsp8A4HJ1JVg9w==", "requires": { "@nuxtjs/opencollective": "0.3.2", "fast-safe-stringify": "2.1.1", "iterare": "1.2.1", - "path-to-regexp": "3.2.0", - "tslib": "2.6.2", + "path-to-regexp": "3.3.0", + "tslib": "2.7.0", "uid": "2.0.2" + }, + "dependencies": { + "path-to-regexp": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-3.3.0.tgz", + "integrity": "sha512-qyCH421YQPS2WFDxDjftfc1ZR5WKQzVzqsp4n9M2kQhVOo/ByahFoUNJfl58kOcEGfQ//7weFTDhm+ss8Ecxgw==" + }, + "tslib": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==" + } } }, "@nestjs/mapped-types": { @@ -16868,15 +16909,22 @@ "requires": {} }, "@nestjs/platform-express": { - "version": "10.3.8", - "resolved": "https://registry.npmjs.org/@nestjs/platform-express/-/platform-express-10.3.8.tgz", - "integrity": "sha512-sifLoxgEJvAgbim1UuW6wyScMfkS9SVQRH+lN33N/9ZvZSjO6NSDLOe+wxqsnZkia+QrjFC0qy0ITRAsggfqbg==", + "version": "10.4.4", + "resolved": "https://registry.npmjs.org/@nestjs/platform-express/-/platform-express-10.4.4.tgz", + "integrity": "sha512-y52q1MxhbHaT3vAgWd08RgiYon0lJgtTa8U6g6gV0KI0IygwZhDQFJVxnrRDUdxQGIP5CKHmfQu3sk9gTNFoEA==", "requires": { - "body-parser": "1.20.2", + "body-parser": "1.20.3", "cors": "2.8.5", - "express": "4.19.2", + "express": "4.21.0", "multer": "1.4.4-lts.1", - "tslib": "2.6.2" + "tslib": "2.7.0" + }, + "dependencies": { + "tslib": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==" + } } }, "@nestjs/schedule": { @@ -16930,12 +16978,20 @@ } }, "@nestjs/testing": { - "version": "10.3.8", - "resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-10.3.8.tgz", - "integrity": "sha512-hpX9das2TdFTKQ4/2ojhjI6YgXtCfXRKui3A4Qaj54VVzc5+mtK502Jj18Vzji98o9MVS6skmYu+S/UvW3U6Fw==", + "version": "10.4.2", + "resolved": "https://registry.npmjs.org/@nestjs/testing/-/testing-10.4.2.tgz", + "integrity": "sha512-jiQU3l/D4B1/LxfmC7eMtJCHEsQ1/frvpQKiYAALEZU4N2VQ9U9pGJzVOR5EAtiMx5Ng1PGks8MTOjsFp6/eww==", "dev": true, "requires": { - "tslib": "2.6.2" + "tslib": "2.7.0" + }, + "dependencies": { + "tslib": { + "version": "2.7.0", + "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.7.0.tgz", + "integrity": "sha512-gLXCKdN1/j47AiHiOkJN69hJmcbGTHI0ImLmbYLHykhgeN0jVGola9yVjFgzCUklsZQMW55o+dW7IXv3RCXDzA==", + "dev": true + } } }, "@nodelib/fs.scandir": { @@ -18487,9 +18543,9 @@ "integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==" }, "body-parser": { - "version": "1.20.2", - "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.2.tgz", - "integrity": "sha512-ml9pReCu3M61kGlqoTm2umSXTlRTuGTx0bfYj+uIUKKYycG5NtSbeetV3faSU6R7ajOPw0g/J1PvK4qNy7s5bA==", + "version": "1.20.3", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.20.3.tgz", + "integrity": "sha512-7rAxByjUMqQ3/bHJy7D6OGXvx/MMc4IqBn/X0fcM1QUcAItpZrBEYhWGem+tzXH90c+G01ypMcYJBO9Y30203g==", "requires": { "bytes": "3.1.2", "content-type": "~1.0.5", @@ -18499,7 +18555,7 @@ "http-errors": "2.0.0", "iconv-lite": "0.4.24", "on-finished": "2.4.1", - "qs": "6.11.0", + "qs": "6.13.0", "raw-body": "2.5.2", "type-is": "~1.6.18", "unpipe": "1.0.0" @@ -19572,9 +19628,9 @@ "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==" }, "encodeurl": { - "version": "1.0.2", - "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", - "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==" + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.0.tgz", + "integrity": "sha512-Q0n9HRi4m6JuGIV1eFlmvJB7ZEVxu93IrMyiMsGC0lrMJMWzRgx6WGquyfQgZVb31vhGgXnfmPNNXmxnOkRBrg==" }, "encoding": { "version": "0.1.13", @@ -19948,15 +20004,6 @@ "integrity": "sha512-jmYNElW7yvO7TV33CjSmvSiE2yco3bV2czu/OzDKdMNVZQWfxCblURLhf+47syQRBntjfLdd/H0egrzIG+oaFQ==", "dev": true }, - "qs": { - "version": "6.12.3", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.12.3.tgz", - "integrity": "sha512-AWJm14H1vVaO/iNZ4/hO+HyaTehuy9nRqVdkTqlJt0HWvBiBIEXFmb4C0DGeYo3Xes9rrEW+TxHsaigCbN5ICQ==", - "dev": true, - "requires": { - "side-channel": "^1.0.6" - } - }, "url": { "version": "0.11.3", "resolved": "https://registry.npmjs.org/url/-/url-0.11.3.tgz", @@ -20655,36 +20702,36 @@ "integrity": "sha512-4EMSHGOPSwAfBiibw3ndnP0AvjDWLsMvGOvWEZ2F96IGk0bIVdjQisOHxReSkE13mHcfbuCiXw+G4y0zv6N8Eg==" }, "express": { - "version": "4.19.2", - "resolved": "https://registry.npmjs.org/express/-/express-4.19.2.tgz", - "integrity": "sha512-5T6nhjsT+EOMzuck8JjBHARTHfMht0POzlA60WV2pMD3gyXw2LZnZ+ueGdNxG+0calOJcWKbpFcuzLZ91YWq9Q==", + "version": "4.21.0", + "resolved": "https://registry.npmjs.org/express/-/express-4.21.0.tgz", + "integrity": "sha512-VqcNGcj/Id5ZT1LZ/cfihi3ttTn+NJmkli2eZADigjq29qTlWi/hAQ43t/VLPq8+UX06FCEx3ByOYet6ZFblng==", "requires": { "accepts": "~1.3.8", "array-flatten": "1.1.1", - "body-parser": "1.20.2", + "body-parser": "1.20.3", "content-disposition": "0.5.4", "content-type": "~1.0.4", "cookie": "0.6.0", "cookie-signature": "1.0.6", "debug": "2.6.9", "depd": "2.0.0", - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "etag": "~1.8.1", - "finalhandler": "1.2.0", + "finalhandler": "1.3.1", "fresh": "0.5.2", "http-errors": "2.0.0", - "merge-descriptors": "1.0.1", + "merge-descriptors": "1.0.3", "methods": "~1.1.2", "on-finished": "2.4.1", "parseurl": "~1.3.3", - "path-to-regexp": "0.1.7", + "path-to-regexp": "0.1.10", "proxy-addr": "~2.0.7", - "qs": "6.11.0", + "qs": "6.13.0", "range-parser": "~1.2.1", "safe-buffer": "5.2.1", - "send": "0.18.0", - "serve-static": "1.15.0", + "send": "0.19.0", + "serve-static": "1.16.2", "setprototypeof": "1.2.0", "statuses": "2.0.1", "type-is": "~1.6.18", @@ -20706,9 +20753,9 @@ "integrity": "sha512-Tpp60P6IUJDTuOq/5Z8cdskzJujfwqfOTkrwIwj7IRISpnkJnT6SyJ4PCPnGMoFjC9ddhal5KVIYtAt97ix05A==" }, "path-to-regexp": { - "version": "0.1.7", - "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", - "integrity": "sha512-5DFkuoqlv1uYQKxy8omFBeJPQcdoE07Kv2sferDCrAq1ohOU+MSDswDIbnx3YAM60qIOnYa53wBhXW0EbMonrQ==" + "version": "0.1.10", + "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.10.tgz", + "integrity": "sha512-7lf7qcQidTku0Gu3YDPc8DJ1q7OOucfa/BSsIwjuh56VU7katFvuM8hULfkwB3Fns/rsVF7PwPKVw1sl5KQS9w==" } } }, @@ -20836,12 +20883,12 @@ "integrity": "sha512-8rXg1ZnX7xzy2NGDVkBVaAy+lSlPNwad13BtgSlLuxfIslyt5Vg64U7tFcCt4WS1R0hvtnQybT/IyCkGZ3DpXQ==" }, "finalhandler": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.2.0.tgz", - "integrity": "sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==", + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.3.1.tgz", + "integrity": "sha512-6BN9trH7bp3qvnrRyzsBz+g3lZxTNZTbVO2EV1CS0WIcDbawYVdYvGflME/9QP0h0pYlCDBCTjYa9nZzMDpyxQ==", "requires": { "debug": "2.6.9", - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "on-finished": "2.4.1", "parseurl": "~1.3.3", @@ -23220,9 +23267,9 @@ } }, "merge-descriptors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", - "integrity": "sha512-cCi6g3/Zr1iqQi6ySbseM1Xvooa98N0w31jzUYrXPX2xqObmFGHJ0tQ5u74H3mVh7wLouTseZyYIq39g8cNp1w==" + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.3.tgz", + "integrity": "sha512-gaNvAS7TZ897/rVaZ0nMtAyxNyi/pdbjbAwUpFQpN70GqnVfOiXpeUUMKRBmzXaSQ8DdTX4/0ms62r2K+hE6mQ==" }, "merge-stream": { "version": "2.0.0", @@ -24227,11 +24274,11 @@ "dev": true }, "qs": { - "version": "6.11.0", - "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", - "integrity": "sha512-MvjoMCJwEarSbUYk5O+nmoSzSutSsTwF85zcHPQ9OrlFoZOYIjaqBAJIqIXjptyD5vThxGq52Xu/MaJzRkIk4Q==", + "version": "6.13.0", + "resolved": "https://registry.npmjs.org/qs/-/qs-6.13.0.tgz", + "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", "requires": { - "side-channel": "^1.0.4" + "side-channel": "^1.0.6" } }, "query-string": { @@ -24799,9 +24846,9 @@ } }, "send": { - "version": "0.18.0", - "resolved": "https://registry.npmjs.org/send/-/send-0.18.0.tgz", - "integrity": "sha512-qqWzuOjSFOuqPjFe4NOsMLafToQQwBSOEpS+FwEt3A2V3vKubTquT3vmLTQpFgMXp8AlFWFuP1qKaJZOtPpVXg==", + "version": "0.19.0", + "resolved": "https://registry.npmjs.org/send/-/send-0.19.0.tgz", + "integrity": "sha512-dW41u5VfLXu8SJh5bwRmyYUbAoSB3c9uQh6L8h/KtsFREPWpbX1lrljJo186Jc4nmci/sGUZ9a0a0J2zgfq2hw==", "requires": { "debug": "2.6.9", "depd": "2.0.0", @@ -24833,6 +24880,11 @@ } } }, + "encodeurl": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", + "integrity": "sha512-TPJXq8JqFaVYm2CWmPvnP2Iyo4ZSM7/QKcSmuMLDObfpH5fi7RUGmd/rTDf+rut/saiDiQEeVTNgAmJEdAOx0w==" + }, "ms": { "version": "2.1.3", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", @@ -24850,14 +24902,14 @@ } }, "serve-static": { - "version": "1.15.0", - "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.15.0.tgz", - "integrity": "sha512-XGuRDNjXUijsUL0vl6nSD7cwURuzEgglbOaFuZM9g3kwDXOWVTck0jLzjPzGD+TazWbboZYu52/9/XPdUgne9g==", + "version": "1.16.2", + "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.16.2.tgz", + "integrity": "sha512-VqpjJZKadQB/PEbEwvFdO43Ax5dFBZ2UECszz8bQ7pi7wt//PWe1P6MN7eCnjsatYtBT6EuiClbjSWP2WrIoTw==", "requires": { - "encodeurl": "~1.0.2", + "encodeurl": "~2.0.0", "escape-html": "~1.0.3", "parseurl": "~1.3.3", - "send": "0.18.0" + "send": "0.19.0" } }, "set-blocking": { diff --git a/nest-forms-backend/package.json b/nest-forms-backend/package.json index 7d69fa2f6..7e7ba59b5 100644 --- a/nest-forms-backend/package.json +++ b/nest-forms-backend/package.json @@ -32,11 +32,11 @@ "@golevelup/nestjs-rabbitmq": "^5.3.0", "@golevelup/ts-jest": "^0.5.4", "@nestjs/bull": "^10.1.1", - "@nestjs/common": "^10.3.8", + "@nestjs/common": "^10.4.2", "@nestjs/config": "^3.2.2", - "@nestjs/core": "^10.3.8", + "@nestjs/core": "^10.4.2", "@nestjs/passport": "^10.0.3", - "@nestjs/platform-express": "^10.3.8", + "@nestjs/platform-express": "^10.4.4", "@nestjs/schedule": "^4.1.0", "@nestjs/swagger": "^7.3.1", "@pdf-lib/fontkit": "^1.1.1", @@ -79,7 +79,7 @@ "@darraghor/eslint-plugin-nestjs-typed": "^4.0.1", "@nestjs/cli": "^10.3.2", "@nestjs/schematics": "^10.1.1", - "@nestjs/testing": "^10.3.8", + "@nestjs/testing": "^10.4.2", "@types/amqplib": "^0.10.5", "@types/express": "^4.17.21", "@types/jest": "29.5.12", diff --git a/nest-forms-backend/src/convert/convert.service.ts b/nest-forms-backend/src/convert/convert.service.ts index 33ade0331..f41786a7f 100644 --- a/nest-forms-backend/src/convert/convert.service.ts +++ b/nest-forms-backend/src/convert/convert.service.ts @@ -17,7 +17,8 @@ import { extractJsonFromSlovenskoSkXml, ExtractJsonFromSlovenskoSkXmlError, } from 'forms-shared/slovensko-sk/extractJson' -import { generateSlovenskoSkXml } from 'forms-shared/slovensko-sk/generateXml' +import { generateSlovenskoSkXmlObject } from 'forms-shared/slovensko-sk/generateXml' +import { buildSlovenskoSkXml } from 'forms-shared/slovensko-sk/xmlBuilder' import { renderSummaryPdf } from 'forms-shared/summary-pdf/renderSummaryPdf' import { chromium } from 'playwright' import { parseStringPromise } from 'xml2js' @@ -68,12 +69,11 @@ export default class ConvertService { /** * Temporary function to convert forms with new government XMLs, will be deleted when all the forms are migrated. */ - private async convertJsonToXmlNewGovernment( + private async convertJsonToXmlObjectNewGovernment( form: Forms, formDefinition: FormDefinitionSlovenskoSk, formDataJson: Prisma.JsonValue, - headless: boolean, - ): Promise { + ): Promise { // Find a better way how to get the form with files const formWithFiles = (await this.prismaService.forms.findUnique({ where: { @@ -84,18 +84,17 @@ export default class ConvertService { }, })) as FormWithFiles - return generateSlovenskoSkXml( + return generateSlovenskoSkXmlObject( formDefinition, formDataJson as GenericObjectType, formWithFiles.files, - headless, ) } - private async convertJsonToXmlLegacy( + private async convertJsonToXmlObjectLegacy( formDefinition: FormDefinitionSlovenskoSk, formDataJson: Prisma.JsonValue, - ): Promise { + ): Promise { const xmlTemplate = createXmlTemplate(formDefinition) const $ = cheerio.load(xmlTemplate, { xmlMode: true, @@ -107,19 +106,20 @@ export default class ConvertService { formDataJson, formDefinition.schemas.schema as JsonSchema, ) - return $('E-form').prop('outerHTML') ?? '' + const xmlString = $('E-form').prop('outerHTML') ?? '' + + return parseStringPromise(xmlString) } /** - * Do not use directly for user facing endpoints as this bypasses the access check in `convertJsonToXmlNewGovernment`. + * Do not use directly for user facing endpoints as this bypasses the access check in `convertJsonToXmlObjectNewGovernment`. * * TODO: Pass files to the function instead */ - async convertJsonToXmlForForm( + async convertJsonToXmlObjectForForm( form: Forms, - headless: boolean, formDataJsonOverride?: Prisma.JsonValue, - ): Promise { + ): Promise { const formDefinition = getFormDefinitionBySlug(form.formDefinitionSlug) if (formDefinition === null) { throw this.throwerErrorGuard.NotFoundException( @@ -136,15 +136,14 @@ export default class ConvertService { const formDataJson = formDataJsonOverride ?? form.formDataJson if (formDefinition.newGovernmentXml) { - return this.convertJsonToXmlNewGovernment( + return this.convertJsonToXmlObjectNewGovernment( form, formDefinition, formDataJson, - headless, ) } - return this.convertJsonToXmlLegacy(formDefinition, formDataJson) + return this.convertJsonToXmlObjectLegacy(formDefinition, formDataJson) } async convertJsonToXmlV2( @@ -158,7 +157,11 @@ export default class ConvertService { ico, ) - return this.convertJsonToXmlForForm(form, false, data.jsonData) + const xmlObject = await this.convertJsonToXmlObjectForForm( + form, + data.jsonData, + ) + return buildSlovenskoSkXml(xmlObject, { headless: false, pretty: true }) } private async convertXmlToJsonLegacy( diff --git a/nest-forms-backend/src/nases/dtos/xml.dto.ts b/nest-forms-backend/src/nases/dtos/xml.dto.ts new file mode 100644 index 000000000..35eddd7c4 --- /dev/null +++ b/nest-forms-backend/src/nases/dtos/xml.dto.ts @@ -0,0 +1,12 @@ +export type NasesAttachmentXmlObject = { + $: { + Id?: string + IsSigned: string + Name: string + Description: string + Class: string + MimeType: string + Encoding: string + } + _?: string | object +} diff --git a/nest-forms-backend/src/nases/utils-services/tokens.nases.service.spec.ts b/nest-forms-backend/src/nases/utils-services/tokens.nases.service.spec.ts index 00d99b217..74198b010 100644 --- a/nest-forms-backend/src/nases/utils-services/tokens.nases.service.spec.ts +++ b/nest-forms-backend/src/nases/utils-services/tokens.nases.service.spec.ts @@ -1,8 +1,13 @@ /* eslint-disable pii/no-phone-number */ /* eslint-disable pii/no-email */ +import { Readable } from 'node:stream' + import { getQueueToken } from '@nestjs/bull' -import { ConfigService } from '@nestjs/config' +import { ConfigModule } from '@nestjs/config' import { Test, TestingModule } from '@nestjs/testing' +import { FileStatus } from '@prisma/client' +import { v1, v4 } from 'uuid' +import { Builder, Parser } from 'xml2js' import prismaMock from '../../../test/singleton' import { CognitoGetUserData } from '../../auth/dtos/cognito.dto' @@ -17,6 +22,10 @@ import NasesUtilsService from './tokens.nases.service' jest.mock('axios') jest.mock('../../utils/subservices/minio-client.subservice') jest.mock('../../convert/convert.service') +jest.mock('uuid', () => ({ + v4: jest.fn(), + v1: jest.fn(), +})) describe('NasesUtilsService', () => { let service: NasesUtilsService @@ -24,13 +33,19 @@ describe('NasesUtilsService', () => { beforeEach(async () => { jest.resetAllMocks() const app: TestingModule = await Test.createTestingModule({ + imports: [ + ConfigModule.forFeature(async () => ({ + NASES_SENDER_URI: 'example_sender', + NASES_RECIPIENT_URI: 'example_recipient', + MINIO_SAFE_BUCKET: '', + })), + ], providers: [ NasesUtilsService, ConvertService, ThrowerErrorGuard, { provide: PrismaService, useValue: prismaMock }, MinioClientSubservice, - ConfigService, TaxService, { provide: getQueueToken('tax'), @@ -72,30 +87,213 @@ describe('NasesUtilsService', () => { }) }) - describe('formatXmlToOneLine', () => { - it('should correctly put xml into one line', () => { - const xml = ` - - < tag1 attribute="value1"/> - < tag2 - attribute="value2">Content - Another content - - ` - - const xmlNormal = ` - - - Content - Another content - ` + describe('createEnvelopeSendMessage', () => { + it('should create XML', async () => { + const mockFiles = [ + { + id: 'id-file0001', + pospId: 'posp0001', + formId: 'form0001', + scannerId: 'scanner0001', + minioFileName: 'miniofile0001', + fileName: 'file0001.pdf', + fileSize: 512, + status: FileStatus.ACCEPTED, + ginisOrder: 1, + ginisUploaded: false, + ginisUploadedError: false, + createdAt: new Date(), + updatedAt: new Date(), + }, + { + id: 'id-file0002', + pospId: 'posp0002', + formId: 'form0002', + scannerId: null, + minioFileName: 'miniofile0002', + fileName: 'file0002.pdf', + fileSize: 512, + status: FileStatus.ACCEPTED, + ginisOrder: null, + ginisUploaded: true, + ginisUploadedError: false, + createdAt: new Date(), + updatedAt: new Date(), + }, + ] + + ;(v4 as jest.Mock).mockReturnValue('12345678-1234-1234-1234-123456789012') + ;(v1 as jest.Mock).mockReturnValue('12345678-1234-1234-1234-123456789012') + service['convertService'].convertJsonToXmlObjectForForm = jest + .fn() + .mockResolvedValue({ + eform: { + tag1: [{ $: { attribute: 'value1' } }], + tag2: [{ $: { attribute: 'value2' }, _: 'Content' }], + tag3: ['Another content\n'], + }, + }) + + prismaMock.files.findMany.mockResolvedValue(mockFiles) + + service['minioClientSubservice'].loadFileStream = jest + .fn() + .mockImplementation(async (_: string, filename: string) => { + const streamData = `test string for input: ${filename}` + + const readableStream = new Readable() + // eslint-disable-next-line no-underscore-dangle + readableStream._read = () => {} + readableStream.push(streamData) + // eslint-disable-next-line unicorn/no-array-push-push + readableStream.push(null) + }) + + service['taxService'].getFilledInPdfBase64 = jest + .fn() + .mockResolvedValue('AWUKDHLAIUWDHU=====') + // eslint-disable-next-line xss/no-mixed-html - const expected = - // eslint-disable-next-line no-secrets/no-secrets - 'ContentAnother content' + service['stream2buffer'] = jest + .fn() + // eslint-disable-next-line xss/no-mixed-html + .mockResolvedValue(Buffer.from('Mock file data string >')) + + let returnXmlString = await service['createEnvelopeSendMessage']({ + id: '123456678901234567890', + formDefinitionSlug: 'priznanie-k-dani-z-nehnutelnosti', + createdAt: new Date(), + updatedAt: new Date(), + externalId: null, + userExternalId: null, + email: null, + finishSubmission: new Date(), + mainUri: null, + actorUri: null, + ownerType: 'FO', + ico: '12345678', + state: 'QUEUED', + error: 'NONE', + formDataJson: null, + formDataGinis: null, + // eslint-disable-next-line xss/no-mixed-html + formDataBase64: 'L:UHIOQWALIUiluh<\tag>liaUWHDL====', + ginisDocumentId: null, + senderId: null, + recipientId: null, + archived: false, + ginisState: 'CREATED', + }) + + const parser = new Parser() + const builder = new Builder({ + // eslint-disable-next-line unicorn/text-encoding-identifier-case + xmldec: { version: '1.0', encoding: 'UTF-8' }, + renderOpts: { + pretty: false, + }, + }) + + /* eslint-disable no-secrets/no-secrets */ + let xmlExample = builder.buildObject( + await parser.parseStringPromise( + `\n` + + ` \n` + + ` 3.0\n` + + `
\n` + + ` \n` + + ` EGOV_APPLICATION\n` + + ` esmao.eforms.bratislava.obec_024\n` + + ` 201501.2\n` + + ` 123456678901234567890\n` + + ` 12345678-1234-1234-1234-123456789012\n` + + ` \n` + + `
\n` + + ` \n` + + ` \n` + + ` 123456678901234567890\n` + + ` example_sender\n` + + ` example_recipient\n` + + ` esmao.eforms.bratislava.obec_024\n` + + ` Podávanie daňového priznanie k dani z nehnuteľností\n` + + ` TW9jayBmaWxlIGRhdGEgPHRhZz4gc3RyaW5nIDwvdGFnPj4=\n` + + ` TW9jayBmaWxlIGRhdGEgPHRhZz4gc3RyaW5nIDwvdGFnPj4=\n` + + ` AWUKDHLAIUWDHU=====\n` + + ` L:UHIOQWALIUil<tag>uh<\tag>liaUWHDL====\n` + + ` \n` + + ` \n` + + `
`, + ), + ) + /* eslint-enable no-secrets/no-secrets */ + + expect(returnXmlString).toBe(xmlExample) + + returnXmlString = await service['createEnvelopeSendMessage']({ + id: '123456678901234567890', + formDefinitionSlug: 'stanovisko-k-investicnemu-zameru', + createdAt: new Date(), + updatedAt: new Date(), + externalId: null, + userExternalId: null, + email: null, + finishSubmission: new Date(), + mainUri: null, + actorUri: null, + ownerType: 'FO', + ico: '12345678', + state: 'QUEUED', + error: 'NONE', + formDataJson: null, + formDataGinis: null, + // eslint-disable-next-line xss/no-mixed-html + formDataBase64: 'L:UHIOQWALIUiluh<\tag>liaUWHDL====', + ginisDocumentId: null, + senderId: null, + recipientId: null, + archived: false, + ginisState: 'CREATED', + }) + + /* eslint-disable no-secrets/no-secrets */ + xmlExample = builder.buildObject( + // eslint-disable-next-line xss/no-mixed-html + await parser.parseStringPromise( + `\n` + + ` \n` + + ` 3.0\n` + + `
\n` + + ` \n` + + ` EGOV_APPLICATION\n` + + ` 00603481.stanoviskoKInvesticnemuZameru\n` + + ` 0.8\n` + + ` 123456678901234567890\n` + + ` 12345678-1234-1234-1234-123456789012\n` + + ` \n` + + `
\n` + + ` \n` + + ` \n` + + ` 123456678901234567890\n` + + ` example_sender\n` + + ` example_recipient\n` + + ` 00603481.stanoviskoKInvesticnemuZameru\n` + + ` 123456678901234567890\n` + + ` \n` + + ` \n` + + ` \n` + + ` Content\n` + + ` Another content\n` + + `\n` + + ` \n` + + ` \n` + + ` \n` + + ` \n` + + `
`, + ), + ) + /* eslint-enable no-secrets/no-secrets */ - expect(service['formatXmlToOneLine'](xml)).toBe(expected) - expect(service['formatXmlToOneLine'](xmlNormal)).toBe(expected) + expect(returnXmlString).toBe(xmlExample) }) }) }) diff --git a/nest-forms-backend/src/nases/utils-services/tokens.nases.service.ts b/nest-forms-backend/src/nases/utils-services/tokens.nases.service.ts index d20662b79..be51069e6 100644 --- a/nest-forms-backend/src/nases/utils-services/tokens.nases.service.ts +++ b/nest-forms-backend/src/nases/utils-services/tokens.nases.service.ts @@ -13,6 +13,7 @@ import { isSlovenskoSkTaxFormDefinition, } from 'forms-shared/definitions/formDefinitionTypes' import { getFormDefinitionBySlug } from 'forms-shared/definitions/getFormDefinitionBySlug' +import { buildSlovenskoSkXml } from 'forms-shared/slovensko-sk/xmlBuilder' import jwt from 'jsonwebtoken' import mime from 'mime-types' import { v1 as uuidv1, v4 as uuidv4 } from 'uuid' @@ -35,6 +36,7 @@ import { NasesSendResponse, ResponseGdprDataDto, } from '../dtos/responses.dto' +import { NasesAttachmentXmlObject } from '../dtos/xml.dto' import { NasesErrorCodesEnum, NasesErrorCodesResponseEnum, @@ -50,7 +52,7 @@ export default class NasesUtilsService { private readonly convertService: ConvertService, private readonly throwerErrorGuard: ThrowerErrorGuard, private prismaService: PrismaService, - private minioClientSubervice: MinioClientSubservice, + private minioClientSubservice: MinioClientSubservice, private taxService: TaxService, private configService: ConfigService, ) { @@ -95,8 +97,8 @@ export default class NasesUtilsService { private async createAttachmentsIfExists( form: Forms, formDefinition: FormDefinitionSlovenskoSk, - ): Promise { - let result = '' + ): Promise { + const result: NasesAttachmentXmlObject[] = [] const files = await this.prismaService.files.findMany({ where: { formId: form.id, @@ -106,14 +108,25 @@ export default class NasesUtilsService { // eslint-disable-next-line no-restricted-syntax for (const file of files) { const mimeType = mime.lookup(file.fileName) || 'application/pdf' - const fileStream = await this.minioClientSubervice.loadFileStream( + const fileStream = await this.minioClientSubservice.loadFileStream( this.configService.getOrThrow('MINIO_SAFE_BUCKET'), `${file.pospId}/${form.id}/${file.minioFileName}`, ) // eslint-disable-next-line no-restricted-syntax const fileBuffer = await this.stream2buffer(fileStream) const fileBase64 = fileBuffer.toString('base64') - result += `${fileBase64}` + result.push({ + $: { + Id: file.id, + IsSigned: 'false', + Name: file.fileName, + Description: 'ATTACHMENT', + Class: 'ATTACHMENT', + MimeType: mimeType, + Encoding: 'Base64', + }, + _: fileBase64, + }) } if (isSlovenskoSkTaxFormDefinition(formDefinition)) { try { @@ -121,7 +134,18 @@ export default class NasesUtilsService { form.formDataJson, form.id, ) - result += `${base64FormPdf}` + result.push({ + $: { + Id: uuidv1(), + IsSigned: 'false', + Name: 'printed-form.pdf', + Description: 'ATTACHMENT', + Class: 'ATTACHMENT', + MimeType: 'application/pdf', + Encoding: 'Base64', + }, + _: base64FormPdf, + }) } catch (error) { console.error( `ERROR - Printing form to attachment to Nases and Noris error for form id ${form.id}`, @@ -276,24 +300,42 @@ export default class NasesUtilsService { return result; */ } - private formatXmlToOneLine(xml: string): string { - const result = xml - .replaceAll(/\s+/g, ' ') // replace all multiple whitespaces with just one space - .replaceAll(/>\s+<') // delete all whitespaces between tags - .replaceAll(/\s*<\s*/g, '<') // delete all whitespaces (spaces) around tag marks - .replaceAll(/\s*>\s*/g, '>') - .replaceAll(/\s*\/>/g, '/>') - .replaceAll(/<\/\s*/g, ' { + let message: string | object | null = null - return result + if (form.formDataBase64) { + message = form.formDataBase64 + } + + if (!isSigned) { + try { + message = await this.convertService.convertJsonToXmlObjectForForm(form) + } catch (error) { + throw this.throwerErrorGuard.InternalServerErrorException( + ErrorsEnum.INTERNAL_SERVER_ERROR, + `There was an error during converting json form data to xml: ${error}`, + ) + } + } + + if (!message) { + throw this.throwerErrorGuard.UnprocessableEntityException( + ErrorsEnum.UNPROCESSABLE_ENTITY_ERROR, + `Message of body is not defined. There is no base64 nor schema`, + ) + } + + return message } /** * Dynamically creates a subject of the submission. If there is not a subject format in the form definition, * it uses default from the form definition. * - * It replaces an occurence of "{path}" with a value from data.formDataJson, at the given path. There are three possibilities: + * It replaces an occurrence of "{path}" with a value from data.formDataJson, at the given path. There are three possibilities: * - If there is a string, it just prints the string * - If there is an array of strings, it prints them separated by a comma * - Otherwise prints empty string "" @@ -304,7 +346,6 @@ export default class NasesUtilsService { * @param data Form instance * @returns message subject generated for the given form */ - private async createEnvelopeSendMessage( form: Forms, senderUri?: string, @@ -324,70 +365,15 @@ export default class NasesUtilsService { } const { isSigned, pospID, pospVersion, title } = formDefinition - let message: string | null = null + const message = await this.getFormMessage(form, isSigned) - if (form.formDataBase64) { - message = form.formDataBase64 - } - if (!isSigned) { - try { - message = await this.convertService.convertJsonToXmlForForm(form, true) - } catch (error) { - throw this.throwerErrorGuard.InternalServerErrorException( - ErrorsEnum.INTERNAL_SERVER_ERROR, - `There was an error during converting json form data to xml: ${< - string - >error}`, - ) - } - } - - if (!message) { - throw this.throwerErrorGuard.UnprocessableEntityException( - ErrorsEnum.UNPROCESSABLE_ENTITY_ERROR, - `Message of body is not defined. There is no base64 nor schema`, - ) - } - // message = Buffer.from(message, 'binary').toString('base64'); - let envelope: string - // envelope = ` - // - // - // 3.0 - //
- // - // EGOV_APPLICATION - // App.GeneralAgenda - // 1.9 - // 0d83aadc-edba-4d1d-9a2f-d62eae985c51 - // 0d83aadc-edba-4d1d-9a2f-d62eae985c51 - - // - //
- // - // - // 0d83aadc-edba-4d1d-9a2f-d62eae985c51 - // e264cea1-acdc-4db0-8901-275d15b1f48a - // e264cea1-acdc-4db0-8901-275d15b1f48a - // App.GeneralAgenda - // Podanie - // - // - // predmet - // popis - // - // - // - // - //
- // ` const senderId = senderUri ?? this.configService.get('NASES_SENDER_URI') ?? '' const correlationId = uuidv4() let subject: string = form.id let mimeType = 'application/x-eform-xml' let encoding = 'XML' - let attachments = '' + let attachments: NasesAttachmentXmlObject[] = [] if (isSlovenskoSkTaxFormDefinition(formDefinition)) { subject = 'Podávanie daňového priznanie k dani z nehnuteľností' // TODO fix in formDefinition, quickfix here formDefinition.messageSubjectDefault @@ -395,40 +381,67 @@ export default class NasesUtilsService { encoding = 'Base64' attachments = await this.createAttachmentsIfExists(form, formDefinition) } - envelope = ` - - - 3.0 -
- - EGOV_APPLICATION - ${pospID} - ${pospVersion} - ${form.id} - ${correlationId} - -
- - - ${form.id} - ${senderId} - ${this.configService.getOrThrow( - 'NASES_RECIPIENT_URI', - )} - ${pospID} - ${subject} - ${message} - ${attachments} - - -
- ` - // - // - envelope = this.formatXmlToOneLine(envelope) - return envelope + + const attachmentBase = { + $: { + Id: form.id, + IsSigned: isSigned ? 'true' : 'false', + Name: title, + Description: '', + Class: 'FORM', + MimeType: mimeType, + Encoding: encoding, + }, + } + + if (typeof message === 'string') { + attachments.push({ + ...attachmentBase, + _: message, + }) + } else if (typeof message === 'object') { + attachments.push({ + ...attachmentBase, + ...message, + }) + } + + const template = { + SKTalkMessage: { + $: { + xmlns: 'http://gov.sk/SKTalkMessage', + 'xmlns:xsi': 'http://www.w3.org/2001/XMLSchema-instance', + 'xmlns:xsd': 'http://www.w3.org/2001/XMLSchema', + }, + EnvelopeVersion: '3.0', + Header: { + MessageInfo: { + Class: 'EGOV_APPLICATION', + PospID: pospID, + PospVersion: pospVersion, + MessageID: form.id, + CorrelationID: correlationId, + }, + }, + Body: { + MessageContainer: { + $: { + xmlns: 'http://schemas.gov.sk/core/MessageContainer/1.0', + }, + MessageId: form.id, + SenderId: senderId, + RecipientId: this.configService.getOrThrow( + 'NASES_RECIPIENT_URI', + ), + MessageType: pospID, + MessageSubject: subject, + Object: attachments, + }, + }, + }, + } + + return buildSlovenskoSkXml(template, { headless: false, pretty: false }) } private getNasesError(code: number): string { diff --git a/next/components/forms/widget-components/SelectField/SelectField.tsx b/next/components/forms/widget-components/SelectField/SelectField.tsx index c0487b628..d940b8f27 100644 --- a/next/components/forms/widget-components/SelectField/SelectField.tsx +++ b/next/components/forms/widget-components/SelectField/SelectField.tsx @@ -195,9 +195,7 @@ const SelectField = < }), placeholder: ({ isDisabled }) => (isDisabled ? 'text-gray-500' : 'text-gray-600'), valueContainer: ({ isDisabled }) => - // If there's a long value in select, it stretches the parent element instead of wrapping the text. - // `[container-type:inline-size]` fixes this for some reason. - cx('gap-x-2 gap-y-1 px-3 py-2 [container-type:inline-size] lg:px-4 lg:py-3', { + cx('gap-x-2 gap-y-1 px-3 py-2 lg:px-4 lg:py-3', { // if rounded is not applied, the background overflows to the "control" 'rounded-l-lg bg-gray-100 text-gray-500': isDisabled, }),