@carlonicora/nextjs-jsonapi 1.65.0 → 1.66.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (80) hide show
  1. package/dist/{AuthComponent-B4rNZRYE.d.ts → AuthComponent-DL1D3y7f.d.ts} +1 -1
  2. package/dist/{AuthComponent-nzabiz68.d.mts → AuthComponent-NwQ_ZXsv.d.mts} +1 -1
  3. package/dist/{BlockNoteEditor-Y5XAD6NR.js → BlockNoteEditor-GQM2TZG2.js} +14 -14
  4. package/dist/{BlockNoteEditor-Y5XAD6NR.js.map → BlockNoteEditor-GQM2TZG2.js.map} +1 -1
  5. package/dist/{BlockNoteEditor-SCQGD6F2.mjs → BlockNoteEditor-KCJMA6LW.mjs} +4 -4
  6. package/dist/{auth.interface-C1WjZ0fM.d.ts → auth.interface-BX_1qZZJ.d.ts} +1 -1
  7. package/dist/{auth.interface-fBFqIrw4.d.mts → auth.interface-yeLelxdI.d.mts} +1 -1
  8. package/dist/billing/index.js +346 -346
  9. package/dist/billing/index.mjs +3 -3
  10. package/dist/{chunk-G7PGWMFO.mjs → chunk-35GWVOYZ.mjs} +61 -1
  11. package/dist/{chunk-G7PGWMFO.mjs.map → chunk-35GWVOYZ.mjs.map} +1 -1
  12. package/dist/{chunk-OLNMWVOV.mjs → chunk-4E74ZTRT.mjs} +2115 -1834
  13. package/dist/chunk-4E74ZTRT.mjs.map +1 -0
  14. package/dist/{chunk-LRXJT656.js → chunk-NVXYOQFW.js} +61 -1
  15. package/dist/chunk-NVXYOQFW.js.map +1 -0
  16. package/dist/{chunk-RA4RYKYB.js → chunk-OQRBY22T.js} +11 -11
  17. package/dist/{chunk-RA4RYKYB.js.map → chunk-OQRBY22T.js.map} +1 -1
  18. package/dist/{chunk-5ODPC3YX.js → chunk-QIFM4G7T.js} +1174 -893
  19. package/dist/chunk-QIFM4G7T.js.map +1 -0
  20. package/dist/{chunk-5KMKI23S.mjs → chunk-UXGPZZ6V.mjs} +2 -2
  21. package/dist/client/index.d.mts +6 -6
  22. package/dist/client/index.d.ts +6 -6
  23. package/dist/client/index.js +4 -4
  24. package/dist/client/index.mjs +3 -3
  25. package/dist/components/index.d.mts +42 -7
  26. package/dist/components/index.d.ts +42 -7
  27. package/dist/components/index.js +14 -4
  28. package/dist/components/index.js.map +1 -1
  29. package/dist/components/index.mjs +13 -3
  30. package/dist/{config-DZWAFB7H.d.ts → config-CyCAWW-d.d.ts} +1 -1
  31. package/dist/{config-ndRJIQsP.d.mts → config-D-mqttuF.d.mts} +1 -1
  32. package/dist/{content.interface-B5ySfiOE.d.mts → content.interface-8T5-G84c.d.mts} +1 -1
  33. package/dist/{content.interface-mmz0uMwm.d.ts → content.interface-D-xdYxjt.d.ts} +1 -1
  34. package/dist/contexts/index.d.mts +2 -2
  35. package/dist/contexts/index.d.ts +2 -2
  36. package/dist/contexts/index.js +4 -4
  37. package/dist/contexts/index.mjs +3 -3
  38. package/dist/core/index.d.mts +29 -9
  39. package/dist/core/index.d.ts +29 -9
  40. package/dist/core/index.js +2 -2
  41. package/dist/core/index.mjs +1 -1
  42. package/dist/index.d.mts +8 -8
  43. package/dist/index.d.ts +8 -8
  44. package/dist/index.js +3 -3
  45. package/dist/index.mjs +2 -2
  46. package/dist/{notification.interface-DG7cq9oG.d.mts → notification.interface-C6UcmJqu.d.mts} +20 -0
  47. package/dist/{notification.interface-COKHDQeE.d.ts → notification.interface-ItBxq2au.d.ts} +20 -0
  48. package/dist/{s3.service-ppn9iGJU.d.ts → s3.service-DIR6Su9B.d.ts} +3 -3
  49. package/dist/{s3.service-BoRPFx82.d.mts → s3.service-XchHd3ii.d.mts} +3 -3
  50. package/dist/server/index.d.mts +4 -4
  51. package/dist/server/index.d.ts +4 -4
  52. package/dist/server/index.js +3 -3
  53. package/dist/server/index.mjs +1 -1
  54. package/dist/{useRbacState-DhuYYr0S.d.mts → useRbacState-Btk1gkQg.d.mts} +1 -1
  55. package/dist/{useRbacState-NnzNL2ED.d.ts → useRbacState-CUj0hp8t.d.ts} +1 -1
  56. package/dist/{useSocket-bsV-K4qR.d.ts → useSocket-BSUN9s3p.d.ts} +1 -1
  57. package/dist/{useSocket-CtfuR5wD.d.mts → useSocket-DKI92Fbg.d.mts} +1 -1
  58. package/package.json +2 -1
  59. package/src/components/containers/RoundPageContainer.tsx +1 -1
  60. package/src/components/fiscal/FiscalDataDisplay.tsx +26 -0
  61. package/src/components/fiscal/ItalianFiscalData.tsx +120 -0
  62. package/src/components/fiscal/ItalianFiscalDataDisplay.tsx +24 -0
  63. package/src/components/fiscal/index.ts +4 -0
  64. package/src/components/index.ts +2 -0
  65. package/src/components/navigations/Breadcrumb.tsx +4 -4
  66. package/src/components/navigations/RecentPagesNavigator.tsx +3 -3
  67. package/src/features/company/components/details/CompanyContent.tsx +105 -0
  68. package/src/features/company/components/details/CompanyDetails.tsx +2 -19
  69. package/src/features/company/components/details/index.ts +1 -0
  70. package/src/features/company/components/forms/CompanyConfigurationEditor.tsx +38 -70
  71. package/src/features/company/components/forms/CompanyEditor.tsx +214 -172
  72. package/src/features/company/data/company.interface.ts +20 -0
  73. package/src/features/company/data/company.ts +73 -0
  74. package/src/utils/fiscal-utils.ts +7 -0
  75. package/src/utils/italian-validators.ts +79 -0
  76. package/dist/chunk-5ODPC3YX.js.map +0 -1
  77. package/dist/chunk-LRXJT656.js.map +0 -1
  78. package/dist/chunk-OLNMWVOV.mjs.map +0 -1
  79. /package/dist/{BlockNoteEditor-SCQGD6F2.mjs.map → BlockNoteEditor-KCJMA6LW.mjs.map} +0 -0
  80. /package/dist/{chunk-5KMKI23S.mjs.map → chunk-UXGPZZ6V.mjs.map} +0 -0
@@ -18,6 +18,17 @@ export class Company extends AbstractApiData implements CompanyInterface {
18
18
  private _features?: FeatureInterface[];
19
19
  private _modules?: ModuleInterface[];
20
20
 
21
+ private _legal_address?: string;
22
+ private _street_number?: string;
23
+ private _street?: string;
24
+ private _city?: string;
25
+ private _province?: string;
26
+ private _region?: string;
27
+ private _postcode?: string;
28
+ private _country?: string;
29
+ private _country_code?: string;
30
+ private _fiscal_data?: string;
31
+
21
32
  get name(): string {
22
33
  if (this._name === undefined) throw new Error("Name is not defined");
23
34
  return this._name;
@@ -59,6 +70,46 @@ export class Company extends AbstractApiData implements CompanyInterface {
59
70
  return this._configurations;
60
71
  }
61
72
 
73
+ get legal_address(): string | undefined {
74
+ return this._legal_address;
75
+ }
76
+
77
+ get street_number(): string | undefined {
78
+ return this._street_number;
79
+ }
80
+
81
+ get street(): string | undefined {
82
+ return this._street;
83
+ }
84
+
85
+ get city(): string | undefined {
86
+ return this._city;
87
+ }
88
+
89
+ get province(): string | undefined {
90
+ return this._province;
91
+ }
92
+
93
+ get region(): string | undefined {
94
+ return this._region;
95
+ }
96
+
97
+ get postcode(): string | undefined {
98
+ return this._postcode;
99
+ }
100
+
101
+ get country(): string | undefined {
102
+ return this._country;
103
+ }
104
+
105
+ get country_code(): string | undefined {
106
+ return this._country_code;
107
+ }
108
+
109
+ get fiscal_data(): string | undefined {
110
+ return this._fiscal_data;
111
+ }
112
+
62
113
  rehydrate(data: JsonApiHydratedDataInterface): this {
63
114
  super.rehydrate(data);
64
115
 
@@ -73,6 +124,17 @@ export class Company extends AbstractApiData implements CompanyInterface {
73
124
  this._availableMonthlyTokens = data.jsonApi.attributes.availableMonthlyTokens ?? 0;
74
125
  this._availableExtraTokens = data.jsonApi.attributes.availableExtraTokens ?? 0;
75
126
 
127
+ this._legal_address = data.jsonApi.attributes.legal_address;
128
+ this._street_number = data.jsonApi.attributes.street_number;
129
+ this._street = data.jsonApi.attributes.street;
130
+ this._city = data.jsonApi.attributes.city;
131
+ this._province = data.jsonApi.attributes.province;
132
+ this._region = data.jsonApi.attributes.region;
133
+ this._postcode = data.jsonApi.attributes.postcode;
134
+ this._country = data.jsonApi.attributes.country;
135
+ this._country_code = data.jsonApi.attributes.country_code;
136
+ this._fiscal_data = data.jsonApi.attributes.fiscal_data;
137
+
76
138
  this._features = this._readIncluded<FeatureInterface>(data, "features", Modules.Feature) as FeatureInterface[];
77
139
  this._modules = this._readIncluded<ModuleInterface>(data, "modules", Modules.Module) as ModuleInterface[];
78
140
 
@@ -100,6 +162,17 @@ export class Company extends AbstractApiData implements CompanyInterface {
100
162
  if (data.availableExtraTokens !== undefined)
101
163
  response.data.attributes.availableExtraTokens = data.availableExtraTokens;
102
164
 
165
+ if (data.legal_address !== undefined) response.data.attributes.legal_address = data.legal_address;
166
+ if (data.street_number !== undefined) response.data.attributes.street_number = data.street_number;
167
+ if (data.street !== undefined) response.data.attributes.street = data.street;
168
+ if (data.city !== undefined) response.data.attributes.city = data.city;
169
+ if (data.province !== undefined) response.data.attributes.province = data.province;
170
+ if (data.region !== undefined) response.data.attributes.region = data.region;
171
+ if (data.postcode !== undefined) response.data.attributes.postcode = data.postcode;
172
+ if (data.country !== undefined) response.data.attributes.country = data.country;
173
+ if (data.country_code !== undefined) response.data.attributes.country_code = data.country_code;
174
+ if (data.fiscal_data !== undefined) response.data.attributes.fiscal_data = data.fiscal_data;
175
+
103
176
  if (data.featureIds && data.featureIds.length > 0) {
104
177
  response.data.relationships.features = {
105
178
  data: data.featureIds.map((featureId) => ({
@@ -0,0 +1,7 @@
1
+ export function parseFiscalData(fiscalDataJson?: string): Record<string, string> {
2
+ try {
3
+ return fiscalDataJson ? JSON.parse(fiscalDataJson) : {};
4
+ } catch {
5
+ return {};
6
+ }
7
+ }
@@ -0,0 +1,79 @@
1
+ import CodiceFiscale from "codice-fiscale-js";
2
+
3
+ export function validatePartitaIva(partitaIva: string): boolean {
4
+ if (!partitaIva || typeof partitaIva !== "string") {
5
+ return false;
6
+ }
7
+
8
+ const cleaned = partitaIva.replace(/\s/g, "");
9
+
10
+ if (!/^\d{11}$/.test(cleaned)) {
11
+ return false;
12
+ }
13
+
14
+ const digits = cleaned.split("").map(Number);
15
+
16
+ const oddSum = digits[0] + digits[2] + digits[4] + digits[6] + digits[8] + digits[10];
17
+
18
+ let evenSum = 0;
19
+ for (let i = 1; i < 10; i += 2) {
20
+ let doubled = digits[i] * 2;
21
+ if (doubled > 9) {
22
+ doubled -= 9;
23
+ }
24
+ evenSum += doubled;
25
+ }
26
+
27
+ const totalSum = oddSum + evenSum;
28
+
29
+ return totalSum % 10 === 0;
30
+ }
31
+
32
+ export function validateCodiceFiscale(codiceFiscale: string): boolean {
33
+ if (!codiceFiscale || typeof codiceFiscale !== "string") {
34
+ return false;
35
+ }
36
+
37
+ const cleaned = codiceFiscale.replace(/\s/g, "").toUpperCase();
38
+
39
+ try {
40
+ return CodiceFiscale.check(cleaned);
41
+ } catch (error) {
42
+ return false;
43
+ }
44
+ }
45
+
46
+ export function validateItalianTaxCode(value: string, type: "partitaIva" | "codiceFiscale"): boolean {
47
+ if (!value || typeof value !== "string") {
48
+ return false;
49
+ }
50
+
51
+ switch (type) {
52
+ case "partitaIva":
53
+ return validatePartitaIva(value);
54
+ case "codiceFiscale":
55
+ return validateCodiceFiscale(value);
56
+ default:
57
+ return false;
58
+ }
59
+ }
60
+
61
+ export function formatPartitaIva(partitaIva: string): string {
62
+ if (!partitaIva) return "";
63
+
64
+ const cleaned = partitaIva.replace(/\s/g, "");
65
+ if (/^\d{11}$/.test(cleaned)) {
66
+ return `${cleaned.substring(0, 7)} ${cleaned.substring(7, 10)} ${cleaned.substring(10)}`;
67
+ }
68
+ return partitaIva;
69
+ }
70
+
71
+ export function formatCodiceFiscale(codiceFiscale: string): string {
72
+ if (!codiceFiscale) return "";
73
+
74
+ const cleaned = codiceFiscale.replace(/\s/g, "").toUpperCase();
75
+ if (/^[A-Z0-9]{16}$/.test(cleaned)) {
76
+ return `${cleaned.substring(0, 6)} ${cleaned.substring(6, 11)} ${cleaned.substring(11, 15)} ${cleaned.substring(15)}`;
77
+ }
78
+ return codiceFiscale;
79
+ }