@careflair/common 1.0.14 → 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/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/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"
|