@eventlook/sdk 1.4.20 → 1.4.24

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.
@@ -13,19 +13,39 @@ const TicketSelectionMap = ({ event }) => {
13
13
  const { setValue } = reactHookForm.useFormContext();
14
14
  const onSelect = (seats) => {
15
15
  const tickets = [];
16
- for (const seat of seats) {
16
+ const groupedSeatsByZone = seats.reduce((tickets, seat) => {
17
+ const zoneIndex = tickets.findIndex((ticket) => ticket.seat.type === seat.locationType);
18
+ if (zoneIndex !== -1) {
19
+ tickets[zoneIndex].quantity += 1;
20
+ }
21
+ else {
22
+ tickets.push({
23
+ seat: {
24
+ id: seat.locationId,
25
+ type: seat.locationType,
26
+ locationDescription: seat.locationTypeDescription,
27
+ },
28
+ quantity: 1,
29
+ ticket: seat.ticket,
30
+ });
31
+ }
32
+ return tickets;
33
+ },
34
+ // TODO: fix types
35
+ []);
36
+ for (const groupedSeat of groupedSeatsByZone) {
17
37
  tickets.push({
18
- releaseId: seat.ticket.id,
19
- price: seat.ticket.price,
20
- quantity: 1,
21
- itemName: `${seat.ticket.releaseCategoryName} - ${seat.ticket.name}`,
38
+ releaseId: groupedSeat.ticket.id,
39
+ price: groupedSeat.ticket.price,
40
+ quantity: groupedSeat.quantity,
41
+ itemName: `${groupedSeat.ticket.releaseCategoryName} - ${groupedSeat.ticket.name}`,
22
42
  products: [],
23
43
  extraFields: [],
24
44
  location: {
25
- id: seat.locationId || '',
45
+ id: groupedSeat.seat.id,
26
46
  type: 'zone',
27
- locationDescription: seat.locationTypeDescription,
28
- }
47
+ locationDescription: groupedSeat.seat.locationDescription,
48
+ },
29
49
  });
30
50
  }
31
51
  setValue(`tickets.${event.id}`, tickets);
@@ -1 +1 @@
1
- {"version":3,"file":"TicketSelectionMap.js","sources":["../../../src/form/TicketSelectionMap.tsx"],"sourcesContent":["import React from 'react';\nimport useGlobal from '@hooks/useGlobal.ts';\nimport { IEvent } from '@utils/types/event.type.ts';\nimport { Button } from '@mui/material';\nimport { iframe, TicketSelection } from '@seat-picker/seat-picker-sdk';\nimport { useFormContext } from 'react-hook-form';\nimport { ITicketForm, ITicketFormTicket } from '@utils/types/ticket.type.ts';\n\ninterface Props {\n event: IEvent;\n}\n\nconst TicketSelectionMap: React.FC<Props> = ({ event }) => {\n const { t, seatingIframeUrl } = useGlobal();\n const { setValue } = useFormContext<ITicketForm>();\n\n const onSelect = (seats: TicketSelection) => {\n const tickets: ITicketFormTicket[] = [];\n for(const seat of seats) {\n tickets.push({\n releaseId: seat.ticket.id,\n price: seat.ticket.price,\n quantity: 1,\n itemName: `${seat.ticket.releaseCategoryName} - ${seat.ticket.name}`,\n products: [],\n extraFields: [],\n location: {\n id: seat.locationId || '',\n type: 'zone',\n locationDescription: seat.locationTypeDescription,\n }\n })\n }\n\n setValue(`tickets.${event.id}`, tickets);\n };\n\n if (!seatingIframeUrl) return null;\n\n return (\n <Button\n variant=\"contained\"\n onClick={() =>\n iframe.openPicker({\n eventId: String(event.id),\n onSelect,\n baseUrl: seatingIframeUrl,\n })\n }\n >\n {t('form.labels.open_map')}\n </Button>\n );\n};\n\nexport default TicketSelectionMap;\n"],"names":["useGlobal","useFormContext","Button","iframe"],"mappings":";;;;;;;;;;AAYA,MAAM,kBAAkB,GAAoB,CAAC,EAAE,KAAK,EAAE,KAAI;IACxD,MAAM,EAAE,CAAC,EAAE,gBAAgB,EAAE,GAAGA,iBAAS,EAAE;AAC3C,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAGC,4BAAc,EAAe;AAElD,IAAA,MAAM,QAAQ,GAAG,CAAC,KAAsB,KAAI;QAC1C,MAAM,OAAO,GAAwB,EAAE;AACvC,QAAA,KAAI,MAAM,IAAI,IAAI,KAAK,EAAE;YACvB,OAAO,CAAC,IAAI,CAAC;AACX,gBAAA,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE;AACzB,gBAAA,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;AACxB,gBAAA,QAAQ,EAAE,CAAC;AACX,gBAAA,QAAQ,EAAE,CAAA,EAAG,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAA,GAAA,EAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAA,CAAE;AACpE,gBAAA,QAAQ,EAAE,EAAE;AACZ,gBAAA,WAAW,EAAE,EAAE;AACf,gBAAA,QAAQ,EAAE;AACR,oBAAA,EAAE,EAAE,IAAI,CAAC,UAAU,IAAI,EAAE;AACzB,oBAAA,IAAI,EAAE,MAAM;oBACZ,mBAAmB,EAAE,IAAI,CAAC,uBAAuB;AAClD;AACF,aAAA,CAAC;;QAGJ,QAAQ,CAAC,WAAW,KAAK,CAAC,EAAE,CAAA,CAAE,EAAE,OAAO,CAAC;AAC1C,KAAC;AAED,IAAA,IAAI,CAAC,gBAAgB;AAAE,QAAA,OAAO,IAAI;AAElC,IAAA,QACE,KAAA,CAAA,aAAA,CAACC,eAAM,EAAA,EACL,OAAO,EAAC,WAAW,EACnB,OAAO,EAAE,MACPC,oBAAM,CAAC,UAAU,CAAC;AAChB,YAAA,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,QAAQ;AACR,YAAA,OAAO,EAAE,gBAAgB;AAC1B,SAAA,CAAC,IAGH,CAAC,CAAC,sBAAsB,CAAC,CACnB;AAEb;;;;"}
1
+ {"version":3,"file":"TicketSelectionMap.js","sources":["../../../src/form/TicketSelectionMap.tsx"],"sourcesContent":["import React from 'react';\nimport useGlobal from '@hooks/useGlobal.ts';\nimport { IEvent } from '@utils/types/event.type.ts';\nimport { Button } from '@mui/material';\nimport { iframe, TicketSelection } from '@seat-picker/seat-picker-sdk';\nimport { useFormContext } from 'react-hook-form';\nimport { ITicketForm, ITicketFormTicket, ITicketLocation } from '@utils/types/ticket.type.ts';\n\ninterface Props {\n event: IEvent;\n}\n\nconst TicketSelectionMap: React.FC<Props> = ({ event }) => {\n const { t, seatingIframeUrl } = useGlobal();\n const { setValue } = useFormContext<ITicketForm>();\n\n const onSelect = (seats: TicketSelection) => {\n const tickets: ITicketFormTicket[] = [];\n const groupedSeatsByZone = seats.reduce(\n (tickets, seat) => {\n const zoneIndex = tickets.findIndex((ticket) => ticket.seat.type === seat.locationType);\n if (zoneIndex !== -1) {\n tickets[zoneIndex].quantity += 1;\n } else {\n tickets.push({\n seat: {\n id: seat.locationId,\n type: seat.locationType,\n locationDescription: seat.locationTypeDescription,\n },\n quantity: 1,\n ticket: seat.ticket,\n });\n }\n\n return tickets;\n },\n // TODO: fix types\n [] as { quantity: number; seat: ITicketLocation; ticket: any }[]\n );\n\n for (const groupedSeat of groupedSeatsByZone) {\n tickets.push({\n releaseId: groupedSeat.ticket.id,\n price: groupedSeat.ticket.price,\n quantity: groupedSeat.quantity,\n itemName: `${groupedSeat.ticket.releaseCategoryName} - ${groupedSeat.ticket.name}`,\n products: [],\n extraFields: [],\n location: {\n id: groupedSeat.seat.id,\n type: 'zone',\n locationDescription: groupedSeat.seat.locationDescription,\n },\n });\n }\n\n setValue(`tickets.${event.id}`, tickets);\n };\n\n if (!seatingIframeUrl) return null;\n\n return (\n <Button\n variant=\"contained\"\n onClick={() =>\n iframe.openPicker({\n eventId: String(event.id),\n onSelect,\n baseUrl: seatingIframeUrl,\n })\n }\n >\n {t('form.labels.open_map')}\n </Button>\n );\n};\n\nexport default TicketSelectionMap;\n"],"names":["useGlobal","useFormContext","Button","iframe"],"mappings":";;;;;;;;;;AAYA,MAAM,kBAAkB,GAAoB,CAAC,EAAE,KAAK,EAAE,KAAI;IACxD,MAAM,EAAE,CAAC,EAAE,gBAAgB,EAAE,GAAGA,iBAAS,EAAE;AAC3C,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAGC,4BAAc,EAAe;AAElD,IAAA,MAAM,QAAQ,GAAG,CAAC,KAAsB,KAAI;QAC1C,MAAM,OAAO,GAAwB,EAAE;QACvC,MAAM,kBAAkB,GAAG,KAAK,CAAC,MAAM,CACrC,CAAC,OAAO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CAAC,WAAW,KAAK,CAAC,EAAE,CAAA,CAAE,EAAE,OAAO,CAAC;AAC1C,KAAC;AAED,IAAA,IAAI,CAAC,gBAAgB;AAAE,QAAA,OAAO,IAAI;AAElC,IAAA,QACE,KAAA,CAAA,aAAA,CAACC,eAAM,EAAA,EACL,OAAO,EAAC,WAAW,EACnB,OAAO,EAAE,MACPC,oBAAM,CAAC,UAAU,CAAC;AAChB,YAAA,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,QAAQ;AACR,YAAA,OAAO,EAAE,gBAAgB;AAC1B,SAAA,CAAC,IAGH,CAAC,CAAC,sBAAsB,CAAC,CACnB;AAEb;;;;"}
@@ -9,19 +9,39 @@ const TicketSelectionMap = ({ event }) => {
9
9
  const { setValue } = useFormContext();
10
10
  const onSelect = (seats) => {
11
11
  const tickets = [];
12
- for (const seat of seats) {
12
+ const groupedSeatsByZone = seats.reduce((tickets, seat) => {
13
+ const zoneIndex = tickets.findIndex((ticket) => ticket.seat.type === seat.locationType);
14
+ if (zoneIndex !== -1) {
15
+ tickets[zoneIndex].quantity += 1;
16
+ }
17
+ else {
18
+ tickets.push({
19
+ seat: {
20
+ id: seat.locationId,
21
+ type: seat.locationType,
22
+ locationDescription: seat.locationTypeDescription,
23
+ },
24
+ quantity: 1,
25
+ ticket: seat.ticket,
26
+ });
27
+ }
28
+ return tickets;
29
+ },
30
+ // TODO: fix types
31
+ []);
32
+ for (const groupedSeat of groupedSeatsByZone) {
13
33
  tickets.push({
14
- releaseId: seat.ticket.id,
15
- price: seat.ticket.price,
16
- quantity: 1,
17
- itemName: `${seat.ticket.releaseCategoryName} - ${seat.ticket.name}`,
34
+ releaseId: groupedSeat.ticket.id,
35
+ price: groupedSeat.ticket.price,
36
+ quantity: groupedSeat.quantity,
37
+ itemName: `${groupedSeat.ticket.releaseCategoryName} - ${groupedSeat.ticket.name}`,
18
38
  products: [],
19
39
  extraFields: [],
20
40
  location: {
21
- id: seat.locationId || '',
41
+ id: groupedSeat.seat.id,
22
42
  type: 'zone',
23
- locationDescription: seat.locationTypeDescription,
24
- }
43
+ locationDescription: groupedSeat.seat.locationDescription,
44
+ },
25
45
  });
26
46
  }
27
47
  setValue(`tickets.${event.id}`, tickets);
@@ -1 +1 @@
1
- {"version":3,"file":"TicketSelectionMap.js","sources":["../../../src/form/TicketSelectionMap.tsx"],"sourcesContent":["import React from 'react';\nimport useGlobal from '@hooks/useGlobal.ts';\nimport { IEvent } from '@utils/types/event.type.ts';\nimport { Button } from '@mui/material';\nimport { iframe, TicketSelection } from '@seat-picker/seat-picker-sdk';\nimport { useFormContext } from 'react-hook-form';\nimport { ITicketForm, ITicketFormTicket } from '@utils/types/ticket.type.ts';\n\ninterface Props {\n event: IEvent;\n}\n\nconst TicketSelectionMap: React.FC<Props> = ({ event }) => {\n const { t, seatingIframeUrl } = useGlobal();\n const { setValue } = useFormContext<ITicketForm>();\n\n const onSelect = (seats: TicketSelection) => {\n const tickets: ITicketFormTicket[] = [];\n for(const seat of seats) {\n tickets.push({\n releaseId: seat.ticket.id,\n price: seat.ticket.price,\n quantity: 1,\n itemName: `${seat.ticket.releaseCategoryName} - ${seat.ticket.name}`,\n products: [],\n extraFields: [],\n location: {\n id: seat.locationId || '',\n type: 'zone',\n locationDescription: seat.locationTypeDescription,\n }\n })\n }\n\n setValue(`tickets.${event.id}`, tickets);\n };\n\n if (!seatingIframeUrl) return null;\n\n return (\n <Button\n variant=\"contained\"\n onClick={() =>\n iframe.openPicker({\n eventId: String(event.id),\n onSelect,\n baseUrl: seatingIframeUrl,\n })\n }\n >\n {t('form.labels.open_map')}\n </Button>\n );\n};\n\nexport default TicketSelectionMap;\n"],"names":[],"mappings":";;;;;;AAYA,MAAM,kBAAkB,GAAoB,CAAC,EAAE,KAAK,EAAE,KAAI;IACxD,MAAM,EAAE,CAAC,EAAE,gBAAgB,EAAE,GAAG,SAAS,EAAE;AAC3C,IAAA,MAAM,EAAE,QAAQ,EAAE,GAAG,cAAc,EAAe;AAElD,IAAA,MAAM,QAAQ,GAAG,CAAC,KAAsB,KAAI;QAC1C,MAAM,OAAO,GAAwB,EAAE;AACvC,QAAA,KAAI,MAAM,IAAI,IAAI,KAAK,EAAE;YACvB,OAAO,CAAC,IAAI,CAAC;AACX,gBAAA,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE;AACzB,gBAAA,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,KAAK;AACxB,gBAAA,QAAQ,EAAE,CAAC;AACX,gBAAA,QAAQ,EAAE,CAAA,EAAG,IAAI,CAAC,MAAM,CAAC,mBAAmB,CAAA,GAAA,EAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAA,CAAE;AACpE,gBAAA,QAAQ,EAAE,EAAE;AACZ,gBAAA,WAAW,EAAE,EAAE;AACf,gBAAA,QAAQ,EAAE;AACR,oBAAA,EAAE,EAAE,IAAI,CAAC,UAAU,IAAI,EAAE;AACzB,oBAAA,IAAI,EAAE,MAAM;oBACZ,mBAAmB,EAAE,IAAI,CAAC,uBAAuB;AAClD;AACF,aAAA,CAAC;;QAGJ,QAAQ,CAAC,WAAW,KAAK,CAAC,EAAE,CAAA,CAAE,EAAE,OAAO,CAAC;AAC1C,KAAC;AAED,IAAA,IAAI,CAAC,gBAAgB;AAAE,QAAA,OAAO,IAAI;AAElC,IAAA,QACE,KAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EACL,OAAO,EAAC,WAAW,EACnB,OAAO,EAAE,MACP,MAAM,CAAC,UAAU,CAAC;AAChB,YAAA,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,QAAQ;AACR,YAAA,OAAO,EAAE,gBAAgB;AAC1B,SAAA,CAAC,IAGH,CAAC,CAAC,sBAAsB,CAAC,CACnB;AAEb;;;;"}
1
+ {"version":3,"file":"TicketSelectionMap.js","sources":["../../../src/form/TicketSelectionMap.tsx"],"sourcesContent":["import React from 'react';\nimport useGlobal from '@hooks/useGlobal.ts';\nimport { IEvent } from '@utils/types/event.type.ts';\nimport { Button } from '@mui/material';\nimport { iframe, TicketSelection } from '@seat-picker/seat-picker-sdk';\nimport { useFormContext } from 'react-hook-form';\nimport { ITicketForm, ITicketFormTicket, ITicketLocation } from '@utils/types/ticket.type.ts';\n\ninterface Props {\n event: IEvent;\n}\n\nconst TicketSelectionMap: React.FC<Props> = ({ event }) => {\n const { t, seatingIframeUrl } = useGlobal();\n const { setValue } = useFormContext<ITicketForm>();\n\n const onSelect = (seats: TicketSelection) => {\n const tickets: ITicketFormTicket[] = [];\n const groupedSeatsByZone = seats.reduce(\n (tickets, seat) => {\n const zoneIndex = tickets.findIndex((ticket) => ticket.seat.type === seat.locationType);\n if (zoneIndex !== -1) {\n tickets[zoneIndex].quantity += 1;\n } else {\n tickets.push({\n seat: {\n id: seat.locationId,\n type: seat.locationType,\n locationDescription: seat.locationTypeDescription,\n },\n quantity: 1,\n ticket: seat.ticket,\n });\n }\n\n return tickets;\n },\n // TODO: fix types\n [] as { quantity: number; seat: ITicketLocation; ticket: any }[]\n );\n\n for (const groupedSeat of groupedSeatsByZone) {\n tickets.push({\n releaseId: groupedSeat.ticket.id,\n price: groupedSeat.ticket.price,\n quantity: groupedSeat.quantity,\n itemName: `${groupedSeat.ticket.releaseCategoryName} - ${groupedSeat.ticket.name}`,\n products: [],\n extraFields: [],\n location: {\n id: groupedSeat.seat.id,\n type: 'zone',\n locationDescription: groupedSeat.seat.locationDescription,\n },\n });\n }\n\n setValue(`tickets.${event.id}`, tickets);\n };\n\n if (!seatingIframeUrl) return null;\n\n return (\n <Button\n variant=\"contained\"\n onClick={() =>\n iframe.openPicker({\n eventId: String(event.id),\n onSelect,\n baseUrl: seatingIframeUrl,\n })\n }\n >\n {t('form.labels.open_map')}\n </Button>\n );\n};\n\nexport default TicketSelectionMap;\n"],"names":[],"mappings":";;;;;;AAYA,MAAM,kBAAkB,GAAoB,CAAC,EAAE,KAAK,EAAE,KAAI;IACxD,MAAM,EAAE,CAA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BAAA,WAAW,EAAE,EAAE;AACf,gBAAA,QAAQ,EAAE;AACR,oBAAA,EAAE,EAAE,WAAW,CAAC,IAAI,CAAC,EAAE;AACvB,oBAAA,IAAI,EAAE,MAAM;AACZ,oBAAA,mBAAmB,EAAE,WAAW,CAAC,IAAI,CAAC,mBAAmB;AAC1D,iBAAA;AACF,aAAA,CAAC;;QAGJ,QAAQ,CAAC,WAAW,KAAK,CAAC,EAAE,CAAA,CAAE,EAAE,OAAO,CAAC;AAC1C,KAAC;AAED,IAAA,IAAI,CAAC,gBAAgB;AAAE,QAAA,OAAO,IAAI;AAElC,IAAA,QACE,KAAA,CAAA,aAAA,CAAC,MAAM,EAAA,EACL,OAAO,EAAC,WAAW,EACnB,OAAO,EAAE,MACP,MAAM,CAAC,UAAU,CAAC;AAChB,YAAA,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;YACzB,QAAQ;AACR,YAAA,OAAO,EAAE,gBAAgB;AAC1B,SAAA,CAAC,IAGH,CAAC,CAAC,sBAAsB,CAAC,CACnB;AAEb;;;;"}
@@ -35,7 +35,7 @@ export interface ITicketFormTicket {
35
35
  }
36
36
  export interface ITicketLocation {
37
37
  id: string;
38
- type: string;
38
+ type: LocationType;
39
39
  locationDescription?: {
40
40
  type: BaseLocationDescriptionType | 'custom';
41
41
  label: string;
@@ -43,6 +43,7 @@ export interface ITicketLocation {
43
43
  }[] | null;
44
44
  }
45
45
  type BaseLocationDescriptionType = 'seatNumber' | 'rowNumber' | 'sectionName';
46
+ type LocationType = 'seat' | 'zone';
46
47
  export type EventTicketsType = {
47
48
  [eventId: string]: ITicketFormTicket[];
48
49
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eventlook/sdk",
3
- "version": "1.4.20",
3
+ "version": "1.4.24",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -4,7 +4,7 @@ import { IEvent } from '@utils/types/event.type.ts';
4
4
  import { Button } from '@mui/material';
5
5
  import { iframe, TicketSelection } from '@seat-picker/seat-picker-sdk';
6
6
  import { useFormContext } from 'react-hook-form';
7
- import { ITicketForm, ITicketFormTicket } from '@utils/types/ticket.type.ts';
7
+ import { ITicketForm, ITicketFormTicket, ITicketLocation } from '@utils/types/ticket.type.ts';
8
8
 
9
9
  interface Props {
10
10
  event: IEvent;
@@ -16,20 +16,43 @@ const TicketSelectionMap: React.FC<Props> = ({ event }) => {
16
16
 
17
17
  const onSelect = (seats: TicketSelection) => {
18
18
  const tickets: ITicketFormTicket[] = [];
19
- for(const seat of seats) {
19
+ const groupedSeatsByZone = seats.reduce(
20
+ (tickets, seat) => {
21
+ const zoneIndex = tickets.findIndex((ticket) => ticket.seat.type === seat.locationType);
22
+ if (zoneIndex !== -1) {
23
+ tickets[zoneIndex].quantity += 1;
24
+ } else {
25
+ tickets.push({
26
+ seat: {
27
+ id: seat.locationId,
28
+ type: seat.locationType,
29
+ locationDescription: seat.locationTypeDescription,
30
+ },
31
+ quantity: 1,
32
+ ticket: seat.ticket,
33
+ });
34
+ }
35
+
36
+ return tickets;
37
+ },
38
+ // TODO: fix types
39
+ [] as { quantity: number; seat: ITicketLocation; ticket: any }[]
40
+ );
41
+
42
+ for (const groupedSeat of groupedSeatsByZone) {
20
43
  tickets.push({
21
- releaseId: seat.ticket.id,
22
- price: seat.ticket.price,
23
- quantity: 1,
24
- itemName: `${seat.ticket.releaseCategoryName} - ${seat.ticket.name}`,
44
+ releaseId: groupedSeat.ticket.id,
45
+ price: groupedSeat.ticket.price,
46
+ quantity: groupedSeat.quantity,
47
+ itemName: `${groupedSeat.ticket.releaseCategoryName} - ${groupedSeat.ticket.name}`,
25
48
  products: [],
26
49
  extraFields: [],
27
50
  location: {
28
- id: seat.locationId || '',
51
+ id: groupedSeat.seat.id,
29
52
  type: 'zone',
30
- locationDescription: seat.locationTypeDescription,
31
- }
32
- })
53
+ locationDescription: groupedSeat.seat.locationDescription,
54
+ },
55
+ });
33
56
  }
34
57
 
35
58
  setValue(`tickets.${event.id}`, tickets);
@@ -38,16 +38,20 @@ export interface ITicketFormTicket {
38
38
 
39
39
  export interface ITicketLocation {
40
40
  id: string;
41
- type: string;
42
- locationDescription?: {
43
- type: BaseLocationDescriptionType | 'custom';
44
- label: string;
45
- value: string;
46
- }[] | null;
41
+ type: LocationType;
42
+ locationDescription?:
43
+ | {
44
+ type: BaseLocationDescriptionType | 'custom';
45
+ label: string;
46
+ value: string;
47
+ }[]
48
+ | null;
47
49
  }
48
50
 
49
51
  type BaseLocationDescriptionType = 'seatNumber' | 'rowNumber' | 'sectionName';
50
52
 
53
+ type LocationType = 'seat' | 'zone';
54
+
51
55
  export type EventTicketsType = { [eventId: string]: ITicketFormTicket[] };
52
56
 
53
57
  export interface ITicketForm {