@careflair/common 1.0.13 → 1.0.15
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.
- package/dist/schemas/forms.d.ts +4 -4
- package/dist/schemas/userValiationSchema.d.ts +30 -10
- package/dist/schemas/userValiationSchema.js +37 -27
- package/dist/schemas/validation.d.ts +4 -4
- package/dist/utils/index.d.ts +2 -6
- package/dist/utils/index.js +2 -12
- package/dist/utils/onboarding.d.ts +141 -0
- package/dist/utils/onboarding.js +67 -0
- package/package.json +3 -3
package/dist/schemas/forms.d.ts
CHANGED
|
@@ -15,36 +15,36 @@ export declare const registrationFormSchema: z.ZodEffects<z.ZodObject<{
|
|
|
15
15
|
role: string;
|
|
16
16
|
username: string;
|
|
17
17
|
email: string;
|
|
18
|
-
password: string;
|
|
19
18
|
firstName: string;
|
|
20
19
|
lastName: string;
|
|
20
|
+
password: string;
|
|
21
21
|
confirmPassword: string;
|
|
22
22
|
fingerPrint?: string | undefined;
|
|
23
23
|
}, {
|
|
24
24
|
role: string;
|
|
25
25
|
username: string;
|
|
26
26
|
email: string;
|
|
27
|
-
password: string;
|
|
28
27
|
firstName: string;
|
|
29
28
|
lastName: string;
|
|
29
|
+
password: string;
|
|
30
30
|
confirmPassword: string;
|
|
31
31
|
fingerPrint?: string | undefined;
|
|
32
32
|
}>, {
|
|
33
33
|
role: string;
|
|
34
34
|
username: string;
|
|
35
35
|
email: string;
|
|
36
|
-
password: string;
|
|
37
36
|
firstName: string;
|
|
38
37
|
lastName: string;
|
|
38
|
+
password: string;
|
|
39
39
|
confirmPassword: string;
|
|
40
40
|
fingerPrint?: string | undefined;
|
|
41
41
|
}, {
|
|
42
42
|
role: string;
|
|
43
43
|
username: string;
|
|
44
44
|
email: string;
|
|
45
|
-
password: string;
|
|
46
45
|
firstName: string;
|
|
47
46
|
lastName: string;
|
|
47
|
+
password: string;
|
|
48
48
|
confirmPassword: string;
|
|
49
49
|
fingerPrint?: string | undefined;
|
|
50
50
|
}>;
|
|
@@ -1,30 +1,50 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
export declare const
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
password: z.ZodString;
|
|
6
|
-
role: z.ZodString;
|
|
7
|
-
fingerPrint: z.ZodOptional<z.ZodString>;
|
|
2
|
+
export declare const emailSchema: z.ZodString;
|
|
3
|
+
export declare const passwordSchema: z.ZodString;
|
|
4
|
+
export declare const UserRegistrationSchema: z.ZodEffects<z.ZodObject<{
|
|
8
5
|
firstName: z.ZodString;
|
|
9
6
|
lastName: z.ZodString;
|
|
10
|
-
|
|
7
|
+
email: z.ZodString;
|
|
8
|
+
username: z.ZodEffects<z.ZodEffects<z.ZodEffects<z.ZodString, string, string>, string, string>, string, string>;
|
|
9
|
+
role: z.ZodString;
|
|
10
|
+
password: z.ZodString;
|
|
11
|
+
confirmPassword: z.ZodString;
|
|
12
|
+
fingerPrint: z.ZodOptional<z.ZodString>;
|
|
11
13
|
}, "strip", z.ZodTypeAny, {
|
|
12
14
|
role: string;
|
|
13
15
|
username: string;
|
|
14
16
|
email: string;
|
|
15
|
-
password: string;
|
|
16
17
|
firstName: string;
|
|
17
18
|
lastName: string;
|
|
18
|
-
|
|
19
|
+
password: string;
|
|
20
|
+
confirmPassword: string;
|
|
19
21
|
fingerPrint?: string | undefined;
|
|
20
22
|
}, {
|
|
21
23
|
role: string;
|
|
22
24
|
username: string;
|
|
23
25
|
email: string;
|
|
26
|
+
firstName: string;
|
|
27
|
+
lastName: string;
|
|
24
28
|
password: string;
|
|
29
|
+
confirmPassword: string;
|
|
30
|
+
fingerPrint?: string | undefined;
|
|
31
|
+
}>, {
|
|
32
|
+
role: string;
|
|
33
|
+
username: string;
|
|
34
|
+
email: string;
|
|
25
35
|
firstName: string;
|
|
26
36
|
lastName: string;
|
|
37
|
+
password: string;
|
|
38
|
+
confirmPassword: string;
|
|
39
|
+
fingerPrint?: string | undefined;
|
|
40
|
+
}, {
|
|
41
|
+
role: string;
|
|
42
|
+
username: string;
|
|
43
|
+
email: string;
|
|
44
|
+
firstName: string;
|
|
45
|
+
lastName: string;
|
|
46
|
+
password: string;
|
|
47
|
+
confirmPassword: string;
|
|
27
48
|
fingerPrint?: string | undefined;
|
|
28
|
-
isSmallProvider?: boolean | undefined;
|
|
29
49
|
}>;
|
|
30
50
|
export type UserRegistrationInput = z.infer<typeof UserRegistrationSchema>;
|
|
@@ -1,40 +1,50 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UserRegistrationSchema = void 0;
|
|
3
|
+
exports.UserRegistrationSchema = exports.passwordSchema = exports.emailSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const limits_1 = require("../constants/limits");
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
.max(limits_1.PASSWORD_MAX_LENGTH, `Password must be at most ${limits_1.PASSWORD_MAX_LENGTH} characters long`),
|
|
22
|
-
role: zod_1.z.string().min(1, {
|
|
23
|
-
message: "Role is required",
|
|
24
|
-
}),
|
|
25
|
-
fingerPrint: zod_1.z.string().optional(),
|
|
6
|
+
// Reusable email validation schema
|
|
7
|
+
exports.emailSchema = zod_1.z
|
|
8
|
+
.string()
|
|
9
|
+
.min(1, "Email is required")
|
|
10
|
+
.max(limits_1.EMAIL_MAX_LENGTH, "Email is too long")
|
|
11
|
+
.email("Invalid email")
|
|
12
|
+
.regex(/^[^+]+@/, "Email aliasing is not allowed");
|
|
13
|
+
// Reusable password validation schema
|
|
14
|
+
exports.passwordSchema = zod_1.z
|
|
15
|
+
.string()
|
|
16
|
+
.min(1, "Password is required")
|
|
17
|
+
.min(limits_1.PASSWORD_MIN_LENGTH, `Password must be at least ${limits_1.PASSWORD_MIN_LENGTH} characters long`)
|
|
18
|
+
.max(limits_1.PASSWORD_MAX_LENGTH, `Password must be at most ${limits_1.PASSWORD_MAX_LENGTH} characters long`);
|
|
19
|
+
exports.UserRegistrationSchema = zod_1.z
|
|
20
|
+
.object({
|
|
26
21
|
firstName: zod_1.z
|
|
27
22
|
.string()
|
|
28
23
|
.min(1, "First name is required")
|
|
29
24
|
.min(limits_1.NAME_MIN_LENGTH, `First name must be at least ${limits_1.NAME_MIN_LENGTH} characters long`)
|
|
30
|
-
.max(limits_1.NAME_MAX_LENGTH, `First name must be
|
|
25
|
+
.max(limits_1.NAME_MAX_LENGTH, `First name must be under ${limits_1.NAME_MAX_LENGTH} characters`),
|
|
31
26
|
lastName: zod_1.z
|
|
32
27
|
.string()
|
|
33
28
|
.min(1, "Last name is required")
|
|
34
29
|
.min(limits_1.NAME_MIN_LENGTH, `Last name must be at least ${limits_1.NAME_MIN_LENGTH} characters long`)
|
|
35
|
-
.max(limits_1.NAME_MAX_LENGTH, `Last name must be
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
30
|
+
.max(limits_1.NAME_MAX_LENGTH, `Last name must be under ${limits_1.NAME_MAX_LENGTH} characters`),
|
|
31
|
+
email: exports.emailSchema,
|
|
32
|
+
username: zod_1.z
|
|
33
|
+
.string()
|
|
34
|
+
.min(1, "Username is required")
|
|
35
|
+
.min(limits_1.USERNAME_MIN_LENGTH, `Username must be at least ${limits_1.USERNAME_MIN_LENGTH} characters long`)
|
|
36
|
+
.max(limits_1.USERNAME_MAX_LENGTH, `Username must be under ${limits_1.USERNAME_MAX_LENGTH} characters`)
|
|
37
|
+
.regex(/^[a-zA-Z0-9_]+$/, "Username can only contain letters, numbers, and underscores")
|
|
38
|
+
.refine((value) => !value.startsWith("_"), "Username cannot start with an underscore")
|
|
39
|
+
.refine((value) => !value.endsWith("_"), "Username cannot end with an underscore")
|
|
40
|
+
.refine((value) => !value.includes("__"), "Username cannot contain consecutive underscores"),
|
|
41
|
+
role: zod_1.z.string().min(1, "Please select your role"),
|
|
42
|
+
password: exports.passwordSchema,
|
|
43
|
+
confirmPassword: zod_1.z.string().min(1, "Confirm password is required"),
|
|
44
|
+
fingerPrint: zod_1.z.string().optional(),
|
|
45
|
+
})
|
|
46
|
+
// Password match validation
|
|
47
|
+
.refine((data) => data.password === data.confirmPassword, {
|
|
48
|
+
message: "Passwords don't match",
|
|
49
|
+
path: ["confirmPassword"],
|
|
40
50
|
});
|
|
@@ -15,19 +15,19 @@ export declare const passwordChangeSchema: z.ZodEffects<z.ZodObject<{
|
|
|
15
15
|
newPassword: z.ZodString;
|
|
16
16
|
confirmPassword: z.ZodString;
|
|
17
17
|
}, "strip", z.ZodTypeAny, {
|
|
18
|
+
confirmPassword: string;
|
|
18
19
|
currentPassword: string;
|
|
19
20
|
newPassword: string;
|
|
20
|
-
confirmPassword: string;
|
|
21
21
|
}, {
|
|
22
|
+
confirmPassword: string;
|
|
22
23
|
currentPassword: string;
|
|
23
24
|
newPassword: string;
|
|
24
|
-
confirmPassword: string;
|
|
25
25
|
}>, {
|
|
26
|
+
confirmPassword: string;
|
|
26
27
|
currentPassword: string;
|
|
27
28
|
newPassword: string;
|
|
28
|
-
confirmPassword: string;
|
|
29
29
|
}, {
|
|
30
|
+
confirmPassword: string;
|
|
30
31
|
currentPassword: string;
|
|
31
32
|
newPassword: string;
|
|
32
|
-
confirmPassword: string;
|
|
33
33
|
}>;
|
package/dist/utils/index.d.ts
CHANGED
package/dist/utils/index.js
CHANGED
|
@@ -14,15 +14,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
|
|
18
|
-
__exportStar(require("./
|
|
19
|
-
// Date formatting utilities
|
|
20
|
-
__exportStar(require("./date"), exports);
|
|
21
|
-
// Time/shift utilities
|
|
22
|
-
__exportStar(require("./time"), exports);
|
|
23
|
-
// Functional utilities
|
|
24
|
-
__exportStar(require("./debounce"), exports);
|
|
25
|
-
// Enum utilities
|
|
26
|
-
__exportStar(require("./enum"), exports);
|
|
27
|
-
// Video validation utilities
|
|
28
|
-
__exportStar(require("./video"), exports);
|
|
17
|
+
__exportStar(require("./onboarding"), exports);
|
|
18
|
+
__exportStar(require("./utils"), exports);
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { OnboardingSteps } from "../enums";
|
|
2
|
+
export declare const getCurrentOnboardingStep: (completedSteps: OnboardingSteps[]) => {
|
|
3
|
+
readonly id: OnboardingSteps.ABN_AND_BUSINESS_NAME;
|
|
4
|
+
readonly isRequired: true;
|
|
5
|
+
readonly title: "ABN and Business Name";
|
|
6
|
+
readonly description: "Enter your ABN and business name to get started";
|
|
7
|
+
readonly url: "/onboarding/business-info/abn-and-business-name";
|
|
8
|
+
} | {
|
|
9
|
+
readonly id: OnboardingSteps.SERVICES;
|
|
10
|
+
readonly isRequired: true;
|
|
11
|
+
readonly title: "Services";
|
|
12
|
+
readonly description: "Select the services you offer";
|
|
13
|
+
readonly url: "/onboarding/business-info/services";
|
|
14
|
+
} | {
|
|
15
|
+
readonly id: OnboardingSteps.LOCATIONS;
|
|
16
|
+
readonly isRequired: true;
|
|
17
|
+
readonly title: "Locations";
|
|
18
|
+
readonly description: "Select the locations you offer";
|
|
19
|
+
readonly url: "/onboarding/business-info/locations";
|
|
20
|
+
} | {
|
|
21
|
+
readonly id: OnboardingSteps.SUPPORTED_AGES;
|
|
22
|
+
readonly isRequired: false;
|
|
23
|
+
readonly title: "Supported Ages";
|
|
24
|
+
readonly description: "Select the ages you support";
|
|
25
|
+
readonly url: "/onboarding/business-info/supported-ages";
|
|
26
|
+
} | {
|
|
27
|
+
readonly id: OnboardingSteps.EXPERIENCE;
|
|
28
|
+
readonly isRequired: false;
|
|
29
|
+
readonly title: "Experience";
|
|
30
|
+
readonly description: "Enter your experience";
|
|
31
|
+
readonly url: "/onboarding/personal-info/experience";
|
|
32
|
+
} | {
|
|
33
|
+
readonly id: OnboardingSteps.HOURLY_RATE;
|
|
34
|
+
readonly isRequired: false;
|
|
35
|
+
readonly title: "Hourly Rate";
|
|
36
|
+
readonly description: "Enter your hourly rate";
|
|
37
|
+
readonly url: "/onboarding/personal-info/hourly-rate";
|
|
38
|
+
} | {
|
|
39
|
+
readonly id: OnboardingSteps.GENDER;
|
|
40
|
+
readonly isRequired: true;
|
|
41
|
+
readonly title: "Gender";
|
|
42
|
+
readonly description: "Select your gender";
|
|
43
|
+
readonly url: "/onboarding/personal-info/gender";
|
|
44
|
+
} | {
|
|
45
|
+
readonly id: OnboardingSteps.LANGUAGES;
|
|
46
|
+
readonly isRequired: false;
|
|
47
|
+
readonly title: "Languages";
|
|
48
|
+
readonly description: "Select the languages you speak";
|
|
49
|
+
readonly url: "/onboarding/personal-info/languages";
|
|
50
|
+
} | {
|
|
51
|
+
readonly id: OnboardingSteps.PHONE;
|
|
52
|
+
readonly isRequired: false;
|
|
53
|
+
readonly title: "Phone";
|
|
54
|
+
readonly description: "Provides participants a direct way to reach you for jobs you apply to.";
|
|
55
|
+
readonly url: "/onboarding/personal-info/phone";
|
|
56
|
+
} | {
|
|
57
|
+
readonly id: OnboardingSteps.OVERVIEW;
|
|
58
|
+
readonly isRequired: false;
|
|
59
|
+
readonly title: "Overview";
|
|
60
|
+
readonly description: "Introduce yourself to your potential clients";
|
|
61
|
+
readonly url: "/onboarding/personal-info/overview";
|
|
62
|
+
} | {
|
|
63
|
+
readonly id: OnboardingSteps.PHOTO;
|
|
64
|
+
readonly isRequired: true;
|
|
65
|
+
readonly title: "Photo";
|
|
66
|
+
readonly description: "Upload a photo of yourself";
|
|
67
|
+
readonly url: "/onboarding/personal-info/photo";
|
|
68
|
+
} | {
|
|
69
|
+
url: string;
|
|
70
|
+
};
|
|
71
|
+
export declare const getNextOnboardingStep: (currentStep: OnboardingSteps) => {
|
|
72
|
+
readonly id: OnboardingSteps.ABN_AND_BUSINESS_NAME;
|
|
73
|
+
readonly isRequired: true;
|
|
74
|
+
readonly title: "ABN and Business Name";
|
|
75
|
+
readonly description: "Enter your ABN and business name to get started";
|
|
76
|
+
readonly url: "/onboarding/business-info/abn-and-business-name";
|
|
77
|
+
} | {
|
|
78
|
+
readonly id: OnboardingSteps.SERVICES;
|
|
79
|
+
readonly isRequired: true;
|
|
80
|
+
readonly title: "Services";
|
|
81
|
+
readonly description: "Select the services you offer";
|
|
82
|
+
readonly url: "/onboarding/business-info/services";
|
|
83
|
+
} | {
|
|
84
|
+
readonly id: OnboardingSteps.LOCATIONS;
|
|
85
|
+
readonly isRequired: true;
|
|
86
|
+
readonly title: "Locations";
|
|
87
|
+
readonly description: "Select the locations you offer";
|
|
88
|
+
readonly url: "/onboarding/business-info/locations";
|
|
89
|
+
} | {
|
|
90
|
+
readonly id: OnboardingSteps.SUPPORTED_AGES;
|
|
91
|
+
readonly isRequired: false;
|
|
92
|
+
readonly title: "Supported Ages";
|
|
93
|
+
readonly description: "Select the ages you support";
|
|
94
|
+
readonly url: "/onboarding/business-info/supported-ages";
|
|
95
|
+
} | {
|
|
96
|
+
readonly id: OnboardingSteps.EXPERIENCE;
|
|
97
|
+
readonly isRequired: false;
|
|
98
|
+
readonly title: "Experience";
|
|
99
|
+
readonly description: "Enter your experience";
|
|
100
|
+
readonly url: "/onboarding/personal-info/experience";
|
|
101
|
+
} | {
|
|
102
|
+
readonly id: OnboardingSteps.HOURLY_RATE;
|
|
103
|
+
readonly isRequired: false;
|
|
104
|
+
readonly title: "Hourly Rate";
|
|
105
|
+
readonly description: "Enter your hourly rate";
|
|
106
|
+
readonly url: "/onboarding/personal-info/hourly-rate";
|
|
107
|
+
} | {
|
|
108
|
+
readonly id: OnboardingSteps.GENDER;
|
|
109
|
+
readonly isRequired: true;
|
|
110
|
+
readonly title: "Gender";
|
|
111
|
+
readonly description: "Select your gender";
|
|
112
|
+
readonly url: "/onboarding/personal-info/gender";
|
|
113
|
+
} | {
|
|
114
|
+
readonly id: OnboardingSteps.LANGUAGES;
|
|
115
|
+
readonly isRequired: false;
|
|
116
|
+
readonly title: "Languages";
|
|
117
|
+
readonly description: "Select the languages you speak";
|
|
118
|
+
readonly url: "/onboarding/personal-info/languages";
|
|
119
|
+
} | {
|
|
120
|
+
readonly id: OnboardingSteps.PHONE;
|
|
121
|
+
readonly isRequired: false;
|
|
122
|
+
readonly title: "Phone";
|
|
123
|
+
readonly description: "Provides participants a direct way to reach you for jobs you apply to.";
|
|
124
|
+
readonly url: "/onboarding/personal-info/phone";
|
|
125
|
+
} | {
|
|
126
|
+
readonly id: OnboardingSteps.OVERVIEW;
|
|
127
|
+
readonly isRequired: false;
|
|
128
|
+
readonly title: "Overview";
|
|
129
|
+
readonly description: "Introduce yourself to your potential clients";
|
|
130
|
+
readonly url: "/onboarding/personal-info/overview";
|
|
131
|
+
} | {
|
|
132
|
+
readonly id: OnboardingSteps.PHOTO;
|
|
133
|
+
readonly isRequired: true;
|
|
134
|
+
readonly title: "Photo";
|
|
135
|
+
readonly description: "Upload a photo of yourself";
|
|
136
|
+
readonly url: "/onboarding/personal-info/photo";
|
|
137
|
+
} | null;
|
|
138
|
+
export declare const getStepIndex: (stepUrl: string) => number;
|
|
139
|
+
export declare const getStepFromUrl: (url: string) => OnboardingSteps;
|
|
140
|
+
export declare const isStepAccessible: (stepUrl: string, completedSteps: OnboardingSteps[]) => boolean;
|
|
141
|
+
export declare const isStepMandatory: (step: OnboardingSteps) => boolean | undefined;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isStepMandatory = exports.isStepAccessible = exports.getStepFromUrl = exports.getStepIndex = exports.getNextOnboardingStep = exports.getCurrentOnboardingStep = void 0;
|
|
4
|
+
const constants_1 = require("../constants");
|
|
5
|
+
const getCurrentOnboardingStep = (completedSteps) => {
|
|
6
|
+
// Find the first step that hasn't been completed
|
|
7
|
+
const nextStep = constants_1.onboardingStepsDetails.find((step) => !completedSteps.includes(step.id));
|
|
8
|
+
// If all required steps are completed, return the celebrate page
|
|
9
|
+
if (!nextStep) {
|
|
10
|
+
return {
|
|
11
|
+
url: "/onboarding/celebrate",
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
return nextStep;
|
|
15
|
+
};
|
|
16
|
+
exports.getCurrentOnboardingStep = getCurrentOnboardingStep;
|
|
17
|
+
const getNextOnboardingStep = (currentStep) => {
|
|
18
|
+
const currentIndex = constants_1.onboardingStepsDetails.findIndex((step) => step.id === currentStep);
|
|
19
|
+
if (currentIndex === -1 ||
|
|
20
|
+
currentIndex === constants_1.onboardingStepsDetails.length - 1) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return constants_1.onboardingStepsDetails[currentIndex + 1];
|
|
24
|
+
};
|
|
25
|
+
exports.getNextOnboardingStep = getNextOnboardingStep;
|
|
26
|
+
// Get the index of a step in the onboarding flow
|
|
27
|
+
const getStepIndex = (stepUrl) => {
|
|
28
|
+
return constants_1.onboardingStepsDetails.findIndex((step) => step.url === stepUrl);
|
|
29
|
+
};
|
|
30
|
+
exports.getStepIndex = getStepIndex;
|
|
31
|
+
// Get the step ID from a URL
|
|
32
|
+
const getStepFromUrl = (url) => {
|
|
33
|
+
// Find the step that matches the URL
|
|
34
|
+
const step = constants_1.onboardingStepsDetails.find((step) => step.url === url);
|
|
35
|
+
// If no step matches, return the first step as default
|
|
36
|
+
if (!step) {
|
|
37
|
+
// Special case for celebrate page
|
|
38
|
+
if (url === "/onboarding/celebrate") {
|
|
39
|
+
// Return the last step for the celebrate page
|
|
40
|
+
return constants_1.onboardingStepsDetails[constants_1.onboardingStepsDetails.length - 1].id;
|
|
41
|
+
}
|
|
42
|
+
return constants_1.onboardingStepsDetails[0].id;
|
|
43
|
+
}
|
|
44
|
+
return step.id;
|
|
45
|
+
};
|
|
46
|
+
exports.getStepFromUrl = getStepFromUrl;
|
|
47
|
+
// Check if a step is accessible based on completed steps
|
|
48
|
+
const isStepAccessible = (stepUrl, completedSteps) => {
|
|
49
|
+
// Special case for the celebrate page - only accessible if all required steps are completed
|
|
50
|
+
if (stepUrl === "/onboarding/celebrate") {
|
|
51
|
+
return constants_1.onboardingStepsDetails.every((step) => completedSteps.includes(step.id) || !step.isRequired);
|
|
52
|
+
}
|
|
53
|
+
// Find the index of the current step and the next allowed step
|
|
54
|
+
const stepIndex = (0, exports.getStepIndex)(stepUrl);
|
|
55
|
+
const nextStepIndex = (0, exports.getStepIndex)((0, exports.getCurrentOnboardingStep)(completedSteps).url);
|
|
56
|
+
// Step is accessible if:
|
|
57
|
+
// 1. It's a valid step in the flow
|
|
58
|
+
// 2. Either it's the next step or a step that's already been completed
|
|
59
|
+
return (stepIndex !== -1 &&
|
|
60
|
+
(stepIndex <= nextStepIndex ||
|
|
61
|
+
completedSteps.includes(constants_1.onboardingStepsDetails[stepIndex].id)));
|
|
62
|
+
};
|
|
63
|
+
exports.isStepAccessible = isStepAccessible;
|
|
64
|
+
const isStepMandatory = (step) => {
|
|
65
|
+
return constants_1.onboardingStepsDetails.find((s) => s.id === step)?.isRequired;
|
|
66
|
+
};
|
|
67
|
+
exports.isStepMandatory = isStepMandatory;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@careflair/common",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.15",
|
|
4
4
|
"description": "Shared assets for CareFlair",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
"prepublishOnly": "npm run build"
|
|
10
10
|
},
|
|
11
11
|
"devDependencies": {
|
|
12
|
-
"typescript": "^5.
|
|
13
|
-
"zod": "^3.
|
|
12
|
+
"typescript": "^5.9.3",
|
|
13
|
+
"zod": "^3.25.76"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [
|
|
16
16
|
"pnp-zod"
|