@agendar/shared 0.4.0 → 0.6.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 (40) hide show
  1. package/dist/{chunk-DIBRYKLY.js → chunk-6MEQXAPW.js} +550 -14
  2. package/dist/chunk-6MEQXAPW.js.map +1 -0
  3. package/dist/{chunk-AIMCPYP2.js → chunk-NGCGPQ4L.js} +550 -14
  4. package/dist/chunk-NGCGPQ4L.js.map +1 -0
  5. package/dist/{chunk-2GJXS5AI.js → chunk-Y2LPIEBZ.js} +550 -14
  6. package/dist/chunk-Y2LPIEBZ.js.map +1 -0
  7. package/dist/i18n/en.cjs +548 -12
  8. package/dist/i18n/en.cjs.map +1 -1
  9. package/dist/i18n/en.d.cts +545 -9
  10. package/dist/i18n/en.d.ts +545 -9
  11. package/dist/i18n/en.js +1 -1
  12. package/dist/i18n/es.cjs +548 -12
  13. package/dist/i18n/es.cjs.map +1 -1
  14. package/dist/i18n/es.d.cts +545 -9
  15. package/dist/i18n/es.d.ts +545 -9
  16. package/dist/i18n/es.js +1 -1
  17. package/dist/i18n/index.cjs +1644 -36
  18. package/dist/i18n/index.cjs.map +1 -1
  19. package/dist/i18n/index.js +3 -3
  20. package/dist/i18n/pt.cjs +548 -12
  21. package/dist/i18n/pt.cjs.map +1 -1
  22. package/dist/i18n/pt.d.cts +545 -9
  23. package/dist/i18n/pt.d.ts +545 -9
  24. package/dist/i18n/pt.js +1 -1
  25. package/dist/schemas/absence-form.cjs +2 -1
  26. package/dist/schemas/absence-form.cjs.map +1 -1
  27. package/dist/schemas/absence-form.d.cts +3 -0
  28. package/dist/schemas/absence-form.d.ts +3 -0
  29. package/dist/schemas/absence-form.js +2 -1
  30. package/dist/schemas/absence-form.js.map +1 -1
  31. package/dist/utils/appointments.cjs +1 -1
  32. package/dist/utils/appointments.cjs.map +1 -1
  33. package/dist/utils/appointments.d.cts +2 -0
  34. package/dist/utils/appointments.d.ts +2 -0
  35. package/dist/utils/appointments.js +1 -1
  36. package/dist/utils/appointments.js.map +1 -1
  37. package/package.json +1 -1
  38. package/dist/chunk-2GJXS5AI.js.map +0 -1
  39. package/dist/chunk-AIMCPYP2.js.map +0 -1
  40. package/dist/chunk-DIBRYKLY.js.map +0 -1
@@ -12,7 +12,8 @@ var DEFAULT_ABSENCE_FORM_MESSAGES = {
12
12
  var absenceTypeSchema = zod.z.enum([
13
13
  "temporary_leave",
14
14
  "missed_shift",
15
- "vacation"
15
+ "vacation",
16
+ "day_off"
16
17
  ]);
17
18
  var createAbsenceFormSchema = (messages = {}) => {
18
19
  const resolved = { ...DEFAULT_ABSENCE_FORM_MESSAGES, ...messages };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/schemas/absence-form.ts"],"names":["z"],"mappings":";;;;;AASA,IAAM,6BAAA,GAA2D;AAAA,EAC/D,oBAAA,EAAsB,2CAAA;AAAA,EACtB,iBAAA,EAAmB,wCAAA;AAAA,EACnB,eAAA,EAAiB,sCAAA;AAAA,EACjB,sBAAA,EAAwB;AAC1B,CAAA;AAEO,IAAM,iBAAA,GAAoBA,MAAE,IAAA,CAAK;AAAA,EACtC,iBAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,uBAAA,GAA0B,CACrC,QAAA,GAA+C,EAAC,KAC7C;AACH,EAAA,MAAM,QAAA,GAAW,EAAE,GAAG,6BAAA,EAA+B,GAAG,QAAA,EAAS;AAEjE,EAAA,OAAOA,MACJ,MAAA,CAAO;AAAA,IACN,eAAA,EAAiBA,MACd,MAAA,EAAO,CACP,KAAI,CACJ,QAAA,CAAS,SAAS,oBAAoB,CAAA;AAAA,IACzC,IAAA,EAAM,iBAAA;AAAA,IACN,YAAYA,KAAA,CAAE,MAAA,GAAS,GAAA,CAAI,CAAA,EAAG,SAAS,iBAAiB,CAAA;AAAA,IACxD,UAAUA,KAAA,CAAE,MAAA,GAAS,GAAA,CAAI,CAAA,EAAG,SAAS,eAAe,CAAA;AAAA,IACpD,MAAA,EAAQA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA,CAAI,GAAI,CAAA,CAAE,QAAA,EAAS,CAAE,EAAA,CAAGA,KAAA,CAAE,OAAA,CAAQ,EAAE,CAAC;AAAA,GACzD,EACA,MAAA,CAAO,CAAC,SAAS,IAAA,CAAK,QAAA,IAAY,KAAK,UAAA,EAAY;AAAA,IAClD,SAAS,QAAA,CAAS,sBAAA;AAAA,IAClB,IAAA,EAAM,CAAC,UAAU;AAAA,GAClB,CAAA;AACL;AAEO,IAAM,oBAAoB,uBAAA","file":"absence-form.cjs","sourcesContent":["import { z } from \"zod\";\n\nexport interface AbsenceFormSchemaMessages {\n professionalRequired: string;\n startDateRequired: string;\n endDateRequired: string;\n endDateBeforeStartDate: string;\n}\n\nconst DEFAULT_ABSENCE_FORM_MESSAGES: AbsenceFormSchemaMessages = {\n professionalRequired: \"absences.validation.professional.required\",\n startDateRequired: \"absences.validation.startDate.required\",\n endDateRequired: \"absences.validation.endDate.required\",\n endDateBeforeStartDate: \"absences.validation.endDate.beforeStartDate\",\n};\n\nexport const absenceTypeSchema = z.enum([\n \"temporary_leave\",\n \"missed_shift\",\n \"vacation\",\n]);\n\nexport const createAbsenceFormSchema = (\n messages: Partial<AbsenceFormSchemaMessages> = {},\n) => {\n const resolved = { ...DEFAULT_ABSENCE_FORM_MESSAGES, ...messages };\n\n return z\n .object({\n professional_id: z\n .number()\n .int()\n .positive(resolved.professionalRequired),\n type: absenceTypeSchema,\n start_date: z.string().min(1, resolved.startDateRequired),\n end_date: z.string().min(1, resolved.endDateRequired),\n reason: z.string().max(2000).optional().or(z.literal(\"\")),\n })\n .refine((data) => data.end_date >= data.start_date, {\n message: resolved.endDateBeforeStartDate,\n path: [\"end_date\"],\n });\n};\n\nexport const absenceFormSchema = createAbsenceFormSchema();\n\nexport type AbsenceFormValues = z.infer<typeof absenceFormSchema>;\n"]}
1
+ {"version":3,"sources":["../../src/core/schemas/absence-form.ts"],"names":["z"],"mappings":";;;;;AASA,IAAM,6BAAA,GAA2D;AAAA,EAC/D,oBAAA,EAAsB,2CAAA;AAAA,EACtB,iBAAA,EAAmB,wCAAA;AAAA,EACnB,eAAA,EAAiB,sCAAA;AAAA,EACjB,sBAAA,EAAwB;AAC1B,CAAA;AAEO,IAAM,iBAAA,GAAoBA,MAAE,IAAA,CAAK;AAAA,EACtC,iBAAA;AAAA,EACA,cAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,uBAAA,GAA0B,CACrC,QAAA,GAA+C,EAAC,KAC7C;AACH,EAAA,MAAM,QAAA,GAAW,EAAE,GAAG,6BAAA,EAA+B,GAAG,QAAA,EAAS;AAEjE,EAAA,OAAOA,MACJ,MAAA,CAAO;AAAA,IACN,eAAA,EAAiBA,MACd,MAAA,EAAO,CACP,KAAI,CACJ,QAAA,CAAS,SAAS,oBAAoB,CAAA;AAAA,IACzC,IAAA,EAAM,iBAAA;AAAA,IACN,YAAYA,KAAA,CAAE,MAAA,GAAS,GAAA,CAAI,CAAA,EAAG,SAAS,iBAAiB,CAAA;AAAA,IACxD,UAAUA,KAAA,CAAE,MAAA,GAAS,GAAA,CAAI,CAAA,EAAG,SAAS,eAAe,CAAA;AAAA,IACpD,MAAA,EAAQA,KAAA,CAAE,MAAA,EAAO,CAAE,GAAA,CAAI,GAAI,CAAA,CAAE,QAAA,EAAS,CAAE,EAAA,CAAGA,KAAA,CAAE,OAAA,CAAQ,EAAE,CAAC;AAAA,GACzD,EACA,MAAA,CAAO,CAAC,SAAS,IAAA,CAAK,QAAA,IAAY,KAAK,UAAA,EAAY;AAAA,IAClD,SAAS,QAAA,CAAS,sBAAA;AAAA,IAClB,IAAA,EAAM,CAAC,UAAU;AAAA,GAClB,CAAA;AACL;AAEO,IAAM,oBAAoB,uBAAA","file":"absence-form.cjs","sourcesContent":["import { z } from \"zod\";\n\nexport interface AbsenceFormSchemaMessages {\n professionalRequired: string;\n startDateRequired: string;\n endDateRequired: string;\n endDateBeforeStartDate: string;\n}\n\nconst DEFAULT_ABSENCE_FORM_MESSAGES: AbsenceFormSchemaMessages = {\n professionalRequired: \"absences.validation.professional.required\",\n startDateRequired: \"absences.validation.startDate.required\",\n endDateRequired: \"absences.validation.endDate.required\",\n endDateBeforeStartDate: \"absences.validation.endDate.beforeStartDate\",\n};\n\nexport const absenceTypeSchema = z.enum([\n \"temporary_leave\",\n \"missed_shift\",\n \"vacation\",\n \"day_off\",\n]);\n\nexport const createAbsenceFormSchema = (\n messages: Partial<AbsenceFormSchemaMessages> = {},\n) => {\n const resolved = { ...DEFAULT_ABSENCE_FORM_MESSAGES, ...messages };\n\n return z\n .object({\n professional_id: z\n .number()\n .int()\n .positive(resolved.professionalRequired),\n type: absenceTypeSchema,\n start_date: z.string().min(1, resolved.startDateRequired),\n end_date: z.string().min(1, resolved.endDateRequired),\n reason: z.string().max(2000).optional().or(z.literal(\"\")),\n })\n .refine((data) => data.end_date >= data.start_date, {\n message: resolved.endDateBeforeStartDate,\n path: [\"end_date\"],\n });\n};\n\nexport const absenceFormSchema = createAbsenceFormSchema();\n\nexport type AbsenceFormValues = z.infer<typeof absenceFormSchema>;\n"]}
@@ -10,6 +10,7 @@ declare const absenceTypeSchema: z.ZodEnum<{
10
10
  temporary_leave: "temporary_leave";
11
11
  missed_shift: "missed_shift";
12
12
  vacation: "vacation";
13
+ day_off: "day_off";
13
14
  }>;
14
15
  declare const createAbsenceFormSchema: (messages?: Partial<AbsenceFormSchemaMessages>) => z.ZodObject<{
15
16
  professional_id: z.ZodNumber;
@@ -17,6 +18,7 @@ declare const createAbsenceFormSchema: (messages?: Partial<AbsenceFormSchemaMess
17
18
  temporary_leave: "temporary_leave";
18
19
  missed_shift: "missed_shift";
19
20
  vacation: "vacation";
21
+ day_off: "day_off";
20
22
  }>;
21
23
  start_date: z.ZodString;
22
24
  end_date: z.ZodString;
@@ -28,6 +30,7 @@ declare const absenceFormSchema: z.ZodObject<{
28
30
  temporary_leave: "temporary_leave";
29
31
  missed_shift: "missed_shift";
30
32
  vacation: "vacation";
33
+ day_off: "day_off";
31
34
  }>;
32
35
  start_date: z.ZodString;
33
36
  end_date: z.ZodString;
@@ -10,6 +10,7 @@ declare const absenceTypeSchema: z.ZodEnum<{
10
10
  temporary_leave: "temporary_leave";
11
11
  missed_shift: "missed_shift";
12
12
  vacation: "vacation";
13
+ day_off: "day_off";
13
14
  }>;
14
15
  declare const createAbsenceFormSchema: (messages?: Partial<AbsenceFormSchemaMessages>) => z.ZodObject<{
15
16
  professional_id: z.ZodNumber;
@@ -17,6 +18,7 @@ declare const createAbsenceFormSchema: (messages?: Partial<AbsenceFormSchemaMess
17
18
  temporary_leave: "temporary_leave";
18
19
  missed_shift: "missed_shift";
19
20
  vacation: "vacation";
21
+ day_off: "day_off";
20
22
  }>;
21
23
  start_date: z.ZodString;
22
24
  end_date: z.ZodString;
@@ -28,6 +30,7 @@ declare const absenceFormSchema: z.ZodObject<{
28
30
  temporary_leave: "temporary_leave";
29
31
  missed_shift: "missed_shift";
30
32
  vacation: "vacation";
33
+ day_off: "day_off";
31
34
  }>;
32
35
  start_date: z.ZodString;
33
36
  end_date: z.ZodString;
@@ -10,7 +10,8 @@ var DEFAULT_ABSENCE_FORM_MESSAGES = {
10
10
  var absenceTypeSchema = z.enum([
11
11
  "temporary_leave",
12
12
  "missed_shift",
13
- "vacation"
13
+ "vacation",
14
+ "day_off"
14
15
  ]);
15
16
  var createAbsenceFormSchema = (messages = {}) => {
16
17
  const resolved = { ...DEFAULT_ABSENCE_FORM_MESSAGES, ...messages };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/schemas/absence-form.ts"],"names":[],"mappings":";;;AASA,IAAM,6BAAA,GAA2D;AAAA,EAC/D,oBAAA,EAAsB,2CAAA;AAAA,EACtB,iBAAA,EAAmB,wCAAA;AAAA,EACnB,eAAA,EAAiB,sCAAA;AAAA,EACjB,sBAAA,EAAwB;AAC1B,CAAA;AAEO,IAAM,iBAAA,GAAoB,EAAE,IAAA,CAAK;AAAA,EACtC,iBAAA;AAAA,EACA,cAAA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,uBAAA,GAA0B,CACrC,QAAA,GAA+C,EAAC,KAC7C;AACH,EAAA,MAAM,QAAA,GAAW,EAAE,GAAG,6BAAA,EAA+B,GAAG,QAAA,EAAS;AAEjE,EAAA,OAAO,EACJ,MAAA,CAAO;AAAA,IACN,eAAA,EAAiB,EACd,MAAA,EAAO,CACP,KAAI,CACJ,QAAA,CAAS,SAAS,oBAAoB,CAAA;AAAA,IACzC,IAAA,EAAM,iBAAA;AAAA,IACN,YAAY,CAAA,CAAE,MAAA,GAAS,GAAA,CAAI,CAAA,EAAG,SAAS,iBAAiB,CAAA;AAAA,IACxD,UAAU,CAAA,CAAE,MAAA,GAAS,GAAA,CAAI,CAAA,EAAG,SAAS,eAAe,CAAA;AAAA,IACpD,MAAA,EAAQ,CAAA,CAAE,MAAA,EAAO,CAAE,GAAA,CAAI,GAAI,CAAA,CAAE,QAAA,EAAS,CAAE,EAAA,CAAG,CAAA,CAAE,OAAA,CAAQ,EAAE,CAAC;AAAA,GACzD,EACA,MAAA,CAAO,CAAC,SAAS,IAAA,CAAK,QAAA,IAAY,KAAK,UAAA,EAAY;AAAA,IAClD,SAAS,QAAA,CAAS,sBAAA;AAAA,IAClB,IAAA,EAAM,CAAC,UAAU;AAAA,GAClB,CAAA;AACL;AAEO,IAAM,oBAAoB,uBAAA","file":"absence-form.js","sourcesContent":["import { z } from \"zod\";\n\nexport interface AbsenceFormSchemaMessages {\n professionalRequired: string;\n startDateRequired: string;\n endDateRequired: string;\n endDateBeforeStartDate: string;\n}\n\nconst DEFAULT_ABSENCE_FORM_MESSAGES: AbsenceFormSchemaMessages = {\n professionalRequired: \"absences.validation.professional.required\",\n startDateRequired: \"absences.validation.startDate.required\",\n endDateRequired: \"absences.validation.endDate.required\",\n endDateBeforeStartDate: \"absences.validation.endDate.beforeStartDate\",\n};\n\nexport const absenceTypeSchema = z.enum([\n \"temporary_leave\",\n \"missed_shift\",\n \"vacation\",\n]);\n\nexport const createAbsenceFormSchema = (\n messages: Partial<AbsenceFormSchemaMessages> = {},\n) => {\n const resolved = { ...DEFAULT_ABSENCE_FORM_MESSAGES, ...messages };\n\n return z\n .object({\n professional_id: z\n .number()\n .int()\n .positive(resolved.professionalRequired),\n type: absenceTypeSchema,\n start_date: z.string().min(1, resolved.startDateRequired),\n end_date: z.string().min(1, resolved.endDateRequired),\n reason: z.string().max(2000).optional().or(z.literal(\"\")),\n })\n .refine((data) => data.end_date >= data.start_date, {\n message: resolved.endDateBeforeStartDate,\n path: [\"end_date\"],\n });\n};\n\nexport const absenceFormSchema = createAbsenceFormSchema();\n\nexport type AbsenceFormValues = z.infer<typeof absenceFormSchema>;\n"]}
1
+ {"version":3,"sources":["../../src/core/schemas/absence-form.ts"],"names":[],"mappings":";;;AASA,IAAM,6BAAA,GAA2D;AAAA,EAC/D,oBAAA,EAAsB,2CAAA;AAAA,EACtB,iBAAA,EAAmB,wCAAA;AAAA,EACnB,eAAA,EAAiB,sCAAA;AAAA,EACjB,sBAAA,EAAwB;AAC1B,CAAA;AAEO,IAAM,iBAAA,GAAoB,EAAE,IAAA,CAAK;AAAA,EACtC,iBAAA;AAAA,EACA,cAAA;AAAA,EACA,UAAA;AAAA,EACA;AACF,CAAC;AAEM,IAAM,uBAAA,GAA0B,CACrC,QAAA,GAA+C,EAAC,KAC7C;AACH,EAAA,MAAM,QAAA,GAAW,EAAE,GAAG,6BAAA,EAA+B,GAAG,QAAA,EAAS;AAEjE,EAAA,OAAO,EACJ,MAAA,CAAO;AAAA,IACN,eAAA,EAAiB,EACd,MAAA,EAAO,CACP,KAAI,CACJ,QAAA,CAAS,SAAS,oBAAoB,CAAA;AAAA,IACzC,IAAA,EAAM,iBAAA;AAAA,IACN,YAAY,CAAA,CAAE,MAAA,GAAS,GAAA,CAAI,CAAA,EAAG,SAAS,iBAAiB,CAAA;AAAA,IACxD,UAAU,CAAA,CAAE,MAAA,GAAS,GAAA,CAAI,CAAA,EAAG,SAAS,eAAe,CAAA;AAAA,IACpD,MAAA,EAAQ,CAAA,CAAE,MAAA,EAAO,CAAE,GAAA,CAAI,GAAI,CAAA,CAAE,QAAA,EAAS,CAAE,EAAA,CAAG,CAAA,CAAE,OAAA,CAAQ,EAAE,CAAC;AAAA,GACzD,EACA,MAAA,CAAO,CAAC,SAAS,IAAA,CAAK,QAAA,IAAY,KAAK,UAAA,EAAY;AAAA,IAClD,SAAS,QAAA,CAAS,sBAAA;AAAA,IAClB,IAAA,EAAM,CAAC,UAAU;AAAA,GAClB,CAAA;AACL;AAEO,IAAM,oBAAoB,uBAAA","file":"absence-form.js","sourcesContent":["import { z } from \"zod\";\n\nexport interface AbsenceFormSchemaMessages {\n professionalRequired: string;\n startDateRequired: string;\n endDateRequired: string;\n endDateBeforeStartDate: string;\n}\n\nconst DEFAULT_ABSENCE_FORM_MESSAGES: AbsenceFormSchemaMessages = {\n professionalRequired: \"absences.validation.professional.required\",\n startDateRequired: \"absences.validation.startDate.required\",\n endDateRequired: \"absences.validation.endDate.required\",\n endDateBeforeStartDate: \"absences.validation.endDate.beforeStartDate\",\n};\n\nexport const absenceTypeSchema = z.enum([\n \"temporary_leave\",\n \"missed_shift\",\n \"vacation\",\n \"day_off\",\n]);\n\nexport const createAbsenceFormSchema = (\n messages: Partial<AbsenceFormSchemaMessages> = {},\n) => {\n const resolved = { ...DEFAULT_ABSENCE_FORM_MESSAGES, ...messages };\n\n return z\n .object({\n professional_id: z\n .number()\n .int()\n .positive(resolved.professionalRequired),\n type: absenceTypeSchema,\n start_date: z.string().min(1, resolved.startDateRequired),\n end_date: z.string().min(1, resolved.endDateRequired),\n reason: z.string().max(2000).optional().or(z.literal(\"\")),\n })\n .refine((data) => data.end_date >= data.start_date, {\n message: resolved.endDateBeforeStartDate,\n path: [\"end_date\"],\n });\n};\n\nexport const absenceFormSchema = createAbsenceFormSchema();\n\nexport type AbsenceFormValues = z.infer<typeof absenceFormSchema>;\n"]}
@@ -60,7 +60,7 @@ function generateTimelineEvents(data, getStatusColorValue) {
60
60
  const startTime = appointment.appointment_time.slice(0, 5);
61
61
  const endTime = addMinutesToTime(
62
62
  startTime,
63
- appointment.service?.duration_minutes ?? DEFAULT_DURATION_MINUTES
63
+ appointment.duration_minutes ?? appointment.service?.duration_minutes ?? DEFAULT_DURATION_MINUTES
64
64
  );
65
65
  return {
66
66
  id: appointment.id,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/utils/date.ts","../../src/core/utils/fullname.ts","../../src/core/utils/appointments.ts"],"names":["dayjs","localizedFormat","localeData"],"mappings":";;;;;;;;;;;;;AAIAA,sBAAA,CAAM,OAAOC,gCAAe,CAAA;AAC5BD,sBAAA,CAAM,OAAOE,2BAAU,CAAA;AA6EhB,SAAS,gBAAA,CAAiB,MAAc,OAAA,EAAyB;AACtE,EAAA,OAAOF,sBAAA,CAAM,CAAA,WAAA,EAAc,IAAI,CAAA,CAAE,CAAA,CAAE,IAAI,OAAA,EAAS,QAAQ,CAAA,CAAE,MAAA,CAAO,OAAO,CAAA;AAC1E;;;ACpFO,IAAM,WAAA,GAAc,CAAC,SAAA,EAAmB,QAAA,KAC7C,WAAW,CAAA,EAAG,SAAS,CAAA,CAAA,EAAI,QAAQ,CAAA,CAAA,GAAK,SAAA;;;ACkD1C,IAAM,cAAA,GAAiB,WAAA;AACvB,IAAM,wBAAA,GAA2B,EAAA;AAE1B,IAAM,QAAQA,sBAAAA;AAEd,SAAS,sBAAA,CACd,IAAA,EACA,QAAA,EACA,MAAA,EACoB;AACpB,EAAA,MAAM,WAA+B,EAAC;AACtC,EAAA,IAAI,OAAA,GAAUA,uBAAM,QAAQ,CAAA;AAC5B,EAAA,MAAM,GAAA,GAAMA,uBAAM,MAAM,CAAA;AAExB,EAAA,OAAO,CAAC,OAAA,CAAQ,OAAA,CAAQ,GAAG,CAAA,EAAG;AAC5B,IAAA,MAAM,GAAA,GAAM,OAAA,CAAQ,MAAA,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,WAAA,CAAY,SAAS,gBAAA,IAAoB;AAAA,SAC3C;AAEA,QAAA,OAAO;AAAA,UACL,IAAI,WAAA,CAAY,EAAA;AAAA,UAChB,KAAA,EAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,SAAS,CAAA,GAAA,CAAA;AAAA,UAC3B,GAAA,EAAK,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,OAAO,CAAA,GAAA,CAAA;AAAA,UACvB,KAAA,EAAO,YAAY,MAAA,GACf,WAAA;AAAA,YACE,WAAA,CAAY,OAAO,SAAA,IAAa,EAAA;AAAA,YAChC,WAAA,CAAY,OAAO,QAAA,IAAY;AAAA,cAEjC,WAAA,CAAY,YAAA;AAAA,UAChB,OAAA,EAAS,WAAA,CAAY,OAAA,EAAS,IAAA,IAAQ,GAAA;AAAA,UACtC,KAAA,EAAO,mBAAA,CAAoB,WAAA,CAAY,MAAM,CAAA;AAAA,UAC7C,cAAA,EAAgB,WAAA,CAAY,YAAA,EAAc,EAAA,IAAM;AAAA,SAClD;AAAA,MACF,CAAC;AAAA,KACF;AAAA,GACH;AACF","file":"appointments.cjs","sourcesContent":["import dayjs from \"dayjs\";\nimport localeData from \"dayjs/plugin/localeData.js\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat.js\";\n\ndayjs.extend(localizedFormat);\ndayjs.extend(localeData);\n\nexport function addDays(date: Date, days: number): Date {\n return dayjs(date).add(days, \"day\").toDate();\n}\n\n/** Full years elapsed since a \"YYYY-MM-DD\" birthday, as of today. */\nexport function calculateAge(birthday: string): number {\n return dayjs().diff(dayjs(birthday), \"year\");\n}\n\n/**\n * Whether a \"YYYY-MM-DD\" string is a real calendar date (rejects e.g. \"2024-02-30\"\n * or \"2024-13-01\", which a shape-only regex like `birthdayRegex` would let through).\n */\nexport function isValidCalendarDate(value: string): boolean {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(value);\n if (!match) return false;\n\n const [, yearStr, monthStr, dayStr] = match;\n const year = Number(yearStr);\n const month = Number(monthStr);\n const day = Number(dayStr);\n\n const date = new Date(year, month - 1, day);\n return (\n date.getFullYear() === year &&\n date.getMonth() === month - 1 &&\n date.getDate() === day\n );\n}\n\n/** Converts a \"YYYY-MM-DD\" value to \"DD/MM/YYYY\" for masked-input display. Empty in, empty out. */\nexport function isoToDisplayDate(iso: string): string {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(iso);\n if (!match) return \"\";\n\n const [, year, month, day] = match;\n return `${day}/${month}/${year}`;\n}\n\n/**\n * Converts the raw digits typed into a DD/MM/YYYY mask (e.g. \"15081990\") into\n * \"YYYY-MM-DD\". Returns \"\" until all 8 digits have been entered.\n */\nexport function maskedDigitsToIsoDate(digits: string): string {\n if (digits.length !== 8) return \"\";\n\n const day = digits.slice(0, 2);\n const month = digits.slice(2, 4);\n const year = digits.slice(4, 8);\n return `${year}-${month}-${day}`;\n}\n\nexport function toDateString(date: Date): string {\n return dayjs(date).format(\"YYYY-MM-DD\");\n}\n\nexport function parseDateParts(dateString: string): {\n month: string;\n day: string;\n} {\n const date = dayjs(dateString);\n return {\n month: date.format(\"MMM\").toUpperCase(),\n day: date.format(\"D\"),\n };\n}\n\nexport function formatMonthDay(dateString: string): string {\n return dayjs(dateString).format(\"MMM D\");\n}\n\nexport function formatTime12h(time: string): string {\n return dayjs(`1970-01-01 ${time}`).format(\"h:mm a\");\n}\n\nexport function addMinutesToTime(time: string, minutes: number): string {\n return dayjs(`1970-01-01 ${time}`).add(minutes, \"minute\").format(\"HH:mm\");\n}\n\n/** Formats a date using the active dayjs locale (e.g. DD/MM/YYYY for pt-br, MM/DD/YYYY for en). */\nexport function formatLocalizedDate(\n date: Date | string | null | undefined,\n): string {\n if (!date) return \"—\";\n return dayjs(date).format(\"L\");\n}\n\n/** Formats a date and time using the active dayjs locale. */\nexport function formatLocalizedDateTime(\n date: Date | string | null | undefined,\n): string {\n if (!date) return \"—\";\n return dayjs(date).format(\"L LT\");\n}\n\n/** Day/month order for the active dayjs locale, derived from its full date pattern (e.g. \"DD/MM\" for pt-br, \"MM/DD\" for en). */\nfunction localizedShortDatePattern(): string {\n const longFormat = dayjs.localeData().longDateFormat(\"L\");\n return longFormat\n .replace(/^[,./\\-\\s]*Y+[,./\\-\\s]*/, \"\")\n .replace(/[,./\\-\\s]*Y+[,./\\-\\s]*$/, \"\");\n}\n\n/** Formats a date as day/month (no year), in the order the active dayjs locale uses. */\nexport function formatLocalizedShortDate(\n date: Date | string | null | undefined,\n): string {\n if (!date) return \"—\";\n return dayjs(date).format(localizedShortDatePattern());\n}\n","export const getFullName = (firstname: string, lastname?: string): string =>\n lastname ? `${firstname} ${lastname}` : firstname;\n","import dayjs from \"dayjs\";\n\nimport { addMinutesToTime } from \"./date\";\nimport { getFullName } from \"./fullname\";\n\nexport interface AppointmentLike {\n id: number;\n appointment_time: string;\n status?: string | null;\n phone_number: string;\n service?: {\n duration_minutes?: number | null;\n name?: string | null;\n } | null;\n client?: {\n firstname?: string | null;\n lastname?: string | null;\n } | null;\n professional?: {\n id: number;\n firstname?: string | null;\n lastname?: string | null;\n } | null;\n}\n\nexport interface AgendaSection<T> {\n title: string;\n data: T[];\n}\n\nexport interface TimelineEvent {\n id: number;\n start: string;\n end: string;\n title: string;\n summary: string;\n color: string;\n professionalId: number | null;\n}\n\nexport interface MarkedDateDot {\n key: string;\n color: string;\n}\n\nexport interface MarkedDate {\n dots: MarkedDateDot[];\n}\n\nexport type MarkedDatesMap = Record<string, MarkedDate>;\n\nconst DEFAULT_STATUS = \"scheduled\";\nconst DEFAULT_DURATION_MINUTES = 30;\n\nexport const today = dayjs();\n\nexport function generateAgendaSections<T>(\n data: Record<string, T[]>,\n dateFrom: string,\n dateTo: string,\n): AgendaSection<T>[] {\n const sections: AgendaSection<T>[] = [];\n let current = dayjs(dateFrom);\n const end = dayjs(dateTo);\n\n while (!current.isAfter(end)) {\n const key = current.format(\"YYYY-MM-DD\");\n sections.push({\n title: key,\n data: data[key] ?? [],\n });\n current = current.add(1, \"day\");\n }\n\n return sections;\n}\n\nexport function generateMarkedDates<T extends { status?: string | null }>(\n data: Record<string, T[]>,\n getStatusColorValue: (status: string | null | undefined) => string,\n): MarkedDatesMap {\n return Object.keys(data).reduce<MarkedDatesMap>((acc, date) => {\n const uniqueStatuses = [\n ...new Set(data[date].map((appointment) => appointment.status)),\n ];\n acc[date] = {\n dots: uniqueStatuses.map((status) => ({\n key: status ?? DEFAULT_STATUS,\n color: getStatusColorValue(status),\n })),\n };\n return acc;\n }, {});\n}\n\nexport function generateTimelineEvents<T extends AppointmentLike>(\n data: Record<string, T[]>,\n getStatusColorValue: (status: string | null | undefined) => string,\n): Record<string, TimelineEvent[]> {\n return Object.fromEntries(\n Object.entries(data).map(([date, appointments]) => [\n date,\n appointments.map((appointment) => {\n const startTime = appointment.appointment_time.slice(0, 5);\n const endTime = addMinutesToTime(\n startTime,\n appointment.service?.duration_minutes ?? DEFAULT_DURATION_MINUTES,\n );\n\n return {\n id: appointment.id,\n start: `${date} ${startTime}:00`,\n end: `${date} ${endTime}:00`,\n title: appointment.client\n ? getFullName(\n appointment.client.firstname ?? \"\",\n appointment.client.lastname ?? \"\",\n )\n : appointment.phone_number,\n summary: appointment.service?.name ?? \"-\",\n color: getStatusColorValue(appointment.status),\n professionalId: appointment.professional?.id ?? null,\n };\n }),\n ]),\n );\n}\n"]}
1
+ {"version":3,"sources":["../../src/core/utils/date.ts","../../src/core/utils/fullname.ts","../../src/core/utils/appointments.ts"],"names":["dayjs","localizedFormat","localeData"],"mappings":";;;;;;;;;;;;;AAIAA,sBAAA,CAAM,OAAOC,gCAAe,CAAA;AAC5BD,sBAAA,CAAM,OAAOE,2BAAU,CAAA;AA6EhB,SAAS,gBAAA,CAAiB,MAAc,OAAA,EAAyB;AACtE,EAAA,OAAOF,sBAAA,CAAM,CAAA,WAAA,EAAc,IAAI,CAAA,CAAE,CAAA,CAAE,IAAI,OAAA,EAAS,QAAQ,CAAA,CAAE,MAAA,CAAO,OAAO,CA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,CAAC;AAAA,KACF;AAAA,GACH;AACF","file":"appointments.cjs","sourcesContent":["import dayjs from \"dayjs\";\nimport localeData from \"dayjs/plugin/localeData.js\";\nimport localizedFormat from \"dayjs/plugin/localizedFormat.js\";\n\ndayjs.extend(localizedFormat);\ndayjs.extend(localeData);\n\nexport function addDays(date: Date, days: number): Date {\n return dayjs(date).add(days, \"day\").toDate();\n}\n\n/** Full years elapsed since a \"YYYY-MM-DD\" birthday, as of today. */\nexport function calculateAge(birthday: string): number {\n return dayjs().diff(dayjs(birthday), \"year\");\n}\n\n/**\n * Whether a \"YYYY-MM-DD\" string is a real calendar date (rejects e.g. \"2024-02-30\"\n * or \"2024-13-01\", which a shape-only regex like `birthdayRegex` would let through).\n */\nexport function isValidCalendarDate(value: string): boolean {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(value);\n if (!match) return false;\n\n const [, yearStr, monthStr, dayStr] = match;\n const year = Number(yearStr);\n const month = Number(monthStr);\n const day = Number(dayStr);\n\n const date = new Date(year, month - 1, day);\n return (\n date.getFullYear() === year &&\n date.getMonth() === month - 1 &&\n date.getDate() === day\n );\n}\n\n/** Converts a \"YYYY-MM-DD\" value to \"DD/MM/YYYY\" for masked-input display. Empty in, empty out. */\nexport function isoToDisplayDate(iso: string): string {\n const match = /^(\\d{4})-(\\d{2})-(\\d{2})$/.exec(iso);\n if (!match) return \"\";\n\n const [, year, month, day] = match;\n return `${day}/${month}/${year}`;\n}\n\n/**\n * Converts the raw digits typed into a DD/MM/YYYY mask (e.g. \"15081990\") into\n * \"YYYY-MM-DD\". Returns \"\" until all 8 digits have been entered.\n */\nexport function maskedDigitsToIsoDate(digits: string): string {\n if (digits.length !== 8) return \"\";\n\n const day = digits.slice(0, 2);\n const month = digits.slice(2, 4);\n const year = digits.slice(4, 8);\n return `${year}-${month}-${day}`;\n}\n\nexport function toDateString(date: Date): string {\n return dayjs(date).format(\"YYYY-MM-DD\");\n}\n\nexport function parseDateParts(dateString: string): {\n month: string;\n day: string;\n} {\n const date = dayjs(dateString);\n return {\n month: date.format(\"MMM\").toUpperCase(),\n day: date.format(\"D\"),\n };\n}\n\nexport function formatMonthDay(dateString: string): string {\n return dayjs(dateString).format(\"MMM D\");\n}\n\nexport function formatTime12h(time: string): string {\n return dayjs(`1970-01-01 ${time}`).format(\"h:mm a\");\n}\n\nexport function addMinutesToTime(time: string, minutes: number): string {\n return dayjs(`1970-01-01 ${time}`).add(minutes, \"minute\").format(\"HH:mm\");\n}\n\n/** Formats a date using the active dayjs locale (e.g. DD/MM/YYYY for pt-br, MM/DD/YYYY for en). */\nexport function formatLocalizedDate(\n date: Date | string | null | undefined,\n): string {\n if (!date) return \"—\";\n return dayjs(date).format(\"L\");\n}\n\n/** Formats a date and time using the active dayjs locale. */\nexport function formatLocalizedDateTime(\n date: Date | string | null | undefined,\n): string {\n if (!date) return \"—\";\n return dayjs(date).format(\"L LT\");\n}\n\n/** Day/month order for the active dayjs locale, derived from its full date pattern (e.g. \"DD/MM\" for pt-br, \"MM/DD\" for en). */\nfunction localizedShortDatePattern(): string {\n const longFormat = dayjs.localeData().longDateFormat(\"L\");\n return longFormat\n .replace(/^[,./\\-\\s]*Y+[,./\\-\\s]*/, \"\")\n .replace(/[,./\\-\\s]*Y+[,./\\-\\s]*$/, \"\");\n}\n\n/** Formats a date as day/month (no year), in the order the active dayjs locale uses. */\nexport function formatLocalizedShortDate(\n date: Date | string | null | undefined,\n): string {\n if (!date) return \"—\";\n return dayjs(date).format(localizedShortDatePattern());\n}\n","export const getFullName = (firstname: string, lastname?: string): string =>\n lastname ? `${firstname} ${lastname}` : firstname;\n","import dayjs from \"dayjs\";\n\nimport { addMinutesToTime } from \"./date\";\nimport { getFullName } from \"./fullname\";\n\nexport interface AppointmentLike {\n id: number;\n appointment_time: string;\n status?: string | null;\n phone_number: string;\n /** The whole appointment's length (all its services); falls back to the service's. */\n duration_minutes?: number | null;\n service?: {\n duration_minutes?: number | null;\n name?: string | null;\n } | null;\n client?: {\n firstname?: string | null;\n lastname?: string | null;\n } | null;\n professional?: {\n id: number;\n firstname?: string | null;\n lastname?: string | null;\n } | null;\n}\n\nexport interface AgendaSection<T> {\n title: string;\n data: T[];\n}\n\nexport interface TimelineEvent {\n id: number;\n start: string;\n end: string;\n title: string;\n summary: string;\n color: string;\n professionalId: number | null;\n}\n\nexport interface MarkedDateDot {\n key: string;\n color: string;\n}\n\nexport interface MarkedDate {\n dots: MarkedDateDot[];\n}\n\nexport type MarkedDatesMap = Record<string, MarkedDate>;\n\nconst DEFAULT_STATUS = \"scheduled\";\nconst DEFAULT_DURATION_MINUTES = 30;\n\nexport const today = dayjs();\n\nexport function generateAgendaSections<T>(\n data: Record<string, T[]>,\n dateFrom: string,\n dateTo: string,\n): AgendaSection<T>[] {\n const sections: AgendaSection<T>[] = [];\n let current = dayjs(dateFrom);\n const end = dayjs(dateTo);\n\n while (!current.isAfter(end)) {\n const key = current.format(\"YYYY-MM-DD\");\n sections.push({\n title: key,\n data: data[key] ?? [],\n });\n current = current.add(1, \"day\");\n }\n\n return sections;\n}\n\nexport function generateMarkedDates<T extends { status?: string | null }>(\n data: Record<string, T[]>,\n getStatusColorValue: (status: string | null | undefined) => string,\n): MarkedDatesMap {\n return Object.keys(data).reduce<MarkedDatesMap>((acc, date) => {\n const uniqueStatuses = [\n ...new Set(data[date].map((appointment) => appointment.status)),\n ];\n acc[date] = {\n dots: uniqueStatuses.map((status) => ({\n key: status ?? DEFAULT_STATUS,\n color: getStatusColorValue(status),\n })),\n };\n return acc;\n }, {});\n}\n\nexport function generateTimelineEvents<T extends AppointmentLike>(\n data: Record<string, T[]>,\n getStatusColorValue: (status: string | null | undefined) => string,\n): Record<string, TimelineEvent[]> {\n return Object.fromEntries(\n Object.entries(data).map(([date, appointments]) => [\n date,\n appointments.map((appointment) => {\n const startTime = appointment.appointment_time.slice(0, 5);\n const endTime = addMinutesToTime(\n startTime,\n appointment.duration_minutes ??\n appointment.service?.duration_minutes ??\n DEFAULT_DURATION_MINUTES,\n );\n\n return {\n id: appointment.id,\n start: `${date} ${startTime}:00`,\n end: `${date} ${endTime}:00`,\n title: appointment.client\n ? getFullName(\n appointment.client.firstname ?? \"\",\n appointment.client.lastname ?? \"\",\n )\n : appointment.phone_number,\n summary: appointment.service?.name ?? \"-\",\n color: getStatusColorValue(appointment.status),\n professionalId: appointment.professional?.id ?? null,\n };\n }),\n ]),\n );\n}\n"]}
@@ -5,6 +5,8 @@ interface AppointmentLike {
5
5
  appointment_time: string;
6
6
  status?: string | null;
7
7
  phone_number: string;
8
+ /** The whole appointment's length (all its services); falls back to the service's. */
9
+ duration_minutes?: number | null;
8
10
  service?: {
9
11
  duration_minutes?: number | null;
10
12
  name?: string | null;
@@ -5,6 +5,8 @@ interface AppointmentLike {
5
5
  appointment_time: string;
6
6
  status?: string | null;
7
7
  phone_number: string;
8
+ /** The whole appointment's length (all its services); falls back to the service's. */
9
+ duration_minutes?: number | null;
8
10
  service?: {
9
11
  duration_minutes?: number | null;
10
12
  name?: string | null;
@@ -41,7 +41,7 @@ function generateTimelineEvents(data, getStatusColorValue) {
41
41
  const startTime = appointment.appointment_time.slice(0, 5);
42
42
  const endTime = addMinutesToTime(
43
43
  startTime,
44
- appointment.service?.duration_minutes ?? DEFAULT_DURATION_MINUTES
44
+ appointment.duration_minutes ?? appointment.service?.duration_minutes ?? DEFAULT_DURATION_MINUTES
45
45
  );
46
46
  return {
47
47
  id: appointment.id,
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/core/utils/appointments.ts"],"names":[],"mappings":";;;;AAmDA,IAAM,cAAA,GAAiB,WAAA;AACvB,IAAM,wBAAA,GAA2B,EAAA;AAE1B,IAAM,QAAQ,KAAA;AAEd,SAAS,sBAAA,CACd,IAAA,EACA,QAAA,EACA,MAAA,EACoB;AACpB,EAAA,MAAM,WAA+B,EAAC;AACtC,EAAA,IAAI,OAAA,GAAU,MAAM,QAAQ,CAAA;AAC5B,EAAA,MAAM,GAAA,GAAM,MAAM,MAAM,CAA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,WAAA,CAAY,gBAAA,CAAiB,KAAA,CAAM,GAAG,CAAC,CAAA;AACzD,QAAA,MAAM,OAAA,GAAU,gBAAA;AAAA,UACd,SAAA;AAAA,UACA,WAAA,CAAY,SAAS,gBAAA,IAAoB;AAAA,SAC3C;AAEA,QAAA,OAAO;AAAA,UACL,IAAI,WAAA,CAAY,EAAA;AAAA,UAChB,KAAA,EAAO,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,SAAS,CAAA,GAAA,CAAA;AAAA,UAC3B,GAAA,EAAK,CAAA,EAAG,IAAI,CAAA,CAAA,EAAI,OAAO,CAAA,GAAA,CAAA;AAAA,UACvB,KAAA,EAAO,YAAY,MAAA,GACf,WAAA;AAAA,YACE,WAAA,CAAY,OAAO,SAAA,IAAa,EAAA;AAAA,YAChC,WAAA,CAAY,OAAO,QAAA,IAAY;AAAA,cAEjC,WAAA,CAAY,YAAA;AAAA,UAChB,OAAA,EAAS,WAAA,CAAY,OAAA,EAAS,IAAA,IAAQ,GAAA;AAAA,UACtC,KAAA,EAAO,mBAAA,CAAoB,WAAA,CAAY,MAAM,CAAA;AAAA,UAC7C,cAAA,EAAgB,WAAA,CAAY,YAAA,EAAc,EAAA,IAAM;AAAA,SAClD;AAAA,MACF,CAAC;AAAA,KACF;AAAA,GACH;AACF","file":"appointments.js","sourcesContent":["import dayjs from \"dayjs\";\n\nimport { addMinutesToTime } from \"./date\";\nimport { getFullName } from \"./fullname\";\n\nexport interface AppointmentLike {\n id: number;\n appointment_time: string;\n status?: string | null;\n phone_number: string;\n service?: {\n duration_minutes?: number | null;\n name?: string | null;\n } | null;\n client?: {\n firstname?: string | null;\n lastname?: string | null;\n } | null;\n professional?: {\n id: number;\n firstname?: string | null;\n lastname?: string | null;\n } | null;\n}\n\nexport interface AgendaSection<T> {\n title: string;\n data: T[];\n}\n\nexport interface TimelineEvent {\n id: number;\n start: string;\n end: string;\n title: string;\n summary: string;\n color: string;\n professionalId: number | null;\n}\n\nexport interface MarkedDateDot {\n key: string;\n color: string;\n}\n\nexport interface MarkedDate {\n dots: MarkedDateDot[];\n}\n\nexport type MarkedDatesMap = Record<string, MarkedDate>;\n\nconst DEFAULT_STATUS = \"scheduled\";\nconst DEFAULT_DURATION_MINUTES = 30;\n\nexport const today = dayjs();\n\nexport function generateAgendaSections<T>(\n data: Record<string, T[]>,\n dateFrom: string,\n dateTo: string,\n): AgendaSection<T>[] {\n const sections: AgendaSection<T>[] = [];\n let current = dayjs(dateFrom);\n const end = dayjs(dateTo);\n\n while (!current.isAfter(end)) {\n const key = current.format(\"YYYY-MM-DD\");\n sections.push({\n title: key,\n data: data[key] ?? [],\n });\n current = current.add(1, \"day\");\n }\n\n return sections;\n}\n\nexport function generateMarkedDates<T extends { status?: string | null }>(\n data: Record<string, T[]>,\n getStatusColorValue: (status: string | null | undefined) => string,\n): MarkedDatesMap {\n return Object.keys(data).reduce<MarkedDatesMap>((acc, date) => {\n const uniqueStatuses = [\n ...new Set(data[date].map((appointment) => appointment.status)),\n ];\n acc[date] = {\n dots: uniqueStatuses.map((status) => ({\n key: status ?? DEFAULT_STATUS,\n color: getStatusColorValue(status),\n })),\n };\n return acc;\n }, {});\n}\n\nexport function generateTimelineEvents<T extends AppointmentLike>(\n data: Record<string, T[]>,\n getStatusColorValue: (status: string | null | undefined) => string,\n): Record<string, TimelineEvent[]> {\n return Object.fromEntries(\n Object.entries(data).map(([date, appointments]) => [\n date,\n appointments.map((appointment) => {\n const startTime = appointment.appointment_time.slice(0, 5);\n const endTime = addMinutesToTime(\n startTime,\n appointment.service?.duration_minutes ?? DEFAULT_DURATION_MINUTES,\n );\n\n return {\n id: appointment.id,\n start: `${date} ${startTime}:00`,\n end: `${date} ${endTime}:00`,\n title: appointment.client\n ? getFullName(\n appointment.client.firstname ?? \"\",\n appointment.client.lastname ?? \"\",\n )\n : appointment.phone_number,\n summary: appointment.service?.name ?? \"-\",\n color: getStatusColorValue(appointment.status),\n professionalId: appointment.professional?.id ?? null,\n };\n }),\n ]),\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Time } from \"./date\";\nimport { getFullName } from \"./fullname\";\n\nexport interface AppointmentLike {\n id: number;\n appointment_time: string;\n status?: string | null;\n phone_number: string;\n /** The whole appointment's length (all its services); falls back to the service's. */\n duration_minutes?: number | null;\n service?: {\n duration_minutes?: number | null;\n name?: string | null;\n } | null;\n client?: {\n firstname?: string | null;\n lastname?: string | null;\n } | null;\n professional?: {\n id: number;\n firstname?: string | null;\n lastname?: string | null;\n } | null;\n}\n\nexport interface AgendaSection<T> {\n title: string;\n data: T[];\n}\n\nexport interface TimelineEvent {\n id: number;\n start: string;\n end: string;\n title: string;\n summary: string;\n color: string;\n professionalId: number | null;\n}\n\nexport interface MarkedDateDot {\n key: string;\n color: string;\n}\n\nexport interface MarkedDate {\n dots: MarkedDateDot[];\n}\n\nexport type MarkedDatesMap = Record<string, MarkedDate>;\n\nconst DEFAULT_STATUS = \"scheduled\";\nconst DEFAULT_DURATION_MINUTES = 30;\n\nexport const today = dayjs();\n\nexport function generateAgendaSections<T>(\n data: Record<string, T[]>,\n dateFrom: string,\n dateTo: string,\n): AgendaSection<T>[] {\n const sections: AgendaSection<T>[] = [];\n let current = dayjs(dateFrom);\n const end = dayjs(dateTo);\n\n while (!current.isAfter(end)) {\n const key = current.format(\"YYYY-MM-DD\");\n sections.push({\n title: key,\n data: data[key] ?? [],\n });\n current = current.add(1, \"day\");\n }\n\n return sections;\n}\n\nexport function generateMarkedDates<T extends { status?: string | null }>(\n data: Record<string, T[]>,\n getStatusColorValue: (status: string | null | undefined) => string,\n): MarkedDatesMap {\n return Object.keys(data).reduce<MarkedDatesMap>((acc, date) => {\n const uniqueStatuses = [\n ...new Set(data[date].map((appointment) => appointment.status)),\n ];\n acc[date] = {\n dots: uniqueStatuses.map((status) => ({\n key: status ?? DEFAULT_STATUS,\n color: getStatusColorValue(status),\n })),\n };\n return acc;\n }, {});\n}\n\nexport function generateTimelineEvents<T extends AppointmentLike>(\n data: Record<string, T[]>,\n getStatusColorValue: (status: string | null | undefined) => string,\n): Record<string, TimelineEvent[]> {\n return Object.fromEntries(\n Object.entries(data).map(([date, appointments]) => [\n date,\n appointments.map((appointment) => {\n const startTime = appointment.appointment_time.slice(0, 5);\n const endTime = addMinutesToTime(\n startTime,\n appointment.duration_minutes ??\n appointment.service?.duration_minutes ??\n DEFAULT_DURATION_MINUTES,\n );\n\n return {\n id: appointment.id,\n start: `${date} ${startTime}:00`,\n end: `${date} ${endTime}:00`,\n title: appointment.client\n ? getFullName(\n appointment.client.firstname ?? \"\",\n appointment.client.lastname ?? \"\",\n )\n : appointment.phone_number,\n summary: appointment.service?.name ?? \"-\",\n color: getStatusColorValue(appointment.status),\n professionalId: appointment.professional?.id ?? null,\n };\n }),\n ]),\n );\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agendar/shared",
3
- "version": "0.4.0",
3
+ "version": "0.6.0",
4
4
  "type": "module",
5
5
  "repository": {
6
6
  "type": "git",