diff --git a/backend/src/migrations/1722423180665-ContactRole.ts b/backend/src/migrations/1722423180665-ContactRole.ts new file mode 100644 index 00000000..13e6b78d --- /dev/null +++ b/backend/src/migrations/1722423180665-ContactRole.ts @@ -0,0 +1,13 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class ContactRole1722423180665 implements MigrationInterface { + name = 'ContactRole1722423180665'; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "_contact" ADD "role" text`); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query(`ALTER TABLE "_contact" DROP COLUMN "role"`); + } +} diff --git a/backend/src/modules/organization/dto/create-contact.dto.ts b/backend/src/modules/organization/dto/create-contact.dto.ts index 1655ce7d..56672924 100644 --- a/backend/src/modules/organization/dto/create-contact.dto.ts +++ b/backend/src/modules/organization/dto/create-contact.dto.ts @@ -28,4 +28,9 @@ export class CreateContactDto { @IsNotEmpty() @MaxLength(50) email: string; + + @IsOptional() + @IsString() + @MaxLength(50) + role: string; } diff --git a/backend/src/modules/organization/entities/contact.entity.ts b/backend/src/modules/organization/entities/contact.entity.ts index 895b547e..f1863fa7 100644 --- a/backend/src/modules/organization/entities/contact.entity.ts +++ b/backend/src/modules/organization/entities/contact.entity.ts @@ -13,6 +13,9 @@ export class Contact extends BaseEntity { @Column({ type: 'text', name: 'phone', nullable: true }) phone: string; + @Column({ type: 'text', name: 'role', nullable: true }) + role: string; + @ManyToMany( (type) => OrganizationLegal, (organizationLegal) => organizationLegal.directors, diff --git a/frontend/src/assets/locales/ro/translation.json b/frontend/src/assets/locales/ro/translation.json index 8083899c..0e215641 100644 --- a/frontend/src/assets/locales/ro/translation.json +++ b/frontend/src/assets/locales/ro/translation.json @@ -585,7 +585,8 @@ "name": "Nume și prenume", "role": "Rol", "email": "E-mail", - "phone": "Telefon" + "phone": "Telefon", + "role": "Rol" }, "legal_config": { "name": { @@ -607,6 +608,10 @@ "minim": "Numărul de telefon al reprezentantului legal nu poate avea mai puțin de 10 caractere.", "invalid": "Numărul de telefon are un format invalid.", "label": "Telefon" + }, + "role": { + "maxim": "Rolul reprezentantului legal nu poate avea mai mult de 50 de caractere.", + "label": "Rol" } }, "director_config": { @@ -629,6 +634,10 @@ "minim": "Numărul de telefon al membrului Consiliului Director nu poate avea mai puțin de 10 caractere.", "invalid": "Numărul de telefon are un format invalid.", "label": "Telefon" + }, + "role": { + "maxim": "Rolul membrului Consiliului Director nu poate avea mai mult de 50 de caractere.", + "label": "Rol" } }, "other_config": { diff --git a/frontend/src/pages/create-organziation/components/CreateOrganizationLegal.tsx b/frontend/src/pages/create-organziation/components/CreateOrganizationLegal.tsx index 25919882..20468fed 100644 --- a/frontend/src/pages/create-organziation/components/CreateOrganizationLegal.tsx +++ b/frontend/src/pages/create-organziation/components/CreateOrganizationLegal.tsx @@ -90,6 +90,7 @@ const CreateOrganizationLegal = () => { fullName: legal.legalReprezentative_fullName, phone: legal.legalReprezentative_phone, email: legal.legalReprezentative_email, + role: legal.legalReprezentative_role, }; //Using isValidating because RHF triggers 2 renders and update local storage with invalid data @@ -184,7 +185,8 @@ const CreateOrganizationLegal = () => { !( director.fullName === selectedDirector?.fullName && director.email === selectedDirector?.email && - director.phone === selectedDirector?.phone + director.phone === selectedDirector?.phone && + director.role === selectedDirector?.role ), ); setDirectors([...filteredDirectors, { ...selectedDirector, ...contact }]); @@ -206,7 +208,8 @@ const CreateOrganizationLegal = () => { !( director.fullName === selectedDirector?.fullName && director.email === selectedDirector?.email && - director.phone === selectedDirector?.phone + director.phone === selectedDirector?.phone && + director.role === selectedDirector?.role ), ); setDirectors(filteredDirectors); @@ -303,6 +306,7 @@ const CreateOrganizationLegal = () => { OrganizationLegalConfig.legal_reprezentative_name, OrganizationLegalConfig.legal_reprezentative_email, OrganizationLegalConfig.legal_reprezentative_phone, + OrganizationLegalConfig.legal_reprezentative_role, ]} id="create-organization-legal" /> diff --git a/frontend/src/pages/organization/components/OrganizationLegal/OrganizationLegal.tsx b/frontend/src/pages/organization/components/OrganizationLegal/OrganizationLegal.tsx index a722978e..5babb64c 100644 --- a/frontend/src/pages/organization/components/OrganizationLegal/OrganizationLegal.tsx +++ b/frontend/src/pages/organization/components/OrganizationLegal/OrganizationLegal.tsx @@ -247,6 +247,7 @@ const OrganizationLegal = () => { fullName: data.legalReprezentative_fullName, phone: data.legalReprezentative_phone, email: data.legalReprezentative_email, + role: data.legalReprezentative_role, }; updateOrganization( @@ -427,6 +428,7 @@ const OrganizationLegal = () => { OrganizationLegalConfig.legal_reprezentative_name, OrganizationLegalConfig.legal_reprezentative_email, OrganizationLegalConfig.legal_reprezentative_phone, + OrganizationLegalConfig.legal_reprezentative_role, ]} /> diff --git a/frontend/src/pages/organization/components/OrganizationLegal/OrganizationLegalConfig.ts b/frontend/src/pages/organization/components/OrganizationLegal/OrganizationLegalConfig.ts index ed51b1e9..982af466 100644 --- a/frontend/src/pages/organization/components/OrganizationLegal/OrganizationLegalConfig.ts +++ b/frontend/src/pages/organization/components/OrganizationLegal/OrganizationLegalConfig.ts @@ -23,6 +23,10 @@ const translations = { invalid: i18n.t('legal:legal_config.phone.invalid'), phone: i18n.t('legal:legal_config.phone.label'), }, + role: { + maxim: i18n.t('legal:legal_config.role.maxim'), + role: i18n.t('legal:legal_config.role.label'), + }, }; export const OrganizationLegalConfig: Record = { @@ -98,4 +102,19 @@ export const OrganizationLegalConfig: Record = { placeholder: '', }, }, + legal_reprezentative_role: { + key: 'legalReprezentative_role', + rules: { + maxLength: { + value: 50, + message: translations.role.maxim, + }, + }, + config: { + type: 'text', + label: translations.role.role, + helperText: '', + placeholder: 'Administrator', + }, + }, }; diff --git a/frontend/src/pages/organization/components/OrganizationLegal/components/DirectorConfig.ts b/frontend/src/pages/organization/components/OrganizationLegal/components/DirectorConfig.ts index 0ead5d0f..092d88e8 100644 --- a/frontend/src/pages/organization/components/OrganizationLegal/components/DirectorConfig.ts +++ b/frontend/src/pages/organization/components/OrganizationLegal/components/DirectorConfig.ts @@ -23,6 +23,10 @@ const translations = { invalid: i18n.t('legal:director_config.phone.invalid'), phone: i18n.t('legal:director_config.phone.label'), }, + role: { + maxim: i18n.t('legal:director_config.role.maxim'), + role: i18n.t('legal:director_config.role.label'), + }, }; export const DirectorConfig: Record = { @@ -98,4 +102,19 @@ export const DirectorConfig: Record = { placeholder: '0721111111', }, }, + role: { + key: 'role', + rules: { + maxLength: { + value: 50, + message: translations.phone.maxim, + }, + }, + config: { + type: 'text', + label: i18n.t('legal:director_config.role.label'), + helperText: '', + placeholder: 'Administrator', + }, + }, }; diff --git a/frontend/src/pages/organization/components/OrganizationLegal/components/DirectorModal.tsx b/frontend/src/pages/organization/components/OrganizationLegal/components/DirectorModal.tsx index d57f7e2e..7af926dd 100644 --- a/frontend/src/pages/organization/components/OrganizationLegal/components/DirectorModal.tsx +++ b/frontend/src/pages/organization/components/OrganizationLegal/components/DirectorModal.tsx @@ -92,7 +92,7 @@ const DirectorModal = ({ isEdit, onClose, defaultValue, onSave, id }: DirectorMo control={control} errors={errors} readonly={false} - configs={[DirectorConfig.fullName, DirectorConfig.email, DirectorConfig.phone]} + configs={[DirectorConfig.fullName, DirectorConfig.email, DirectorConfig.phone, DirectorConfig.role]} id={id} /> diff --git a/frontend/src/pages/organization/components/OrganizationLegal/table-headers/DirectorsTable.headers.tsx b/frontend/src/pages/organization/components/OrganizationLegal/table-headers/DirectorsTable.headers.tsx index 418ffa98..78d41e7c 100644 --- a/frontend/src/pages/organization/components/OrganizationLegal/table-headers/DirectorsTable.headers.tsx +++ b/frontend/src/pages/organization/components/OrganizationLegal/table-headers/DirectorsTable.headers.tsx @@ -8,6 +8,7 @@ const translations = { name: i18n.t('legal:header.name'), email: i18n.t('legal:header.email'), phone: i18n.t('legal:header.phone'), + role: i18n.t('legal:header.role'), }; export const DirectorsTableHeaders: TableColumn[] = [ @@ -35,4 +36,12 @@ export const DirectorsTableHeaders: TableColumn[] = [ minWidth: '10rem', sortable: true, }, + { + id: 'role', + name: , + selector: (row: Contact) => row.role, + grow: 1, + minWidth: '10rem', + sortable: true, + }, ]; diff --git a/frontend/src/pages/organization/interfaces/Contact.interface.ts b/frontend/src/pages/organization/interfaces/Contact.interface.ts index 0816a858..bcd8c80f 100644 --- a/frontend/src/pages/organization/interfaces/Contact.interface.ts +++ b/frontend/src/pages/organization/interfaces/Contact.interface.ts @@ -4,4 +4,5 @@ export interface Contact extends BaseEntity { fullName: string; email: string; phone: string; + role: string; }