analytica-frontend-lib 1.2.47 → 1.2.49

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 (86) hide show
  1. package/dist/ActivityCardQuestionBanks/index.css +28 -2
  2. package/dist/ActivityCardQuestionBanks/index.css.map +1 -1
  3. package/dist/ActivityCardQuestionPreview/index.css +28 -2
  4. package/dist/ActivityCardQuestionPreview/index.css.map +1 -1
  5. package/dist/ActivityDetails/index.css +28 -2
  6. package/dist/ActivityDetails/index.css.map +1 -1
  7. package/dist/ActivityFilters/index.css +28 -2
  8. package/dist/ActivityFilters/index.css.map +1 -1
  9. package/dist/ActivityPreview/index.css +28 -2
  10. package/dist/ActivityPreview/index.css.map +1 -1
  11. package/dist/AlertManager/index.css +28 -2
  12. package/dist/AlertManager/index.css.map +1 -1
  13. package/dist/ProgressCircle/index.d.ts.map +1 -1
  14. package/dist/ProgressCircle/index.js +8 -8
  15. package/dist/ProgressCircle/index.js.map +1 -1
  16. package/dist/ProgressCircle/index.mjs +8 -8
  17. package/dist/ProgressCircle/index.mjs.map +1 -1
  18. package/dist/RecommendedLessonDetails/index.d.ts +4 -0
  19. package/dist/RecommendedLessonDetails/index.d.ts.map +1 -0
  20. package/dist/RecommendedLessonDetails/index.js +2250 -0
  21. package/dist/RecommendedLessonDetails/index.js.map +1 -0
  22. package/dist/RecommendedLessonDetails/index.mjs +2242 -0
  23. package/dist/RecommendedLessonDetails/index.mjs.map +1 -0
  24. package/dist/RecommendedLessonsHistory/index.css +28 -2
  25. package/dist/RecommendedLessonsHistory/index.css.map +1 -1
  26. package/dist/RecommendedLessonsHistory/index.js +3 -5
  27. package/dist/RecommendedLessonsHistory/index.js.map +1 -1
  28. package/dist/RecommendedLessonsHistory/index.mjs +3 -5
  29. package/dist/RecommendedLessonsHistory/index.mjs.map +1 -1
  30. package/dist/SendActivityModal/SendActivityModal.css +19353 -0
  31. package/dist/SendActivityModal/SendActivityModal.css.map +1 -0
  32. package/dist/SendActivityModal/SendActivityModal.d.ts +12 -0
  33. package/dist/SendActivityModal/SendActivityModal.d.ts.map +1 -0
  34. package/dist/SendActivityModal/SendActivityModal.js +6446 -0
  35. package/dist/SendActivityModal/SendActivityModal.js.map +1 -0
  36. package/dist/SendActivityModal/SendActivityModal.mjs +6486 -0
  37. package/dist/SendActivityModal/SendActivityModal.mjs.map +1 -0
  38. package/dist/SendActivityModal/hooks/useSendActivityModal.d.ts +43 -0
  39. package/dist/SendActivityModal/hooks/useSendActivityModal.d.ts.map +1 -0
  40. package/dist/SendActivityModal/hooks/useSendActivityModal.js +269 -0
  41. package/dist/SendActivityModal/hooks/useSendActivityModal.js.map +1 -0
  42. package/dist/SendActivityModal/hooks/useSendActivityModal.mjs +243 -0
  43. package/dist/SendActivityModal/hooks/useSendActivityModal.mjs.map +1 -0
  44. package/dist/SendActivityModal/index.css +28 -2
  45. package/dist/SendActivityModal/index.css.map +1 -1
  46. package/dist/SendActivityModal/types.d.ts +95 -0
  47. package/dist/SendActivityModal/types.d.ts.map +1 -0
  48. package/dist/SendActivityModal/types.js +35 -0
  49. package/dist/SendActivityModal/types.js.map +1 -0
  50. package/dist/SendActivityModal/types.mjs +10 -0
  51. package/dist/SendActivityModal/types.mjs.map +1 -0
  52. package/dist/SendActivityModal/validation.d.ts +133 -0
  53. package/dist/SendActivityModal/validation.d.ts.map +1 -0
  54. package/dist/SendActivityModal/validation.js +178 -0
  55. package/dist/SendActivityModal/validation.js.map +1 -0
  56. package/dist/SendActivityModal/validation.mjs +144 -0
  57. package/dist/SendActivityModal/validation.mjs.map +1 -0
  58. package/dist/TableProvider/index.css +28 -2
  59. package/dist/TableProvider/index.css.map +1 -1
  60. package/dist/hooks/useRecommendedLessonDetails/index.d.ts +780 -0
  61. package/dist/hooks/useRecommendedLessonDetails/index.d.ts.map +1 -0
  62. package/dist/hooks/useRecommendedLessonDetails/index.js +204 -0
  63. package/dist/hooks/useRecommendedLessonDetails/index.js.map +1 -0
  64. package/dist/hooks/useRecommendedLessonDetails/index.mjs +174 -0
  65. package/dist/hooks/useRecommendedLessonDetails/index.mjs.map +1 -0
  66. package/dist/hooks/useRecommendedLessonDetails.d.ts +780 -0
  67. package/dist/hooks/useRecommendedLessonDetails.d.ts.map +1 -0
  68. package/dist/index.css +28 -2
  69. package/dist/index.css.map +1 -1
  70. package/dist/index.d.ts +6 -2
  71. package/dist/index.d.ts.map +1 -1
  72. package/dist/index.js +657 -10
  73. package/dist/index.js.map +1 -1
  74. package/dist/index.mjs +645 -10
  75. package/dist/index.mjs.map +1 -1
  76. package/dist/styles.css +28 -2
  77. package/dist/styles.css.map +1 -1
  78. package/dist/types/recommendedLessons/index.d.ts +156 -0
  79. package/dist/types/recommendedLessons/index.d.ts.map +1 -1
  80. package/dist/types/recommendedLessons/index.js +47 -2
  81. package/dist/types/recommendedLessons/index.js.map +1 -1
  82. package/dist/types/recommendedLessons/index.mjs +41 -1
  83. package/dist/types/recommendedLessons/index.mjs.map +1 -1
  84. package/dist/types/recommendedLessons.d.ts +156 -0
  85. package/dist/types/recommendedLessons.d.ts.map +1 -1
  86. package/package.json +3 -1
@@ -0,0 +1,95 @@
1
+ import type { CategoryConfig } from '../CheckBoxGroup/CheckBoxGroup';
2
+ export type { CategoryConfig, Item } from '../CheckBoxGroup/CheckBoxGroup';
3
+ /**
4
+ * Activity subtype matching backend SIMULATION_SUBTYPE
5
+ */
6
+ export type ActivitySubtype = 'TAREFA' | 'TRABALHO' | 'PROVA';
7
+ /**
8
+ * Activity type options for UI selection
9
+ */
10
+ export declare const ACTIVITY_TYPE_OPTIONS: ReadonlyArray<{
11
+ value: ActivitySubtype;
12
+ label: string;
13
+ }>;
14
+ /**
15
+ * Form data structure for sending activity
16
+ */
17
+ export interface SendActivityFormData {
18
+ /** Activity subtype (Step 1) */
19
+ subtype: ActivitySubtype;
20
+ /** Activity title (Step 1) */
21
+ title: string;
22
+ /** Notification message (Step 1) */
23
+ notification?: string;
24
+ /** Array of students to send activity to (Step 2) */
25
+ students: Array<{
26
+ studentId: string;
27
+ userInstitutionId: string;
28
+ }>;
29
+ /** Start date in YYYY-MM-DD format (Step 3) */
30
+ startDate: string;
31
+ /** Start time in HH:MM format (Step 3) */
32
+ startTime: string;
33
+ /** End date in YYYY-MM-DD format (Step 3) */
34
+ finalDate: string;
35
+ /** End time in HH:MM format (Step 3) */
36
+ finalTime: string;
37
+ /** Allow retry flag (Step 3) */
38
+ canRetry: boolean;
39
+ }
40
+ /**
41
+ * Initial data for pre-filling the modal form
42
+ */
43
+ export interface SendActivityModalInitialData {
44
+ /** Pre-filled activity title */
45
+ title?: string;
46
+ /** Pre-filled activity subtype */
47
+ subtype?: ActivitySubtype;
48
+ /** Pre-filled notification message */
49
+ notification?: string;
50
+ }
51
+ /**
52
+ * Modal props
53
+ */
54
+ export interface SendActivityModalProps {
55
+ /** Controls modal visibility */
56
+ isOpen: boolean;
57
+ /** Callback when modal is closed */
58
+ onClose: () => void;
59
+ /** Callback when activity is submitted */
60
+ onSubmit: (data: SendActivityFormData) => Promise<void>;
61
+ /** Recipient categories configuration (same format as CheckboxGroup) */
62
+ categories: CategoryConfig[];
63
+ /** Callback when categories change (optional - for controlled state) */
64
+ onCategoriesChange?: (categories: CategoryConfig[]) => void;
65
+ /** Loading state for submit button */
66
+ isLoading?: boolean;
67
+ /** Callback when submission fails (optional - if not provided, error propagates) */
68
+ onError?: (error: unknown) => void;
69
+ /** Initial data to pre-fill the form */
70
+ initialData?: SendActivityModalInitialData;
71
+ }
72
+ /**
73
+ * Step validation errors
74
+ */
75
+ export interface StepErrors {
76
+ subtype?: string;
77
+ title?: string;
78
+ students?: string;
79
+ startDate?: string;
80
+ startTime?: string;
81
+ finalDate?: string;
82
+ finalTime?: string;
83
+ }
84
+ /**
85
+ * Step state for stepper
86
+ */
87
+ export type StepState = 'pending' | 'current' | 'completed';
88
+ /**
89
+ * Step configuration
90
+ */
91
+ export interface StepConfig {
92
+ label: string;
93
+ state: StepState;
94
+ }
95
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/components/SendActivityModal/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAC;AAGrE,YAAY,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,gCAAgC,CAAC;AAE3E;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,UAAU,GAAG,OAAO,CAAC;AAE9D;;GAEG;AACH,eAAO,MAAM,qBAAqB,EAAE,aAAa,CAAC;IAChD,KAAK,EAAE,eAAe,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;CACf,CAIS,CAAC;AAEX;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,gCAAgC;IAChC,OAAO,EAAE,eAAe,CAAC;IACzB,8BAA8B;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,oCAAoC;IACpC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qDAAqD;IACrD,QAAQ,EAAE,KAAK,CAAC;QACd,SAAS,EAAE,MAAM,CAAC;QAClB,iBAAiB,EAAE,MAAM,CAAC;KAC3B,CAAC,CAAC;IACH,+CAA+C;IAC/C,SAAS,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,SAAS,EAAE,MAAM,CAAC;IAClB,6CAA6C;IAC7C,SAAS,EAAE,MAAM,CAAC;IAClB,wCAAwC;IACxC,SAAS,EAAE,MAAM,CAAC;IAClB,gCAAgC;IAChC,QAAQ,EAAE,OAAO,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C,gCAAgC;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,kCAAkC;IAClC,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,sCAAsC;IACtC,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,gCAAgC;IAChC,MAAM,EAAE,OAAO,CAAC;IAChB,oCAAoC;IACpC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,0CAA0C;IAC1C,QAAQ,EAAE,CAAC,IAAI,EAAE,oBAAoB,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACxD,wEAAwE;IACxE,UAAU,EAAE,cAAc,EAAE,CAAC;IAC7B,wEAAwE;IACxE,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,cAAc,EAAE,KAAK,IAAI,CAAC;IAC5D,sCAAsC;IACtC,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,oFAAoF;IACpF,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,wCAAwC;IACxC,WAAW,CAAC,EAAE,4BAA4B,CAAC;CAC5C;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,CAAC;AAE5D;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,SAAS,CAAC;CAClB"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/components/SendActivityModal/types.ts
21
+ var types_exports = {};
22
+ __export(types_exports, {
23
+ ACTIVITY_TYPE_OPTIONS: () => ACTIVITY_TYPE_OPTIONS
24
+ });
25
+ module.exports = __toCommonJS(types_exports);
26
+ var ACTIVITY_TYPE_OPTIONS = [
27
+ { value: "TAREFA", label: "Tarefa" },
28
+ { value: "TRABALHO", label: "Trabalho" },
29
+ { value: "PROVA", label: "Prova" }
30
+ ];
31
+ // Annotate the CommonJS export names for ESM import in node:
32
+ 0 && (module.exports = {
33
+ ACTIVITY_TYPE_OPTIONS
34
+ });
35
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/SendActivityModal/types.ts"],"sourcesContent":["import type { CategoryConfig } from '../CheckBoxGroup/CheckBoxGroup';\n\n// Re-export types from CheckboxGroup for easier imports\nexport type { CategoryConfig, Item } from '../CheckBoxGroup/CheckBoxGroup';\n\n/**\n * Activity subtype matching backend SIMULATION_SUBTYPE\n */\nexport type ActivitySubtype = 'TAREFA' | 'TRABALHO' | 'PROVA';\n\n/**\n * Activity type options for UI selection\n */\nexport const ACTIVITY_TYPE_OPTIONS: ReadonlyArray<{\n value: ActivitySubtype;\n label: string;\n}> = [\n { value: 'TAREFA', label: 'Tarefa' },\n { value: 'TRABALHO', label: 'Trabalho' },\n { value: 'PROVA', label: 'Prova' },\n] as const;\n\n/**\n * Form data structure for sending activity\n */\nexport interface SendActivityFormData {\n /** Activity subtype (Step 1) */\n subtype: ActivitySubtype;\n /** Activity title (Step 1) */\n title: string;\n /** Notification message (Step 1) */\n notification?: string;\n /** Array of students to send activity to (Step 2) */\n students: Array<{\n studentId: string;\n userInstitutionId: string;\n }>;\n /** Start date in YYYY-MM-DD format (Step 3) */\n startDate: string;\n /** Start time in HH:MM format (Step 3) */\n startTime: string;\n /** End date in YYYY-MM-DD format (Step 3) */\n finalDate: string;\n /** End time in HH:MM format (Step 3) */\n finalTime: string;\n /** Allow retry flag (Step 3) */\n canRetry: boolean;\n}\n\n/**\n * Initial data for pre-filling the modal form\n */\nexport interface SendActivityModalInitialData {\n /** Pre-filled activity title */\n title?: string;\n /** Pre-filled activity subtype */\n subtype?: ActivitySubtype;\n /** Pre-filled notification message */\n notification?: string;\n}\n\n/**\n * Modal props\n */\nexport interface SendActivityModalProps {\n /** Controls modal visibility */\n isOpen: boolean;\n /** Callback when modal is closed */\n onClose: () => void;\n /** Callback when activity is submitted */\n onSubmit: (data: SendActivityFormData) => Promise<void>;\n /** Recipient categories configuration (same format as CheckboxGroup) */\n categories: CategoryConfig[];\n /** Callback when categories change (optional - for controlled state) */\n onCategoriesChange?: (categories: CategoryConfig[]) => void;\n /** Loading state for submit button */\n isLoading?: boolean;\n /** Callback when submission fails (optional - if not provided, error propagates) */\n onError?: (error: unknown) => void;\n /** Initial data to pre-fill the form */\n initialData?: SendActivityModalInitialData;\n}\n\n/**\n * Step validation errors\n */\nexport interface StepErrors {\n subtype?: string;\n title?: string;\n students?: string;\n startDate?: string;\n startTime?: string;\n finalDate?: string;\n finalTime?: string;\n}\n\n/**\n * Step state for stepper\n */\nexport type StepState = 'pending' | 'current' | 'completed';\n\n/**\n * Step configuration\n */\nexport interface StepConfig {\n label: string;\n state: StepState;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAaO,IAAM,wBAGR;AAAA,EACH,EAAE,OAAO,UAAU,OAAO,SAAS;AAAA,EACnC,EAAE,OAAO,YAAY,OAAO,WAAW;AAAA,EACvC,EAAE,OAAO,SAAS,OAAO,QAAQ;AACnC;","names":[]}
@@ -0,0 +1,10 @@
1
+ // src/components/SendActivityModal/types.ts
2
+ var ACTIVITY_TYPE_OPTIONS = [
3
+ { value: "TAREFA", label: "Tarefa" },
4
+ { value: "TRABALHO", label: "Trabalho" },
5
+ { value: "PROVA", label: "Prova" }
6
+ ];
7
+ export {
8
+ ACTIVITY_TYPE_OPTIONS
9
+ };
10
+ //# sourceMappingURL=types.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/SendActivityModal/types.ts"],"sourcesContent":["import type { CategoryConfig } from '../CheckBoxGroup/CheckBoxGroup';\n\n// Re-export types from CheckboxGroup for easier imports\nexport type { CategoryConfig, Item } from '../CheckBoxGroup/CheckBoxGroup';\n\n/**\n * Activity subtype matching backend SIMULATION_SUBTYPE\n */\nexport type ActivitySubtype = 'TAREFA' | 'TRABALHO' | 'PROVA';\n\n/**\n * Activity type options for UI selection\n */\nexport const ACTIVITY_TYPE_OPTIONS: ReadonlyArray<{\n value: ActivitySubtype;\n label: string;\n}> = [\n { value: 'TAREFA', label: 'Tarefa' },\n { value: 'TRABALHO', label: 'Trabalho' },\n { value: 'PROVA', label: 'Prova' },\n] as const;\n\n/**\n * Form data structure for sending activity\n */\nexport interface SendActivityFormData {\n /** Activity subtype (Step 1) */\n subtype: ActivitySubtype;\n /** Activity title (Step 1) */\n title: string;\n /** Notification message (Step 1) */\n notification?: string;\n /** Array of students to send activity to (Step 2) */\n students: Array<{\n studentId: string;\n userInstitutionId: string;\n }>;\n /** Start date in YYYY-MM-DD format (Step 3) */\n startDate: string;\n /** Start time in HH:MM format (Step 3) */\n startTime: string;\n /** End date in YYYY-MM-DD format (Step 3) */\n finalDate: string;\n /** End time in HH:MM format (Step 3) */\n finalTime: string;\n /** Allow retry flag (Step 3) */\n canRetry: boolean;\n}\n\n/**\n * Initial data for pre-filling the modal form\n */\nexport interface SendActivityModalInitialData {\n /** Pre-filled activity title */\n title?: string;\n /** Pre-filled activity subtype */\n subtype?: ActivitySubtype;\n /** Pre-filled notification message */\n notification?: string;\n}\n\n/**\n * Modal props\n */\nexport interface SendActivityModalProps {\n /** Controls modal visibility */\n isOpen: boolean;\n /** Callback when modal is closed */\n onClose: () => void;\n /** Callback when activity is submitted */\n onSubmit: (data: SendActivityFormData) => Promise<void>;\n /** Recipient categories configuration (same format as CheckboxGroup) */\n categories: CategoryConfig[];\n /** Callback when categories change (optional - for controlled state) */\n onCategoriesChange?: (categories: CategoryConfig[]) => void;\n /** Loading state for submit button */\n isLoading?: boolean;\n /** Callback when submission fails (optional - if not provided, error propagates) */\n onError?: (error: unknown) => void;\n /** Initial data to pre-fill the form */\n initialData?: SendActivityModalInitialData;\n}\n\n/**\n * Step validation errors\n */\nexport interface StepErrors {\n subtype?: string;\n title?: string;\n students?: string;\n startDate?: string;\n startTime?: string;\n finalDate?: string;\n finalTime?: string;\n}\n\n/**\n * Step state for stepper\n */\nexport type StepState = 'pending' | 'current' | 'completed';\n\n/**\n * Step configuration\n */\nexport interface StepConfig {\n label: string;\n state: StepState;\n}\n"],"mappings":";AAaO,IAAM,wBAGR;AAAA,EACH,EAAE,OAAO,UAAU,OAAO,SAAS;AAAA,EACnC,EAAE,OAAO,YAAY,OAAO,WAAW;AAAA,EACvC,EAAE,OAAO,SAAS,OAAO,QAAQ;AACnC;","names":[]}
@@ -0,0 +1,133 @@
1
+ import { z } from 'zod';
2
+ import { SendActivityFormData, StepErrors } from './types';
3
+ /**
4
+ * Error messages for validation
5
+ */
6
+ export declare const ERROR_MESSAGES: {
7
+ readonly SUBTYPE_REQUIRED: "Campo obrigatório! Por favor, selecione uma opção para continuar.";
8
+ readonly TITLE_REQUIRED: "Campo obrigatório! Por favor, preencha este campo para continuar.";
9
+ readonly STUDENTS_REQUIRED: "Campo obrigatório! Por favor, selecione pelo menos um aluno para continuar.";
10
+ readonly START_DATE_REQUIRED: "Campo obrigatório! Por favor, preencha este campo para continuar.";
11
+ readonly FINAL_DATE_REQUIRED: "Campo obrigatório! Por favor, preencha este campo para continuar.";
12
+ readonly FINAL_DATE_INVALID: "A data final deve ser maior ou igual à data inicial.";
13
+ };
14
+ /**
15
+ * Zod schema for activity step (Step 1)
16
+ */
17
+ export declare const activityStepSchema: z.ZodObject<{
18
+ subtype: z.ZodEnum<["TAREFA", "TRABALHO", "PROVA"]>;
19
+ title: z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>;
20
+ notification: z.ZodOptional<z.ZodString>;
21
+ }, "strip", z.ZodTypeAny, {
22
+ title: string;
23
+ subtype: "PROVA" | "TAREFA" | "TRABALHO";
24
+ notification?: string | undefined;
25
+ }, {
26
+ title: string;
27
+ subtype: "PROVA" | "TAREFA" | "TRABALHO";
28
+ notification?: string | undefined;
29
+ }>;
30
+ /**
31
+ * Zod schema for recipient step (Step 2)
32
+ */
33
+ export declare const recipientStepSchema: z.ZodObject<{
34
+ students: z.ZodArray<z.ZodObject<{
35
+ studentId: z.ZodString;
36
+ userInstitutionId: z.ZodString;
37
+ }, "strip", z.ZodTypeAny, {
38
+ studentId: string;
39
+ userInstitutionId: string;
40
+ }, {
41
+ studentId: string;
42
+ userInstitutionId: string;
43
+ }>, "many">;
44
+ }, "strip", z.ZodTypeAny, {
45
+ students: {
46
+ studentId: string;
47
+ userInstitutionId: string;
48
+ }[];
49
+ }, {
50
+ students: {
51
+ studentId: string;
52
+ userInstitutionId: string;
53
+ }[];
54
+ }>;
55
+ /**
56
+ * Zod schema for deadline step with date comparison refinement
57
+ */
58
+ export declare const deadlineStepSchema: z.ZodEffects<z.ZodObject<{
59
+ startDate: z.ZodString;
60
+ startTime: z.ZodDefault<z.ZodString>;
61
+ finalDate: z.ZodString;
62
+ finalTime: z.ZodDefault<z.ZodString>;
63
+ canRetry: z.ZodDefault<z.ZodBoolean>;
64
+ }, "strip", z.ZodTypeAny, {
65
+ canRetry: boolean;
66
+ startDate: string;
67
+ startTime: string;
68
+ finalDate: string;
69
+ finalTime: string;
70
+ }, {
71
+ startDate: string;
72
+ finalDate: string;
73
+ canRetry?: boolean | undefined;
74
+ startTime?: string | undefined;
75
+ finalTime?: string | undefined;
76
+ }>, {
77
+ canRetry: boolean;
78
+ startDate: string;
79
+ startTime: string;
80
+ finalDate: string;
81
+ finalTime: string;
82
+ }, {
83
+ startDate: string;
84
+ finalDate: string;
85
+ canRetry?: boolean | undefined;
86
+ startTime?: string | undefined;
87
+ finalTime?: string | undefined;
88
+ }>;
89
+ /**
90
+ * Type inference from Zod schemas
91
+ */
92
+ export type ActivityStepData = z.infer<typeof activityStepSchema>;
93
+ export type RecipientStepData = z.infer<typeof recipientStepSchema>;
94
+ export type DeadlineStepData = z.infer<typeof deadlineStepSchema>;
95
+ /**
96
+ * Validates the activity step (Step 1) using Zod
97
+ * @param data - Partial form data
98
+ * @returns StepErrors object with any validation errors
99
+ */
100
+ export declare function validateActivityStep(data: Partial<SendActivityFormData>): StepErrors;
101
+ /**
102
+ * Validates the recipient step (Step 2) using Zod
103
+ * @param data - Partial form data
104
+ * @returns StepErrors object with any validation errors
105
+ */
106
+ export declare function validateRecipientStep(data: Partial<SendActivityFormData>): StepErrors;
107
+ /**
108
+ * Validates the deadline step (Step 3) using Zod
109
+ * @param data - Partial form data
110
+ * @returns StepErrors object with any validation errors
111
+ */
112
+ export declare function validateDeadlineStep(data: Partial<SendActivityFormData>): StepErrors;
113
+ /**
114
+ * Validates a specific step
115
+ * @param step - Step number (1, 2, or 3)
116
+ * @param data - Partial form data
117
+ * @returns StepErrors object with any validation errors
118
+ */
119
+ export declare function validateStep(step: number, data: Partial<SendActivityFormData>): StepErrors;
120
+ /**
121
+ * Checks if a specific step is valid
122
+ * @param step - Step number (1, 2, or 3)
123
+ * @param data - Partial form data
124
+ * @returns true if the step is valid
125
+ */
126
+ export declare function isStepValid(step: number, data: Partial<SendActivityFormData>): boolean;
127
+ /**
128
+ * Checks if all steps are valid (form can be submitted)
129
+ * @param data - Partial form data
130
+ * @returns true if all steps are valid
131
+ */
132
+ export declare function isFormValid(data: Partial<SendActivityFormData>): boolean;
133
+ //# sourceMappingURL=validation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validation.d.ts","sourceRoot":"","sources":["../../../src/components/SendActivityModal/validation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AACxB,OAAO,EAAE,oBAAoB,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE3D;;GAEG;AACH,eAAO,MAAM,cAAc;;;;;;;CAYjB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;EAW7B,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;EAa9B,CAAC;AA+BH;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAO9B,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAClE,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AACpE,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAElE;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAClC,UAAU,CAmBZ;AAED;;;;GAIG;AACH,wBAAgB,qBAAqB,CACnC,IAAI,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAClC,UAAU,CAgBZ;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAClC,UAAU,CAiCZ;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAC1B,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAClC,UAAU,CAWZ;AAED;;;;;GAKG;AACH,wBAAgB,WAAW,CACzB,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAClC,OAAO,CAGT;AAED;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,IAAI,EAAE,OAAO,CAAC,oBAAoB,CAAC,GAAG,OAAO,CAExE"}
@@ -0,0 +1,178 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/components/SendActivityModal/validation.ts
21
+ var validation_exports = {};
22
+ __export(validation_exports, {
23
+ ERROR_MESSAGES: () => ERROR_MESSAGES,
24
+ activityStepSchema: () => activityStepSchema,
25
+ deadlineStepSchema: () => deadlineStepSchema,
26
+ isFormValid: () => isFormValid,
27
+ isStepValid: () => isStepValid,
28
+ recipientStepSchema: () => recipientStepSchema,
29
+ validateActivityStep: () => validateActivityStep,
30
+ validateDeadlineStep: () => validateDeadlineStep,
31
+ validateRecipientStep: () => validateRecipientStep,
32
+ validateStep: () => validateStep
33
+ });
34
+ module.exports = __toCommonJS(validation_exports);
35
+ var import_zod = require("zod");
36
+ var ERROR_MESSAGES = {
37
+ SUBTYPE_REQUIRED: "Campo obrigat\xF3rio! Por favor, selecione uma op\xE7\xE3o para continuar.",
38
+ TITLE_REQUIRED: "Campo obrigat\xF3rio! Por favor, preencha este campo para continuar.",
39
+ STUDENTS_REQUIRED: "Campo obrigat\xF3rio! Por favor, selecione pelo menos um aluno para continuar.",
40
+ START_DATE_REQUIRED: "Campo obrigat\xF3rio! Por favor, preencha este campo para continuar.",
41
+ FINAL_DATE_REQUIRED: "Campo obrigat\xF3rio! Por favor, preencha este campo para continuar.",
42
+ FINAL_DATE_INVALID: "A data final deve ser maior ou igual \xE0 data inicial."
43
+ };
44
+ var activityStepSchema = import_zod.z.object({
45
+ subtype: import_zod.z.enum(["TAREFA", "TRABALHO", "PROVA"], {
46
+ errorMap: () => ({ message: ERROR_MESSAGES.SUBTYPE_REQUIRED })
47
+ }),
48
+ title: import_zod.z.string({ required_error: ERROR_MESSAGES.TITLE_REQUIRED }).transform((val) => val.trim()).refine((val) => val.length > 0, {
49
+ message: ERROR_MESSAGES.TITLE_REQUIRED
50
+ }),
51
+ notification: import_zod.z.string().optional()
52
+ });
53
+ var recipientStepSchema = import_zod.z.object({
54
+ students: import_zod.z.array(
55
+ import_zod.z.object({
56
+ studentId: import_zod.z.string(),
57
+ userInstitutionId: import_zod.z.string()
58
+ }),
59
+ {
60
+ required_error: ERROR_MESSAGES.STUDENTS_REQUIRED,
61
+ invalid_type_error: ERROR_MESSAGES.STUDENTS_REQUIRED
62
+ }
63
+ ).min(1, ERROR_MESSAGES.STUDENTS_REQUIRED)
64
+ });
65
+ var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
66
+ var TIME_REGEX = /^\d{2}:\d{2}$/;
67
+ var deadlineStepBaseSchema = import_zod.z.object({
68
+ startDate: import_zod.z.string({
69
+ required_error: ERROR_MESSAGES.START_DATE_REQUIRED,
70
+ invalid_type_error: ERROR_MESSAGES.START_DATE_REQUIRED
71
+ }).min(1, ERROR_MESSAGES.START_DATE_REQUIRED).regex(DATE_REGEX, ERROR_MESSAGES.START_DATE_REQUIRED),
72
+ startTime: import_zod.z.string().regex(TIME_REGEX).default("00:00"),
73
+ finalDate: import_zod.z.string({
74
+ required_error: ERROR_MESSAGES.FINAL_DATE_REQUIRED,
75
+ invalid_type_error: ERROR_MESSAGES.FINAL_DATE_REQUIRED
76
+ }).min(1, ERROR_MESSAGES.FINAL_DATE_REQUIRED).regex(DATE_REGEX, ERROR_MESSAGES.FINAL_DATE_REQUIRED),
77
+ finalTime: import_zod.z.string().regex(TIME_REGEX).default("23:59"),
78
+ canRetry: import_zod.z.boolean().default(false)
79
+ });
80
+ var deadlineStepSchema = deadlineStepBaseSchema.refine(
81
+ (data) => {
82
+ const start = /* @__PURE__ */ new Date(`${data.startDate}T${data.startTime}`);
83
+ const end = /* @__PURE__ */ new Date(`${data.finalDate}T${data.finalTime}`);
84
+ return end >= start;
85
+ },
86
+ { message: ERROR_MESSAGES.FINAL_DATE_INVALID, path: ["finalDate"] }
87
+ );
88
+ function validateActivityStep(data) {
89
+ const errors = {};
90
+ const result = activityStepSchema.safeParse({
91
+ subtype: data.subtype,
92
+ title: data.title,
93
+ notification: data.notification
94
+ });
95
+ if (!result.success) {
96
+ result.error.issues.forEach((issue) => {
97
+ const field = issue.path[0];
98
+ if (field === "subtype" || field === "title") {
99
+ errors[field] = issue.message;
100
+ }
101
+ });
102
+ }
103
+ return errors;
104
+ }
105
+ function validateRecipientStep(data) {
106
+ const errors = {};
107
+ const result = recipientStepSchema.safeParse({
108
+ students: data.students
109
+ });
110
+ if (!result.success) {
111
+ result.error.issues.forEach((issue) => {
112
+ if (issue.path[0] === "students") {
113
+ errors.students = issue.message;
114
+ }
115
+ });
116
+ }
117
+ return errors;
118
+ }
119
+ function validateDeadlineStep(data) {
120
+ const errors = {};
121
+ if (!data.startDate) {
122
+ errors.startDate = ERROR_MESSAGES.START_DATE_REQUIRED;
123
+ }
124
+ if (!data.finalDate) {
125
+ errors.finalDate = ERROR_MESSAGES.FINAL_DATE_REQUIRED;
126
+ }
127
+ if (data.startDate && data.finalDate) {
128
+ const result = deadlineStepSchema.safeParse({
129
+ startDate: data.startDate,
130
+ startTime: data.startTime ?? "00:00",
131
+ finalDate: data.finalDate,
132
+ finalTime: data.finalTime ?? "23:59",
133
+ canRetry: data.canRetry ?? false
134
+ });
135
+ if (!result.success) {
136
+ result.error.issues.forEach((issue) => {
137
+ const field = issue.path[0];
138
+ if (field === "startDate" || field === "finalDate") {
139
+ errors[field] = issue.message;
140
+ }
141
+ });
142
+ }
143
+ }
144
+ return errors;
145
+ }
146
+ function validateStep(step, data) {
147
+ switch (step) {
148
+ case 1:
149
+ return validateActivityStep(data);
150
+ case 2:
151
+ return validateRecipientStep(data);
152
+ case 3:
153
+ return validateDeadlineStep(data);
154
+ default:
155
+ return {};
156
+ }
157
+ }
158
+ function isStepValid(step, data) {
159
+ const errors = validateStep(step, data);
160
+ return Object.keys(errors).length === 0;
161
+ }
162
+ function isFormValid(data) {
163
+ return isStepValid(1, data) && isStepValid(2, data) && isStepValid(3, data);
164
+ }
165
+ // Annotate the CommonJS export names for ESM import in node:
166
+ 0 && (module.exports = {
167
+ ERROR_MESSAGES,
168
+ activityStepSchema,
169
+ deadlineStepSchema,
170
+ isFormValid,
171
+ isStepValid,
172
+ recipientStepSchema,
173
+ validateActivityStep,
174
+ validateDeadlineStep,
175
+ validateRecipientStep,
176
+ validateStep
177
+ });
178
+ //# sourceMappingURL=validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/components/SendActivityModal/validation.ts"],"sourcesContent":["import { z } from 'zod';\nimport { SendActivityFormData, StepErrors } from './types';\n\n/**\n * Error messages for validation\n */\nexport const ERROR_MESSAGES = {\n SUBTYPE_REQUIRED:\n 'Campo obrigatório! Por favor, selecione uma opção para continuar.',\n TITLE_REQUIRED:\n 'Campo obrigatório! Por favor, preencha este campo para continuar.',\n STUDENTS_REQUIRED:\n 'Campo obrigatório! Por favor, selecione pelo menos um aluno para continuar.',\n START_DATE_REQUIRED:\n 'Campo obrigatório! Por favor, preencha este campo para continuar.',\n FINAL_DATE_REQUIRED:\n 'Campo obrigatório! Por favor, preencha este campo para continuar.',\n FINAL_DATE_INVALID: 'A data final deve ser maior ou igual à data inicial.',\n} as const;\n\n/**\n * Zod schema for activity step (Step 1)\n */\nexport const activityStepSchema = z.object({\n subtype: z.enum(['TAREFA', 'TRABALHO', 'PROVA'], {\n errorMap: () => ({ message: ERROR_MESSAGES.SUBTYPE_REQUIRED }),\n }),\n title: z\n .string({ required_error: ERROR_MESSAGES.TITLE_REQUIRED })\n .transform((val) => val.trim())\n .refine((val) => val.length > 0, {\n message: ERROR_MESSAGES.TITLE_REQUIRED,\n }),\n notification: z.string().optional(),\n});\n\n/**\n * Zod schema for recipient step (Step 2)\n */\nexport const recipientStepSchema = z.object({\n students: z\n .array(\n z.object({\n studentId: z.string(),\n userInstitutionId: z.string(),\n }),\n {\n required_error: ERROR_MESSAGES.STUDENTS_REQUIRED,\n invalid_type_error: ERROR_MESSAGES.STUDENTS_REQUIRED,\n }\n )\n .min(1, ERROR_MESSAGES.STUDENTS_REQUIRED),\n});\n\n/**\n * Regex patterns for date and time validation\n */\nconst DATE_REGEX = /^\\d{4}-\\d{2}-\\d{2}$/;\nconst TIME_REGEX = /^\\d{2}:\\d{2}$/;\n\n/**\n * Zod schema for deadline step (Step 3) - base validation\n */\nconst deadlineStepBaseSchema = z.object({\n startDate: z\n .string({\n required_error: ERROR_MESSAGES.START_DATE_REQUIRED,\n invalid_type_error: ERROR_MESSAGES.START_DATE_REQUIRED,\n })\n .min(1, ERROR_MESSAGES.START_DATE_REQUIRED)\n .regex(DATE_REGEX, ERROR_MESSAGES.START_DATE_REQUIRED),\n startTime: z.string().regex(TIME_REGEX).default('00:00'),\n finalDate: z\n .string({\n required_error: ERROR_MESSAGES.FINAL_DATE_REQUIRED,\n invalid_type_error: ERROR_MESSAGES.FINAL_DATE_REQUIRED,\n })\n .min(1, ERROR_MESSAGES.FINAL_DATE_REQUIRED)\n .regex(DATE_REGEX, ERROR_MESSAGES.FINAL_DATE_REQUIRED),\n finalTime: z.string().regex(TIME_REGEX).default('23:59'),\n canRetry: z.boolean().default(false),\n});\n\n/**\n * Zod schema for deadline step with date comparison refinement\n */\nexport const deadlineStepSchema = deadlineStepBaseSchema.refine(\n (data) => {\n const start = new Date(`${data.startDate}T${data.startTime}`);\n const end = new Date(`${data.finalDate}T${data.finalTime}`);\n return end >= start;\n },\n { message: ERROR_MESSAGES.FINAL_DATE_INVALID, path: ['finalDate'] }\n);\n\n/**\n * Type inference from Zod schemas\n */\nexport type ActivityStepData = z.infer<typeof activityStepSchema>;\nexport type RecipientStepData = z.infer<typeof recipientStepSchema>;\nexport type DeadlineStepData = z.infer<typeof deadlineStepSchema>;\n\n/**\n * Validates the activity step (Step 1) using Zod\n * @param data - Partial form data\n * @returns StepErrors object with any validation errors\n */\nexport function validateActivityStep(\n data: Partial<SendActivityFormData>\n): StepErrors {\n const errors: StepErrors = {};\n\n const result = activityStepSchema.safeParse({\n subtype: data.subtype,\n title: data.title,\n notification: data.notification,\n });\n\n if (!result.success) {\n result.error.issues.forEach((issue) => {\n const field = issue.path[0] as keyof StepErrors;\n if (field === 'subtype' || field === 'title') {\n errors[field] = issue.message;\n }\n });\n }\n\n return errors;\n}\n\n/**\n * Validates the recipient step (Step 2) using Zod\n * @param data - Partial form data\n * @returns StepErrors object with any validation errors\n */\nexport function validateRecipientStep(\n data: Partial<SendActivityFormData>\n): StepErrors {\n const errors: StepErrors = {};\n\n const result = recipientStepSchema.safeParse({\n students: data.students,\n });\n\n if (!result.success) {\n result.error.issues.forEach((issue) => {\n if (issue.path[0] === 'students') {\n errors.students = issue.message;\n }\n });\n }\n\n return errors;\n}\n\n/**\n * Validates the deadline step (Step 3) using Zod\n * @param data - Partial form data\n * @returns StepErrors object with any validation errors\n */\nexport function validateDeadlineStep(\n data: Partial<SendActivityFormData>\n): StepErrors {\n const errors: StepErrors = {};\n\n // First validate individual fields\n if (!data.startDate) {\n errors.startDate = ERROR_MESSAGES.START_DATE_REQUIRED;\n }\n\n if (!data.finalDate) {\n errors.finalDate = ERROR_MESSAGES.FINAL_DATE_REQUIRED;\n }\n\n // If both dates exist, validate with the full schema (including refinement)\n if (data.startDate && data.finalDate) {\n const result = deadlineStepSchema.safeParse({\n startDate: data.startDate,\n startTime: data.startTime ?? '00:00',\n finalDate: data.finalDate,\n finalTime: data.finalTime ?? '23:59',\n canRetry: data.canRetry ?? false,\n });\n\n if (!result.success) {\n result.error.issues.forEach((issue) => {\n const field = issue.path[0] as keyof StepErrors;\n if (field === 'startDate' || field === 'finalDate') {\n errors[field] = issue.message;\n }\n });\n }\n }\n\n return errors;\n}\n\n/**\n * Validates a specific step\n * @param step - Step number (1, 2, or 3)\n * @param data - Partial form data\n * @returns StepErrors object with any validation errors\n */\nexport function validateStep(\n step: number,\n data: Partial<SendActivityFormData>\n): StepErrors {\n switch (step) {\n case 1:\n return validateActivityStep(data);\n case 2:\n return validateRecipientStep(data);\n case 3:\n return validateDeadlineStep(data);\n default:\n return {};\n }\n}\n\n/**\n * Checks if a specific step is valid\n * @param step - Step number (1, 2, or 3)\n * @param data - Partial form data\n * @returns true if the step is valid\n */\nexport function isStepValid(\n step: number,\n data: Partial<SendActivityFormData>\n): boolean {\n const errors = validateStep(step, data);\n return Object.keys(errors).length === 0;\n}\n\n/**\n * Checks if all steps are valid (form can be submitted)\n * @param data - Partial form data\n * @returns true if all steps are valid\n */\nexport function isFormValid(data: Partial<SendActivityFormData>): boolean {\n return isStepValid(1, data) && isStepValid(2, data) && isStepValid(3, data);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,iBAAkB;AAMX,IAAM,iBAAiB;AAAA,EAC5B,kBACE;AAAA,EACF,gBACE;AAAA,EACF,mBACE;AAAA,EACF,qBACE;AAAA,EACF,qBACE;AAAA,EACF,oBAAoB;AACtB;AAKO,IAAM,qBAAqB,aAAE,OAAO;AAAA,EACzC,SAAS,aAAE,KAAK,CAAC,UAAU,YAAY,OAAO,GAAG;AAAA,IAC/C,UAAU,OAAO,EAAE,SAAS,eAAe,iBAAiB;AAAA,EAC9D,CAAC;AAAA,EACD,OAAO,aACJ,OAAO,EAAE,gBAAgB,eAAe,eAAe,CAAC,EACxD,UAAU,CAAC,QAAQ,IAAI,KAAK,CAAC,EAC7B,OAAO,CAAC,QAAQ,IAAI,SAAS,GAAG;AAAA,IAC/B,SAAS,eAAe;AAAA,EAC1B,CAAC;AAAA,EACH,cAAc,aAAE,OAAO,EAAE,SAAS;AACpC,CAAC;AAKM,IAAM,sBAAsB,aAAE,OAAO;AAAA,EAC1C,UAAU,aACP;AAAA,IACC,aAAE,OAAO;AAAA,MACP,WAAW,aAAE,OAAO;AAAA,MACpB,mBAAmB,aAAE,OAAO;AAAA,IAC9B,CAAC;AAAA,IACD;AAAA,MACE,gBAAgB,eAAe;AAAA,MAC/B,oBAAoB,eAAe;AAAA,IACrC;AAAA,EACF,EACC,IAAI,GAAG,eAAe,iBAAiB;AAC5C,CAAC;AAKD,IAAM,aAAa;AACnB,IAAM,aAAa;AAKnB,IAAM,yBAAyB,aAAE,OAAO;AAAA,EACtC,WAAW,aACR,OAAO;AAAA,IACN,gBAAgB,eAAe;AAAA,IAC/B,oBAAoB,eAAe;AAAA,EACrC,CAAC,EACA,IAAI,GAAG,eAAe,mBAAmB,EACzC,MAAM,YAAY,eAAe,mBAAmB;AAAA,EACvD,WAAW,aAAE,OAAO,EAAE,MAAM,UAAU,EAAE,QAAQ,OAAO;AAAA,EACvD,WAAW,aACR,OAAO;AAAA,IACN,gBAAgB,eAAe;AAAA,IAC/B,oBAAoB,eAAe;AAAA,EACrC,CAAC,EACA,IAAI,GAAG,eAAe,mBAAmB,EACzC,MAAM,YAAY,eAAe,mBAAmB;AAAA,EACvD,WAAW,aAAE,OAAO,EAAE,MAAM,UAAU,EAAE,QAAQ,OAAO;AAAA,EACvD,UAAU,aAAE,QAAQ,EAAE,QAAQ,KAAK;AACrC,CAAC;AAKM,IAAM,qBAAqB,uBAAuB;AAAA,EACvD,CAAC,SAAS;AACR,UAAM,QAAQ,oBAAI,KAAK,GAAG,KAAK,SAAS,IAAI,KAAK,SAAS,EAAE;AAC5D,UAAM,MAAM,oBAAI,KAAK,GAAG,KAAK,SAAS,IAAI,KAAK,SAAS,EAAE;AAC1D,WAAO,OAAO;AAAA,EAChB;AAAA,EACA,EAAE,SAAS,eAAe,oBAAoB,MAAM,CAAC,WAAW,EAAE;AACpE;AAcO,SAAS,qBACd,MACY;AACZ,QAAM,SAAqB,CAAC;AAE5B,QAAM,SAAS,mBAAmB,UAAU;AAAA,IAC1C,SAAS,KAAK;AAAA,IACd,OAAO,KAAK;AAAA,IACZ,cAAc,KAAK;AAAA,EACrB,CAAC;AAED,MAAI,CAAC,OAAO,SAAS;AACnB,WAAO,MAAM,OAAO,QAAQ,CAAC,UAAU;AACrC,YAAM,QAAQ,MAAM,KAAK,CAAC;AAC1B,UAAI,UAAU,aAAa,UAAU,SAAS;AAC5C,eAAO,KAAK,IAAI,MAAM;AAAA,MACxB;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAOO,SAAS,sBACd,MACY;AACZ,QAAM,SAAqB,CAAC;AAE5B,QAAM,SAAS,oBAAoB,UAAU;AAAA,IAC3C,UAAU,KAAK;AAAA,EACjB,CAAC;AAED,MAAI,CAAC,OAAO,SAAS;AACnB,WAAO,MAAM,OAAO,QAAQ,CAAC,UAAU;AACrC,UAAI,MAAM,KAAK,CAAC,MAAM,YAAY;AAChC,eAAO,WAAW,MAAM;AAAA,MAC1B;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO;AACT;AAOO,SAAS,qBACd,MACY;AACZ,QAAM,SAAqB,CAAC;AAG5B,MAAI,CAAC,KAAK,WAAW;AACnB,WAAO,YAAY,eAAe;AAAA,EACpC;AAEA,MAAI,CAAC,KAAK,WAAW;AACnB,WAAO,YAAY,eAAe;AAAA,EACpC;AAGA,MAAI,KAAK,aAAa,KAAK,WAAW;AACpC,UAAM,SAAS,mBAAmB,UAAU;AAAA,MAC1C,WAAW,KAAK;AAAA,MAChB,WAAW,KAAK,aAAa;AAAA,MAC7B,WAAW,KAAK;AAAA,MAChB,WAAW,KAAK,aAAa;AAAA,MAC7B,UAAU,KAAK,YAAY;AAAA,IAC7B,CAAC;AAED,QAAI,CAAC,OAAO,SAAS;AACnB,aAAO,MAAM,OAAO,QAAQ,CAAC,UAAU;AACrC,cAAM,QAAQ,MAAM,KAAK,CAAC;AAC1B,YAAI,UAAU,eAAe,UAAU,aAAa;AAClD,iBAAO,KAAK,IAAI,MAAM;AAAA,QACxB;AAAA,MACF,CAAC;AAAA,IACH;AAAA,EACF;AAEA,SAAO;AACT;AAQO,SAAS,aACd,MACA,MACY;AACZ,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO,qBAAqB,IAAI;AAAA,IAClC,KAAK;AACH,aAAO,sBAAsB,IAAI;AAAA,IACnC,KAAK;AACH,aAAO,qBAAqB,IAAI;AAAA,IAClC;AACE,aAAO,CAAC;AAAA,EACZ;AACF;AAQO,SAAS,YACd,MACA,MACS;AACT,QAAM,SAAS,aAAa,MAAM,IAAI;AACtC,SAAO,OAAO,KAAK,MAAM,EAAE,WAAW;AACxC;AAOO,SAAS,YAAY,MAA8C;AACxE,SAAO,YAAY,GAAG,IAAI,KAAK,YAAY,GAAG,IAAI,KAAK,YAAY,GAAG,IAAI;AAC5E;","names":[]}
@@ -0,0 +1,144 @@
1
+ // src/components/SendActivityModal/validation.ts
2
+ import { z } from "zod";
3
+ var ERROR_MESSAGES = {
4
+ SUBTYPE_REQUIRED: "Campo obrigat\xF3rio! Por favor, selecione uma op\xE7\xE3o para continuar.",
5
+ TITLE_REQUIRED: "Campo obrigat\xF3rio! Por favor, preencha este campo para continuar.",
6
+ STUDENTS_REQUIRED: "Campo obrigat\xF3rio! Por favor, selecione pelo menos um aluno para continuar.",
7
+ START_DATE_REQUIRED: "Campo obrigat\xF3rio! Por favor, preencha este campo para continuar.",
8
+ FINAL_DATE_REQUIRED: "Campo obrigat\xF3rio! Por favor, preencha este campo para continuar.",
9
+ FINAL_DATE_INVALID: "A data final deve ser maior ou igual \xE0 data inicial."
10
+ };
11
+ var activityStepSchema = z.object({
12
+ subtype: z.enum(["TAREFA", "TRABALHO", "PROVA"], {
13
+ errorMap: () => ({ message: ERROR_MESSAGES.SUBTYPE_REQUIRED })
14
+ }),
15
+ title: z.string({ required_error: ERROR_MESSAGES.TITLE_REQUIRED }).transform((val) => val.trim()).refine((val) => val.length > 0, {
16
+ message: ERROR_MESSAGES.TITLE_REQUIRED
17
+ }),
18
+ notification: z.string().optional()
19
+ });
20
+ var recipientStepSchema = z.object({
21
+ students: z.array(
22
+ z.object({
23
+ studentId: z.string(),
24
+ userInstitutionId: z.string()
25
+ }),
26
+ {
27
+ required_error: ERROR_MESSAGES.STUDENTS_REQUIRED,
28
+ invalid_type_error: ERROR_MESSAGES.STUDENTS_REQUIRED
29
+ }
30
+ ).min(1, ERROR_MESSAGES.STUDENTS_REQUIRED)
31
+ });
32
+ var DATE_REGEX = /^\d{4}-\d{2}-\d{2}$/;
33
+ var TIME_REGEX = /^\d{2}:\d{2}$/;
34
+ var deadlineStepBaseSchema = z.object({
35
+ startDate: z.string({
36
+ required_error: ERROR_MESSAGES.START_DATE_REQUIRED,
37
+ invalid_type_error: ERROR_MESSAGES.START_DATE_REQUIRED
38
+ }).min(1, ERROR_MESSAGES.START_DATE_REQUIRED).regex(DATE_REGEX, ERROR_MESSAGES.START_DATE_REQUIRED),
39
+ startTime: z.string().regex(TIME_REGEX).default("00:00"),
40
+ finalDate: z.string({
41
+ required_error: ERROR_MESSAGES.FINAL_DATE_REQUIRED,
42
+ invalid_type_error: ERROR_MESSAGES.FINAL_DATE_REQUIRED
43
+ }).min(1, ERROR_MESSAGES.FINAL_DATE_REQUIRED).regex(DATE_REGEX, ERROR_MESSAGES.FINAL_DATE_REQUIRED),
44
+ finalTime: z.string().regex(TIME_REGEX).default("23:59"),
45
+ canRetry: z.boolean().default(false)
46
+ });
47
+ var deadlineStepSchema = deadlineStepBaseSchema.refine(
48
+ (data) => {
49
+ const start = /* @__PURE__ */ new Date(`${data.startDate}T${data.startTime}`);
50
+ const end = /* @__PURE__ */ new Date(`${data.finalDate}T${data.finalTime}`);
51
+ return end >= start;
52
+ },
53
+ { message: ERROR_MESSAGES.FINAL_DATE_INVALID, path: ["finalDate"] }
54
+ );
55
+ function validateActivityStep(data) {
56
+ const errors = {};
57
+ const result = activityStepSchema.safeParse({
58
+ subtype: data.subtype,
59
+ title: data.title,
60
+ notification: data.notification
61
+ });
62
+ if (!result.success) {
63
+ result.error.issues.forEach((issue) => {
64
+ const field = issue.path[0];
65
+ if (field === "subtype" || field === "title") {
66
+ errors[field] = issue.message;
67
+ }
68
+ });
69
+ }
70
+ return errors;
71
+ }
72
+ function validateRecipientStep(data) {
73
+ const errors = {};
74
+ const result = recipientStepSchema.safeParse({
75
+ students: data.students
76
+ });
77
+ if (!result.success) {
78
+ result.error.issues.forEach((issue) => {
79
+ if (issue.path[0] === "students") {
80
+ errors.students = issue.message;
81
+ }
82
+ });
83
+ }
84
+ return errors;
85
+ }
86
+ function validateDeadlineStep(data) {
87
+ const errors = {};
88
+ if (!data.startDate) {
89
+ errors.startDate = ERROR_MESSAGES.START_DATE_REQUIRED;
90
+ }
91
+ if (!data.finalDate) {
92
+ errors.finalDate = ERROR_MESSAGES.FINAL_DATE_REQUIRED;
93
+ }
94
+ if (data.startDate && data.finalDate) {
95
+ const result = deadlineStepSchema.safeParse({
96
+ startDate: data.startDate,
97
+ startTime: data.startTime ?? "00:00",
98
+ finalDate: data.finalDate,
99
+ finalTime: data.finalTime ?? "23:59",
100
+ canRetry: data.canRetry ?? false
101
+ });
102
+ if (!result.success) {
103
+ result.error.issues.forEach((issue) => {
104
+ const field = issue.path[0];
105
+ if (field === "startDate" || field === "finalDate") {
106
+ errors[field] = issue.message;
107
+ }
108
+ });
109
+ }
110
+ }
111
+ return errors;
112
+ }
113
+ function validateStep(step, data) {
114
+ switch (step) {
115
+ case 1:
116
+ return validateActivityStep(data);
117
+ case 2:
118
+ return validateRecipientStep(data);
119
+ case 3:
120
+ return validateDeadlineStep(data);
121
+ default:
122
+ return {};
123
+ }
124
+ }
125
+ function isStepValid(step, data) {
126
+ const errors = validateStep(step, data);
127
+ return Object.keys(errors).length === 0;
128
+ }
129
+ function isFormValid(data) {
130
+ return isStepValid(1, data) && isStepValid(2, data) && isStepValid(3, data);
131
+ }
132
+ export {
133
+ ERROR_MESSAGES,
134
+ activityStepSchema,
135
+ deadlineStepSchema,
136
+ isFormValid,
137
+ isStepValid,
138
+ recipientStepSchema,
139
+ validateActivityStep,
140
+ validateDeadlineStep,
141
+ validateRecipientStep,
142
+ validateStep
143
+ };
144
+ //# sourceMappingURL=validation.mjs.map