heartraite 1.0.17 → 1.0.19

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.
@@ -1,14 +1,9 @@
1
1
  export declare enum CloudFunction {
2
- CREATE_ASSESSMENT = "assessment/create-assessment",
3
- GET_ASSESSMENT = "assessment/get-assessment",
4
- GET_ASSESSMENTS = "assessment/get-assessments",
5
- CREATE_SUBMISSION = "assessment/create-submission",
6
- GET_SUBMISSION = "assessment/get-submission",
7
- UPDATE_ANSWER = "assessment/update-answer",
8
- SUBMIT_CATEGORY_FEEDBACK = "assessment/submit-category-feedback",
9
2
  REGISTER_USER = "auth/register-user",
10
3
  AUTHENTICATE_BANKID = "bankid/authenticate",
11
4
  COLLECT_BANKID = "bankid/collect",
5
+ SUBMIT_ANSWER = "ca/submit-answer",
6
+ SUBMIT_CATEGORY_FEEDBACK = "ca/submit-category-feedback",
12
7
  CREATE_LIKE = "like/create-like",
13
8
  GET_LIKES = "like/get-likes",
14
9
  HANDLE_LIKE_SEEN = "like/handle-like-seen",
@@ -21,7 +16,14 @@ export declare enum CloudFunction {
21
16
  GET_MATCHABLE_USERS = "match/get-matchable-users",
22
17
  SEND_MESSAGE = "message/send-message",
23
18
  GET_MESSAGES = "message/get-messages",
24
- CREATE_PLS = "pls/create-pls",
19
+ CREATE_PLS_INPUT = "pls/create-input",
20
+ CREATE_PLS_ASSESSMENT = "pls/create-assessment",
21
+ GET_PLS_ASSESSMENT = "pls/get-assessment",
22
+ GET_PLS_ASSESSMENTS = "pls/get-assessments",
23
+ CREATE_PLS_SUBMISSION = "pls/create-submission",
24
+ GET_PLS_SUBMISSION = "pls/get-submission",
25
+ UPDATE_PLS_ANSWER = "pls/update-answer",
26
+ SUBMIT_PLS_CATEGORY_FEEDBACK = "pls/submit-category-feedback",
25
27
  UPDATE_QUESTIONS = "rating/update-quesitons",
26
28
  CREATE_REPORT = "report/create-report",
27
29
  ADD_IMAGES = "storage/add-images",
@@ -3,16 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.CloudFunction = void 0;
4
4
  var CloudFunction;
5
5
  (function (CloudFunction) {
6
- CloudFunction["CREATE_ASSESSMENT"] = "assessment/create-assessment";
7
- CloudFunction["GET_ASSESSMENT"] = "assessment/get-assessment";
8
- CloudFunction["GET_ASSESSMENTS"] = "assessment/get-assessments";
9
- CloudFunction["CREATE_SUBMISSION"] = "assessment/create-submission";
10
- CloudFunction["GET_SUBMISSION"] = "assessment/get-submission";
11
- CloudFunction["UPDATE_ANSWER"] = "assessment/update-answer";
12
- CloudFunction["SUBMIT_CATEGORY_FEEDBACK"] = "assessment/submit-category-feedback";
13
6
  CloudFunction["REGISTER_USER"] = "auth/register-user";
14
7
  CloudFunction["AUTHENTICATE_BANKID"] = "bankid/authenticate";
15
8
  CloudFunction["COLLECT_BANKID"] = "bankid/collect";
9
+ CloudFunction["SUBMIT_ANSWER"] = "ca/submit-answer";
10
+ CloudFunction["SUBMIT_CATEGORY_FEEDBACK"] = "ca/submit-category-feedback";
16
11
  CloudFunction["CREATE_LIKE"] = "like/create-like";
17
12
  CloudFunction["GET_LIKES"] = "like/get-likes";
18
13
  CloudFunction["HANDLE_LIKE_SEEN"] = "like/handle-like-seen";
@@ -25,7 +20,14 @@ var CloudFunction;
25
20
  CloudFunction["GET_MATCHABLE_USERS"] = "match/get-matchable-users";
26
21
  CloudFunction["SEND_MESSAGE"] = "message/send-message";
27
22
  CloudFunction["GET_MESSAGES"] = "message/get-messages";
28
- CloudFunction["CREATE_PLS"] = "pls/create-pls";
23
+ CloudFunction["CREATE_PLS_INPUT"] = "pls/create-input";
24
+ CloudFunction["CREATE_PLS_ASSESSMENT"] = "pls/create-assessment";
25
+ CloudFunction["GET_PLS_ASSESSMENT"] = "pls/get-assessment";
26
+ CloudFunction["GET_PLS_ASSESSMENTS"] = "pls/get-assessments";
27
+ CloudFunction["CREATE_PLS_SUBMISSION"] = "pls/create-submission";
28
+ CloudFunction["GET_PLS_SUBMISSION"] = "pls/get-submission";
29
+ CloudFunction["UPDATE_PLS_ANSWER"] = "pls/update-answer";
30
+ CloudFunction["SUBMIT_PLS_CATEGORY_FEEDBACK"] = "pls/submit-category-feedback";
29
31
  CloudFunction["UPDATE_QUESTIONS"] = "rating/update-quesitons";
30
32
  CloudFunction["CREATE_REPORT"] = "report/create-report";
31
33
  CloudFunction["ADD_IMAGES"] = "storage/add-images";
@@ -0,0 +1 @@
1
+ export * from "./useTypewriter";
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./useTypewriter"), exports);
@@ -0,0 +1,12 @@
1
+ interface UseTypewriterOptions {
2
+ text: string;
3
+ typingSpeed?: number;
4
+ initialDelay?: number;
5
+ blinkingSpeed?: number;
6
+ }
7
+ export declare const useTypewriter: ({ text, typingSpeed, initialDelay, blinkingSpeed, }: UseTypewriterOptions) => {
8
+ displayedText: string;
9
+ showDot: boolean;
10
+ isComplete: boolean;
11
+ };
12
+ export {};
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTypewriter = void 0;
4
+ const react_1 = require("react");
5
+ const useTypewriter = ({ text, typingSpeed = 50, initialDelay = 1000, blinkingSpeed = 500, }) => {
6
+ const [isComplete, setIsComplete] = (0, react_1.useState)(false);
7
+ const [displayedText, setDisplayedText] = (0, react_1.useState)("");
8
+ const [showDot, setShowDot] = (0, react_1.useState)(false);
9
+ (0, react_1.useEffect)(() => {
10
+ if (!text || text.length === 0) {
11
+ setDisplayedText(""); // No text to display
12
+ setIsComplete(true); // Mark typing as complete immediately
13
+ setShowDot(false); // No blinking dot for empty text
14
+ return; // Exit early if text is empty
15
+ }
16
+ let blinkingInterval = null;
17
+ let typingTimeout = null;
18
+ // Initialize state
19
+ setDisplayedText(""); // Clear the displayed text
20
+ setShowDot(true); // Start with a blinking dot
21
+ setIsComplete(false); // Reset completion flag
22
+ // Start blinking dot effect
23
+ blinkingInterval = setInterval(() => {
24
+ setShowDot((prev) => !prev);
25
+ }, blinkingSpeed);
26
+ // Start typing after the initial delay
27
+ typingTimeout = setTimeout(() => {
28
+ if (blinkingInterval) {
29
+ clearInterval(blinkingInterval); // Stop blinking before typing
30
+ setShowDot(false); // Hide blinking dot
31
+ }
32
+ // Typing effect
33
+ let currentIndex = 0;
34
+ const typeNextChar = () => {
35
+ if (currentIndex < text.length) {
36
+ const charToAdd = text[currentIndex];
37
+ setDisplayedText((prev) => prev + charToAdd); // Append character
38
+ currentIndex++;
39
+ setTimeout(typeNextChar, typingSpeed); // Schedule next character
40
+ }
41
+ else {
42
+ setIsComplete(true); // Mark as complete
43
+ }
44
+ };
45
+ // Trigger the first character manually
46
+ setDisplayedText(text.charAt(0));
47
+ currentIndex = 1;
48
+ // Schedule the rest of the characters
49
+ setTimeout(typeNextChar, typingSpeed);
50
+ }, initialDelay);
51
+ // Cleanup on unmount or dependencies change
52
+ return () => {
53
+ if (blinkingInterval)
54
+ clearInterval(blinkingInterval);
55
+ if (typingTimeout)
56
+ clearTimeout(typingTimeout);
57
+ };
58
+ }, [text, typingSpeed, initialDelay, blinkingSpeed]);
59
+ return { displayedText, showDot, isComplete };
60
+ };
61
+ exports.useTypewriter = useTypewriter;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const react_1 = require("@testing-library/react");
4
+ const useTypewriter_1 = require("./useTypewriter");
5
+ jest.useFakeTimers();
6
+ describe("useTypewriter", () => {
7
+ const sampleText = "Hello, world!";
8
+ const defaultOptions = {
9
+ text: sampleText,
10
+ typingSpeed: 50,
11
+ initialDelay: 500,
12
+ blinkingSpeed: 300,
13
+ };
14
+ it("should start with an empty displayedText", () => {
15
+ const { result } = (0, react_1.renderHook)(() => (0, useTypewriter_1.useTypewriter)(defaultOptions));
16
+ expect(result.current.displayedText).toBe("");
17
+ expect(result.current.isComplete).toBe(false);
18
+ expect(result.current.showDot).toBe(true);
19
+ });
20
+ it("should handle empty text input gracefully", () => {
21
+ const { result } = (0, react_1.renderHook)(() => (0, useTypewriter_1.useTypewriter)({ ...defaultOptions, text: "" }));
22
+ // Assert initial state for empty text input
23
+ expect(result.current.displayedText).toBe(""); // Should be an empty string
24
+ expect(result.current.isComplete).toBe(true); // Typing is complete immediately
25
+ expect(result.current.showDot).toBe(false); // No blinking dot
26
+ });
27
+ it("should display the correct text after typing is complete", async () => {
28
+ const text = "Du beskriver dig själv som en person som värderar kroppstyper, engagemang, kompetens i livet.";
29
+ const { result } = (0, react_1.renderHook)(() => (0, useTypewriter_1.useTypewriter)({
30
+ ...defaultOptions,
31
+ text,
32
+ }));
33
+ // Simulate the initial delay (before typing starts)
34
+ (0, react_1.act)(() => {
35
+ jest.advanceTimersByTime(defaultOptions.initialDelay);
36
+ });
37
+ // Simulate the full typing duration (based on the text length and typing speed)
38
+ const totalTypingTime = text.length * defaultOptions.typingSpeed;
39
+ (0, react_1.act)(() => {
40
+ jest.advanceTimersByTime(totalTypingTime);
41
+ });
42
+ // Assert that after typing is complete, the correct text is displayed
43
+ expect(result.current.displayedText).toBe(text);
44
+ expect(result.current.isComplete).toBe(true);
45
+ expect(result.current.showDot).toBe(false); // No more blinking dot
46
+ });
47
+ it("should respect typing speed and initial delay", () => {
48
+ const customOptions = {
49
+ ...defaultOptions,
50
+ typingSpeed: 100,
51
+ initialDelay: 1000,
52
+ };
53
+ const { result } = (0, react_1.renderHook)(() => (0, useTypewriter_1.useTypewriter)(customOptions));
54
+ // Before initial delay
55
+ (0, react_1.act)(() => {
56
+ jest.advanceTimersByTime(900);
57
+ });
58
+ expect(result.current.displayedText).toBe("");
59
+ expect(result.current.isComplete).toBe(false);
60
+ // After initial delay
61
+ (0, react_1.act)(() => {
62
+ jest.advanceTimersByTime(100);
63
+ });
64
+ expect(result.current.displayedText).toBe(sampleText.charAt(0));
65
+ // Verify typing speed
66
+ (0, react_1.act)(() => {
67
+ jest.advanceTimersByTime(customOptions.typingSpeed);
68
+ });
69
+ expect(result.current.displayedText).toBe(sampleText.slice(0, 2));
70
+ });
71
+ });
package/dist/index.d.ts CHANGED
@@ -2,3 +2,4 @@ export * from "./constants";
2
2
  export * from "./enum";
3
3
  export * from "./firebase";
4
4
  export * from "./types";
5
+ export * from "./hooks";
package/dist/index.js CHANGED
@@ -18,3 +18,4 @@ __exportStar(require("./constants"), exports);
18
18
  __exportStar(require("./enum"), exports);
19
19
  __exportStar(require("./firebase"), exports);
20
20
  __exportStar(require("./types"), exports);
21
+ __exportStar(require("./hooks"), exports);
@@ -0,0 +1,11 @@
1
+ import { Answer, CategoryEvaluation } from "./submission.types";
2
+ type QuestionId = string;
3
+ type CategoryId = string;
4
+ export type CA = {
5
+ created: string;
6
+ userId: string;
7
+ completed: boolean;
8
+ answers: Record<QuestionId, Answer>;
9
+ categoryEvaluations?: Record<CategoryId, CategoryEvaluation>;
10
+ };
11
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,39 +1,11 @@
1
1
  import { CloudFunction } from "../enum";
2
- import { AddImagesRequest, AuthenticateBankIDRequest, CollectBankIDRequest, CreateAssessmentRequest, CreateBillingPortalRequest, CreateCheckoutSessionRequest, CreateLikeRequest, CreatePLSRequest, CreateReportRequest, CreateSubmissionRequest, GetAssessmentRequest, GetMatchableUserRequest, GetMatchCheckRequest, GetMatchesRequest, GetMatchRequest, GetMessagesRequest, GetProductsRequest, GetSubmissionRequest, GetUserRequest, HandleLikeSeenRequest, HandleMatchSeenRequest, RegisterOnboardingRequest, RegisterUserRequest, RemoveMatchRequest, SendMessageRequest, SubmitCategoryFeedbackRequest, UpdateAnswerRequest, UpdateQuestionsRequest, UpdateUserRequest } from "./request.types";
3
- import { AddImagesResponse, AuthenticateBankIDResponse, CollectBankIDResponse, CreateAssessmentResponse, CreateBillingPortalResponse, CreateCheckoutSessionResponse, CreateLikeResponse, CreatePLSResponse, CreateReportResponse, CreateSubmissionResponse, GetAssessmentResponse, GetAssessmentsResponse, GetMatchableUserResponse, GetMatchableUsersResponse, GetMatchCheckResponse, GetMatchesResponse, GetMatchResponse, GetMessagesResponse, GetProductsResponse, GetSubmissionResponse, GetUserResponse, HandleLikeSeenResponse, HandleMatchSeenResponse, RegisterOnboardingResponse, RegisterUserResponse, RemoveMatchResponse, SendMessageResponse, SubmitCategoryFeedbackResponse, UpdateAnswerResponse, UpdateQuestionsResponse, UpdateUserResponse } from "./response.types";
2
+ import { AddImagesRequest, AuthenticateBankIDRequest, CollectBankIDRequest, CreateBillingPortalRequest, CreateCheckoutSessionRequest, CreateLikeRequest, CreatePLSAssessmentRequest, CreatePLSInputRequest, CreatePLSSubmissionRequest, CreateReportRequest, GetMatchableUserRequest, GetMatchCheckRequest, GetMatchesRequest, GetMatchRequest, GetMessagesRequest, GetPLSAssessmentRequest, GetPLSSubmissionRequest, GetProductsRequest, GetUserRequest, HandleLikeSeenRequest, HandleMatchSeenRequest, RegisterOnboardingRequest, RegisterUserRequest, RemoveMatchRequest, SendMessageRequest, SubmitAnswerRequest, SubmitCategoryFeedbackRequest, SubmitPLSCategoryFeedbackRequest, UpdatePLSAnswerRequest, UpdateQuestionsRequest, UpdateUserRequest } from "./request.types";
3
+ import { AddImagesResponse, AuthenticateBankIDResponse, CollectBankIDResponse, CreateBillingPortalResponse, CreateCheckoutSessionResponse, CreateLikeResponse, CreatePLSAssessmentResponse, CreatePLSInputResponse, CreatePLSSubmissionResponse, CreateReportResponse, GetMatchableUserResponse, GetMatchableUsersResponse, GetMatchCheckResponse, GetMatchesResponse, GetMatchResponse, GetMessagesResponse, GetPLSAssessmentResponse, GetPLSAssessmentsResponse, GetPLSSubmissionResponse, GetProductsResponse, GetUserResponse, HandleLikeSeenResponse, HandleMatchSeenResponse, RegisterOnboardingResponse, RegisterUserResponse, RemoveMatchResponse, SendMessageResponse, SubmitAnswerResponse, SubmitCategoryFeedbackResponse, SubmitPLSCategoryFeedbackResponse, UpdatePLSAnswerResponse, UpdateQuestionsResponse, UpdateUserResponse } from "./response.types";
4
4
  export type CloudFunctionTypes = {
5
- [CloudFunction.CREATE_ASSESSMENT]: {
6
- payload: CreateAssessmentRequest;
7
- response: CreateAssessmentResponse;
8
- };
9
- [CloudFunction.GET_ASSESSMENT]: {
10
- payload: GetAssessmentRequest;
11
- response: GetAssessmentResponse;
12
- };
13
- [CloudFunction.GET_ASSESSMENTS]: {
14
- payload?: undefined;
15
- response: GetAssessmentsResponse;
16
- };
17
5
  [CloudFunction.REGISTER_USER]: {
18
6
  payload: RegisterUserRequest;
19
7
  response: RegisterUserResponse;
20
8
  };
21
- [CloudFunction.CREATE_SUBMISSION]: {
22
- payload: CreateSubmissionRequest;
23
- response: CreateSubmissionResponse;
24
- };
25
- [CloudFunction.GET_SUBMISSION]: {
26
- payload: GetSubmissionRequest;
27
- response: GetSubmissionResponse;
28
- };
29
- [CloudFunction.UPDATE_ANSWER]: {
30
- payload: UpdateAnswerRequest;
31
- response: UpdateAnswerResponse;
32
- };
33
- [CloudFunction.SUBMIT_CATEGORY_FEEDBACK]: {
34
- payload: SubmitCategoryFeedbackRequest;
35
- response: SubmitCategoryFeedbackResponse;
36
- };
37
9
  [CloudFunction.AUTHENTICATE_BANKID]: {
38
10
  payload: AuthenticateBankIDRequest;
39
11
  response: AuthenticateBankIDResponse;
@@ -42,6 +14,14 @@ export type CloudFunctionTypes = {
42
14
  payload: CollectBankIDRequest;
43
15
  response: CollectBankIDResponse;
44
16
  };
17
+ [CloudFunction.SUBMIT_ANSWER]: {
18
+ payload: SubmitAnswerRequest;
19
+ response: SubmitAnswerResponse;
20
+ };
21
+ [CloudFunction.SUBMIT_CATEGORY_FEEDBACK]: {
22
+ payload: SubmitCategoryFeedbackRequest;
23
+ response: SubmitCategoryFeedbackResponse;
24
+ };
45
25
  [CloudFunction.CREATE_LIKE]: {
46
26
  payload: CreateLikeRequest;
47
27
  response: CreateLikeResponse;
@@ -90,9 +70,37 @@ export type CloudFunctionTypes = {
90
70
  payload: GetMessagesRequest;
91
71
  response: GetMessagesResponse;
92
72
  };
93
- [CloudFunction.CREATE_PLS]: {
94
- payload: CreatePLSRequest;
95
- response: CreatePLSResponse;
73
+ [CloudFunction.CREATE_PLS_INPUT]: {
74
+ payload: CreatePLSInputRequest;
75
+ response: CreatePLSInputResponse;
76
+ };
77
+ [CloudFunction.CREATE_PLS_SUBMISSION]: {
78
+ payload: CreatePLSSubmissionRequest;
79
+ response: CreatePLSSubmissionResponse;
80
+ };
81
+ [CloudFunction.GET_PLS_SUBMISSION]: {
82
+ payload: GetPLSSubmissionRequest;
83
+ response: GetPLSSubmissionResponse;
84
+ };
85
+ [CloudFunction.UPDATE_PLS_ANSWER]: {
86
+ payload: UpdatePLSAnswerRequest;
87
+ response: UpdatePLSAnswerResponse;
88
+ };
89
+ [CloudFunction.SUBMIT_PLS_CATEGORY_FEEDBACK]: {
90
+ payload: SubmitPLSCategoryFeedbackRequest;
91
+ response: SubmitPLSCategoryFeedbackResponse;
92
+ };
93
+ [CloudFunction.CREATE_PLS_ASSESSMENT]: {
94
+ payload: CreatePLSAssessmentRequest;
95
+ response: CreatePLSAssessmentResponse;
96
+ };
97
+ [CloudFunction.GET_PLS_ASSESSMENT]: {
98
+ payload: GetPLSAssessmentRequest;
99
+ response: GetPLSAssessmentResponse;
100
+ };
101
+ [CloudFunction.GET_PLS_ASSESSMENTS]: {
102
+ payload?: undefined;
103
+ response: GetPLSAssessmentsResponse;
96
104
  };
97
105
  [CloudFunction.UPDATE_QUESTIONS]: {
98
106
  payload: UpdateQuestionsRequest;
@@ -1,4 +1,5 @@
1
1
  export * from "./assessment.types";
2
+ export * from "./ca.types";
2
3
  export * from "./cloud-function-types";
3
4
  export * from "./error.types";
4
5
  export * from "./helper.types";
@@ -15,6 +15,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./assessment.types"), exports);
18
+ __exportStar(require("./ca.types"), exports);
18
19
  __exportStar(require("./cloud-function-types"), exports);
19
20
  __exportStar(require("./error.types"), exports);
20
21
  __exportStar(require("./helper.types"), exports);
@@ -7,28 +7,11 @@ export type RegisterUserRequest = {
7
7
  password: string;
8
8
  referrerId?: string;
9
9
  };
10
- export type CreateAssessmentRequest = {
11
- intimateTopics: boolean;
12
- };
13
- export type GetAssessmentRequest = {
14
- id: string;
15
- };
16
- export type CreateSubmissionRequest = {
17
- assessmentId: string;
18
- };
19
- export type GetSubmissionRequest = {
20
- assessmentId: string;
21
- submissionId: string;
22
- };
23
- export type UpdateAnswerRequest = {
24
- assessmentId: string;
25
- submissionId: string;
10
+ export type SubmitAnswerRequest = {
26
11
  categoryId: string;
27
12
  answer: Answer;
28
13
  };
29
14
  export type SubmitCategoryFeedbackRequest = {
30
- assessmentId: string;
31
- submissionId: string;
32
15
  categoryId: string;
33
16
  agreement: FeedbackAgreement;
34
17
  evaluationReflection: string;
@@ -78,11 +61,38 @@ export type GetMatchableUserRequest = {
78
61
  export type GetMatchCheckRequest = {
79
62
  userId: string;
80
63
  };
81
- export type CreatePLSRequest = {
64
+ export type CreatePLSInputRequest = {
82
65
  questionnaire: Record<string, string>;
83
66
  channelId: string;
84
67
  variation: string;
85
68
  };
69
+ export type CreatePLSSubmissionRequest = {
70
+ assessmentId: string;
71
+ };
72
+ export type GetPLSSubmissionRequest = {
73
+ assessmentId: string;
74
+ submissionId: string;
75
+ };
76
+ export type UpdatePLSAnswerRequest = {
77
+ assessmentId: string;
78
+ submissionId: string;
79
+ categoryId: string;
80
+ answer: Answer;
81
+ };
82
+ export type SubmitPLSCategoryFeedbackRequest = {
83
+ assessmentId: string;
84
+ submissionId: string;
85
+ categoryId: string;
86
+ agreement: FeedbackAgreement;
87
+ evaluationReflection: string;
88
+ additionalThoughts: string;
89
+ };
90
+ export type CreatePLSAssessmentRequest = {
91
+ intimateTopics: boolean;
92
+ };
93
+ export type GetPLSAssessmentRequest = {
94
+ id: string;
95
+ };
86
96
  export type UpdateQuestionsRequest = {
87
97
  questions: Record<string, string>;
88
98
  };
@@ -5,20 +5,11 @@ import { Message } from "./message.types";
5
5
  import { StripeProduct } from "./stripe.types";
6
6
  import { User } from "./user.types";
7
7
  import { Like } from "./like.types";
8
+ import { CA } from "./ca.types";
8
9
  export type RegisterUserResponse = {
9
10
  success: boolean;
10
11
  message: string;
11
12
  };
12
- export type CreateAssessmentResponse = Assessment;
13
- export type GetAssessmentResponse = Assessment;
14
- export type GetAssessmentsResponse = FullAssessment[];
15
- export type CreateSubmissionResponse = Submission;
16
- export type GetSubmissionResponse = Submission;
17
- export type UpdateAnswerResponse = {
18
- submission: Submission;
19
- categoryEvaluation?: CategoryEvaluation;
20
- };
21
- export type SubmitCategoryFeedbackResponse = CategoryEvaluation;
22
13
  export type AuthenticateBankIDResponse = {
23
14
  orderRef: string;
24
15
  qrStartToken: string;
@@ -30,6 +21,11 @@ export interface CollectBankIDResponse {
30
21
  qrCode?: string;
31
22
  hintCode?: string;
32
23
  }
24
+ export type SubmitAnswerResponse = {
25
+ ca: CA;
26
+ categoryEvaluation?: CategoryEvaluation;
27
+ };
28
+ export type SubmitCategoryFeedbackResponse = CategoryEvaluation;
33
29
  export type SendMessageResponse = Message;
34
30
  export type GetMessagesResponse = Message[];
35
31
  export type HandleLikeResponse = boolean;
@@ -44,7 +40,17 @@ export type CreateLikeResponse = {
44
40
  };
45
41
  export type GetLikesResponse = Like[];
46
42
  export type HandleLikeSeenResponse = void;
47
- export type CreatePLSResponse = void;
43
+ export type CreatePLSInputResponse = void;
44
+ export type CreatePLSAssessmentResponse = Assessment;
45
+ export type GetPLSAssessmentResponse = Assessment;
46
+ export type GetPLSAssessmentsResponse = FullAssessment[];
47
+ export type CreatePLSSubmissionResponse = Submission;
48
+ export type GetPLSSubmissionResponse = Submission;
49
+ export type UpdatePLSAnswerResponse = {
50
+ submission: Submission;
51
+ categoryEvaluation?: CategoryEvaluation;
52
+ };
53
+ export type SubmitPLSCategoryFeedbackResponse = CategoryEvaluation;
48
54
  export type UpdateQuestionsResponse = void;
49
55
  export type CreateReportResponse = void;
50
56
  export type CreateBillingPortalResponse = {
package/jest.config.js ADDED
@@ -0,0 +1,9 @@
1
+ module.exports = {
2
+ preset: "ts-jest", // Use ts-jest preset to handle TypeScript
3
+ testEnvironment: "jest-environment-jsdom", // Use jsdom for React tests
4
+ moduleFileExtensions: ["js", "jsx", "ts", "tsx"], // Support for js, jsx, ts, tsx files
5
+ testMatch: [
6
+ "**/*.test.[jt]s?(x)", // Match any .test.js, .test.ts, .test.jsx, .test.tsx files
7
+ ],
8
+ collectCoverageFrom: ["src/**/*.{js,jsx,ts,tsx}", "!src/**/*.d.ts"], // Collect coverage for all files except d.ts
9
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "heartraite",
3
- "version": "1.0.17",
3
+ "version": "1.0.19",
4
4
  "description": "Heartraite npm package for common functionality",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -20,12 +20,24 @@
20
20
  "url": "https://github.com/agottfredsson/heartraite-npm/issues"
21
21
  },
22
22
  "homepage": "https://github.com/agottfredsson/heartraite-npm#readme",
23
+ "dependencies": {
24
+ "react": "^19.0.0",
25
+ "react-dom": "^19.0.0"
26
+ },
23
27
  "peerDependencies": {
24
28
  "firebase": "^11.0.1"
25
29
  },
26
30
  "devDependencies": {
31
+ "@testing-library/dom": "^10.4.0",
32
+ "@testing-library/react": "^16.1.0",
33
+ "@types/jest": "^29.5.14",
27
34
  "@types/node": "^22.9.0",
28
- "typescript": "^5.6.3",
29
- "firebase": "^11.0.1"
35
+ "@types/react": "^19.0.2",
36
+ "@types/react-dom": "^19.0.2",
37
+ "firebase": "^11.0.1",
38
+ "jest": "^29.7.0",
39
+ "jest-environment-jsdom": "^29.7.0",
40
+ "ts-jest": "^29.2.5",
41
+ "typescript": "^5.6.3"
30
42
  }
31
43
  }
@@ -1,14 +1,9 @@
1
1
  export enum CloudFunction {
2
- CREATE_ASSESSMENT = "assessment/create-assessment",
3
- GET_ASSESSMENT = "assessment/get-assessment",
4
- GET_ASSESSMENTS = "assessment/get-assessments",
5
- CREATE_SUBMISSION = "assessment/create-submission",
6
- GET_SUBMISSION = "assessment/get-submission",
7
- UPDATE_ANSWER = "assessment/update-answer",
8
- SUBMIT_CATEGORY_FEEDBACK = "assessment/submit-category-feedback",
9
2
  REGISTER_USER = "auth/register-user",
10
3
  AUTHENTICATE_BANKID = "bankid/authenticate",
11
4
  COLLECT_BANKID = "bankid/collect",
5
+ SUBMIT_ANSWER = "ca/submit-answer",
6
+ SUBMIT_CATEGORY_FEEDBACK = "ca/submit-category-feedback",
12
7
  CREATE_LIKE = "like/create-like",
13
8
  GET_LIKES = "like/get-likes",
14
9
  HANDLE_LIKE_SEEN = "like/handle-like-seen",
@@ -21,7 +16,14 @@ export enum CloudFunction {
21
16
  GET_MATCHABLE_USERS = "match/get-matchable-users",
22
17
  SEND_MESSAGE = "message/send-message",
23
18
  GET_MESSAGES = "message/get-messages",
24
- CREATE_PLS = "pls/create-pls",
19
+ CREATE_PLS_INPUT = "pls/create-input",
20
+ CREATE_PLS_ASSESSMENT = "pls/create-assessment",
21
+ GET_PLS_ASSESSMENT = "pls/get-assessment",
22
+ GET_PLS_ASSESSMENTS = "pls/get-assessments",
23
+ CREATE_PLS_SUBMISSION = "pls/create-submission",
24
+ GET_PLS_SUBMISSION = "pls/get-submission",
25
+ UPDATE_PLS_ANSWER = "pls/update-answer",
26
+ SUBMIT_PLS_CATEGORY_FEEDBACK = "pls/submit-category-feedback",
25
27
  UPDATE_QUESTIONS = "rating/update-quesitons",
26
28
  CREATE_REPORT = "report/create-report",
27
29
  ADD_IMAGES = "storage/add-images",
@@ -0,0 +1 @@
1
+ export * from "./useTypewriter";
@@ -0,0 +1,86 @@
1
+ import { renderHook, act } from "@testing-library/react";
2
+ import { useTypewriter } from "./useTypewriter";
3
+
4
+ jest.useFakeTimers();
5
+
6
+ describe("useTypewriter", () => {
7
+ const sampleText = "Hello, world!";
8
+ const defaultOptions = {
9
+ text: sampleText,
10
+ typingSpeed: 50,
11
+ initialDelay: 500,
12
+ blinkingSpeed: 300,
13
+ };
14
+
15
+ it("should start with an empty displayedText", () => {
16
+ const { result } = renderHook(() => useTypewriter(defaultOptions));
17
+ expect(result.current.displayedText).toBe("");
18
+ expect(result.current.isComplete).toBe(false);
19
+ expect(result.current.showDot).toBe(true);
20
+ });
21
+ it("should handle empty text input gracefully", () => {
22
+ const { result } = renderHook(() =>
23
+ useTypewriter({ ...defaultOptions, text: "" })
24
+ );
25
+
26
+ // Assert initial state for empty text input
27
+ expect(result.current.displayedText).toBe(""); // Should be an empty string
28
+ expect(result.current.isComplete).toBe(true); // Typing is complete immediately
29
+ expect(result.current.showDot).toBe(false); // No blinking dot
30
+ });
31
+
32
+ it("should display the correct text after typing is complete", async () => {
33
+ const text =
34
+ "Du beskriver dig själv som en person som värderar kroppstyper, engagemang, kompetens i livet.";
35
+
36
+ const { result } = renderHook(() =>
37
+ useTypewriter({
38
+ ...defaultOptions,
39
+ text,
40
+ })
41
+ );
42
+
43
+ // Simulate the initial delay (before typing starts)
44
+ act(() => {
45
+ jest.advanceTimersByTime(defaultOptions.initialDelay);
46
+ });
47
+
48
+ // Simulate the full typing duration (based on the text length and typing speed)
49
+ const totalTypingTime = text.length * defaultOptions.typingSpeed;
50
+ act(() => {
51
+ jest.advanceTimersByTime(totalTypingTime);
52
+ });
53
+
54
+ // Assert that after typing is complete, the correct text is displayed
55
+ expect(result.current.displayedText).toBe(text);
56
+ expect(result.current.isComplete).toBe(true);
57
+ expect(result.current.showDot).toBe(false); // No more blinking dot
58
+ });
59
+ it("should respect typing speed and initial delay", () => {
60
+ const customOptions = {
61
+ ...defaultOptions,
62
+ typingSpeed: 100,
63
+ initialDelay: 1000,
64
+ };
65
+ const { result } = renderHook(() => useTypewriter(customOptions));
66
+
67
+ // Before initial delay
68
+ act(() => {
69
+ jest.advanceTimersByTime(900);
70
+ });
71
+ expect(result.current.displayedText).toBe("");
72
+ expect(result.current.isComplete).toBe(false);
73
+
74
+ // After initial delay
75
+ act(() => {
76
+ jest.advanceTimersByTime(100);
77
+ });
78
+ expect(result.current.displayedText).toBe(sampleText.charAt(0));
79
+
80
+ // Verify typing speed
81
+ act(() => {
82
+ jest.advanceTimersByTime(customOptions.typingSpeed);
83
+ });
84
+ expect(result.current.displayedText).toBe(sampleText.slice(0, 2));
85
+ });
86
+ });
@@ -0,0 +1,78 @@
1
+ import { useEffect, useState } from "react";
2
+
3
+ interface UseTypewriterOptions {
4
+ text: string;
5
+ typingSpeed?: number; // Time in ms between each character
6
+ initialDelay?: number; // Time in ms before typing starts
7
+ blinkingSpeed?: number; // Time in ms for the blinking dot toggle
8
+ }
9
+
10
+ export const useTypewriter = ({
11
+ text,
12
+ typingSpeed = 50,
13
+ initialDelay = 1000,
14
+ blinkingSpeed = 500,
15
+ }: UseTypewriterOptions) => {
16
+ const [isComplete, setIsComplete] = useState(false);
17
+ const [displayedText, setDisplayedText] = useState("");
18
+ const [showDot, setShowDot] = useState(false);
19
+
20
+ useEffect(() => {
21
+ if (!text || text.length === 0) {
22
+ setDisplayedText(""); // No text to display
23
+ setIsComplete(true); // Mark typing as complete immediately
24
+ setShowDot(false); // No blinking dot for empty text
25
+ return; // Exit early if text is empty
26
+ }
27
+
28
+ let blinkingInterval: NodeJS.Timeout | null = null;
29
+ let typingTimeout: NodeJS.Timeout | null = null;
30
+
31
+ // Initialize state
32
+ setDisplayedText(""); // Clear the displayed text
33
+ setShowDot(true); // Start with a blinking dot
34
+ setIsComplete(false); // Reset completion flag
35
+
36
+ // Start blinking dot effect
37
+ blinkingInterval = setInterval(() => {
38
+ setShowDot((prev) => !prev);
39
+ }, blinkingSpeed);
40
+
41
+ // Start typing after the initial delay
42
+ typingTimeout = setTimeout(() => {
43
+ if (blinkingInterval) {
44
+ clearInterval(blinkingInterval); // Stop blinking before typing
45
+ setShowDot(false); // Hide blinking dot
46
+ }
47
+
48
+ // Typing effect
49
+ let currentIndex = 0;
50
+
51
+ const typeNextChar = () => {
52
+ if (currentIndex < text.length) {
53
+ const charToAdd = text[currentIndex];
54
+ setDisplayedText((prev) => prev + charToAdd); // Append character
55
+ currentIndex++;
56
+ setTimeout(typeNextChar, typingSpeed); // Schedule next character
57
+ } else {
58
+ setIsComplete(true); // Mark as complete
59
+ }
60
+ };
61
+
62
+ // Trigger the first character manually
63
+ setDisplayedText(text.charAt(0));
64
+ currentIndex = 1;
65
+
66
+ // Schedule the rest of the characters
67
+ setTimeout(typeNextChar, typingSpeed);
68
+ }, initialDelay);
69
+
70
+ // Cleanup on unmount or dependencies change
71
+ return () => {
72
+ if (blinkingInterval) clearInterval(blinkingInterval);
73
+ if (typingTimeout) clearTimeout(typingTimeout);
74
+ };
75
+ }, [text, typingSpeed, initialDelay, blinkingSpeed]);
76
+
77
+ return { displayedText, showDot, isComplete };
78
+ };
package/src/index.ts CHANGED
@@ -2,3 +2,4 @@ export * from "./constants";
2
2
  export * from "./enum";
3
3
  export * from "./firebase";
4
4
  export * from "./types";
5
+ export * from "./hooks";
@@ -0,0 +1,12 @@
1
+ import { Answer, CategoryEvaluation } from "./submission.types";
2
+
3
+ type QuestionId = string;
4
+ type CategoryId = string;
5
+
6
+ export type CA = {
7
+ created: string;
8
+ userId: string;
9
+ completed: boolean;
10
+ answers: Record<QuestionId, Answer>;
11
+ categoryEvaluations?: Record<CategoryId, CategoryEvaluation>;
12
+ };
@@ -3,21 +3,21 @@ import {
3
3
  AddImagesRequest,
4
4
  AuthenticateBankIDRequest,
5
5
  CollectBankIDRequest,
6
- CreateAssessmentRequest,
7
6
  CreateBillingPortalRequest,
8
7
  CreateCheckoutSessionRequest,
9
8
  CreateLikeRequest,
10
- CreatePLSRequest,
9
+ CreatePLSAssessmentRequest,
10
+ CreatePLSInputRequest,
11
+ CreatePLSSubmissionRequest,
11
12
  CreateReportRequest,
12
- CreateSubmissionRequest,
13
- GetAssessmentRequest,
14
13
  GetMatchableUserRequest,
15
14
  GetMatchCheckRequest,
16
15
  GetMatchesRequest,
17
16
  GetMatchRequest,
18
17
  GetMessagesRequest,
18
+ GetPLSAssessmentRequest,
19
+ GetPLSSubmissionRequest,
19
20
  GetProductsRequest,
20
- GetSubmissionRequest,
21
21
  GetUserRequest,
22
22
  HandleLikeSeenRequest,
23
23
  HandleMatchSeenRequest,
@@ -25,8 +25,10 @@ import {
25
25
  RegisterUserRequest,
26
26
  RemoveMatchRequest,
27
27
  SendMessageRequest,
28
+ SubmitAnswerRequest,
28
29
  SubmitCategoryFeedbackRequest,
29
- UpdateAnswerRequest,
30
+ SubmitPLSCategoryFeedbackRequest,
31
+ UpdatePLSAnswerRequest,
30
32
  UpdateQuestionsRequest,
31
33
  UpdateUserRequest,
32
34
  } from "./request.types";
@@ -34,23 +36,23 @@ import {
34
36
  AddImagesResponse,
35
37
  AuthenticateBankIDResponse,
36
38
  CollectBankIDResponse,
37
- CreateAssessmentResponse,
38
39
  CreateBillingPortalResponse,
39
40
  CreateCheckoutSessionResponse,
40
41
  CreateLikeResponse,
41
- CreatePLSResponse,
42
+ CreatePLSAssessmentResponse,
43
+ CreatePLSInputResponse,
44
+ CreatePLSSubmissionResponse,
42
45
  CreateReportResponse,
43
- CreateSubmissionResponse,
44
- GetAssessmentResponse,
45
- GetAssessmentsResponse,
46
46
  GetMatchableUserResponse,
47
47
  GetMatchableUsersResponse,
48
48
  GetMatchCheckResponse,
49
49
  GetMatchesResponse,
50
50
  GetMatchResponse,
51
51
  GetMessagesResponse,
52
+ GetPLSAssessmentResponse,
53
+ GetPLSAssessmentsResponse,
54
+ GetPLSSubmissionResponse,
52
55
  GetProductsResponse,
53
- GetSubmissionResponse,
54
56
  GetUserResponse,
55
57
  HandleLikeSeenResponse,
56
58
  HandleMatchSeenResponse,
@@ -58,50 +60,23 @@ import {
58
60
  RegisterUserResponse,
59
61
  RemoveMatchResponse,
60
62
  SendMessageResponse,
63
+ SubmitAnswerResponse,
61
64
  SubmitCategoryFeedbackResponse,
62
- UpdateAnswerResponse,
65
+ SubmitPLSCategoryFeedbackResponse,
66
+ UpdatePLSAnswerResponse,
63
67
  UpdateQuestionsResponse,
64
68
  UpdateUserResponse,
65
69
  } from "./response.types";
66
70
 
67
71
  // Define a mapping of Cloud Functions to payload and response types
68
72
  export type CloudFunctionTypes = {
69
- // Assessment
70
- [CloudFunction.CREATE_ASSESSMENT]: {
71
- payload: CreateAssessmentRequest;
72
- response: CreateAssessmentResponse;
73
- };
74
- [CloudFunction.GET_ASSESSMENT]: {
75
- payload: GetAssessmentRequest;
76
- response: GetAssessmentResponse;
77
- };
78
- [CloudFunction.GET_ASSESSMENTS]: {
79
- payload?: undefined;
80
- response: GetAssessmentsResponse;
81
- };
82
- // Auth
73
+ // auth
83
74
  [CloudFunction.REGISTER_USER]: {
84
75
  payload: RegisterUserRequest;
85
76
  response: RegisterUserResponse;
86
77
  };
87
- // Submission
88
- [CloudFunction.CREATE_SUBMISSION]: {
89
- payload: CreateSubmissionRequest;
90
- response: CreateSubmissionResponse;
91
- };
92
- [CloudFunction.GET_SUBMISSION]: {
93
- payload: GetSubmissionRequest;
94
- response: GetSubmissionResponse;
95
- };
96
- [CloudFunction.UPDATE_ANSWER]: {
97
- payload: UpdateAnswerRequest;
98
- response: UpdateAnswerResponse;
99
- };
100
- [CloudFunction.SUBMIT_CATEGORY_FEEDBACK]: {
101
- payload: SubmitCategoryFeedbackRequest;
102
- response: SubmitCategoryFeedbackResponse;
103
- };
104
- // BankID
78
+
79
+ // bankID
105
80
  [CloudFunction.AUTHENTICATE_BANKID]: {
106
81
  payload: AuthenticateBankIDRequest;
107
82
  response: AuthenticateBankIDResponse;
@@ -110,7 +85,18 @@ export type CloudFunctionTypes = {
110
85
  payload: CollectBankIDRequest;
111
86
  response: CollectBankIDResponse;
112
87
  };
113
- // Like
88
+
89
+ // ca
90
+ [CloudFunction.SUBMIT_ANSWER]: {
91
+ payload: SubmitAnswerRequest;
92
+ response: SubmitAnswerResponse;
93
+ };
94
+ [CloudFunction.SUBMIT_CATEGORY_FEEDBACK]: {
95
+ payload: SubmitCategoryFeedbackRequest;
96
+ response: SubmitCategoryFeedbackResponse;
97
+ };
98
+
99
+ // like
114
100
  [CloudFunction.CREATE_LIKE]: {
115
101
  payload: CreateLikeRequest;
116
102
  response: CreateLikeResponse;
@@ -123,7 +109,8 @@ export type CloudFunctionTypes = {
123
109
  payload: HandleLikeSeenRequest;
124
110
  response: HandleLikeSeenResponse;
125
111
  };
126
- // Match
112
+
113
+ // match
127
114
  [CloudFunction.GET_MATCH]: {
128
115
  payload: GetMatchRequest;
129
116
  response: GetMatchResponse;
@@ -152,7 +139,8 @@ export type CloudFunctionTypes = {
152
139
  payload: GetMatchableUsersResponse;
153
140
  response: GetMatchableUsersResponse;
154
141
  };
155
- // Messages
142
+
143
+ // messages
156
144
  [CloudFunction.SEND_MESSAGE]: {
157
145
  payload: SendMessageRequest;
158
146
  response: SendMessageResponse;
@@ -161,27 +149,60 @@ export type CloudFunctionTypes = {
161
149
  payload: GetMessagesRequest;
162
150
  response: GetMessagesResponse;
163
151
  };
164
- // PLS
165
- [CloudFunction.CREATE_PLS]: {
166
- payload: CreatePLSRequest;
167
- response: CreatePLSResponse;
152
+
153
+ // pls
154
+ [CloudFunction.CREATE_PLS_INPUT]: {
155
+ payload: CreatePLSInputRequest;
156
+ response: CreatePLSInputResponse;
157
+ };
158
+ [CloudFunction.CREATE_PLS_SUBMISSION]: {
159
+ payload: CreatePLSSubmissionRequest;
160
+ response: CreatePLSSubmissionResponse;
161
+ };
162
+ [CloudFunction.GET_PLS_SUBMISSION]: {
163
+ payload: GetPLSSubmissionRequest;
164
+ response: GetPLSSubmissionResponse;
165
+ };
166
+ [CloudFunction.UPDATE_PLS_ANSWER]: {
167
+ payload: UpdatePLSAnswerRequest;
168
+ response: UpdatePLSAnswerResponse;
169
+ };
170
+ [CloudFunction.SUBMIT_PLS_CATEGORY_FEEDBACK]: {
171
+ payload: SubmitPLSCategoryFeedbackRequest;
172
+ response: SubmitPLSCategoryFeedbackResponse;
173
+ };
174
+ [CloudFunction.CREATE_PLS_ASSESSMENT]: {
175
+ payload: CreatePLSAssessmentRequest;
176
+ response: CreatePLSAssessmentResponse;
168
177
  };
169
- // Rating
178
+ [CloudFunction.GET_PLS_ASSESSMENT]: {
179
+ payload: GetPLSAssessmentRequest;
180
+ response: GetPLSAssessmentResponse;
181
+ };
182
+ [CloudFunction.GET_PLS_ASSESSMENTS]: {
183
+ payload?: undefined;
184
+ response: GetPLSAssessmentsResponse;
185
+ };
186
+
187
+ // rating
170
188
  [CloudFunction.UPDATE_QUESTIONS]: {
171
189
  payload: UpdateQuestionsRequest;
172
190
  response: UpdateQuestionsResponse;
173
191
  };
174
- // Report
192
+
193
+ // report
175
194
  [CloudFunction.CREATE_REPORT]: {
176
195
  payload: CreateReportRequest;
177
196
  response: CreateReportResponse;
178
197
  };
179
- // Storage
198
+
199
+ // storage
180
200
  [CloudFunction.ADD_IMAGES]: {
181
201
  payload: AddImagesRequest;
182
202
  response: AddImagesResponse;
183
203
  };
184
- // Stripe
204
+
205
+ // stripe
185
206
  [CloudFunction.GET_PRODUCTS]: {
186
207
  payload: GetProductsRequest;
187
208
  response: GetProductsResponse;
@@ -194,7 +215,8 @@ export type CloudFunctionTypes = {
194
215
  payload: CreateCheckoutSessionRequest;
195
216
  response: CreateCheckoutSessionResponse;
196
217
  };
197
- // User
218
+
219
+ // user
198
220
  [CloudFunction.REGISTER_ONBOARDING]: {
199
221
  payload: RegisterOnboardingRequest;
200
222
  response: RegisterOnboardingResponse;
@@ -1,4 +1,5 @@
1
1
  export * from "./assessment.types";
2
+ export * from "./ca.types";
2
3
  export * from "./cloud-function-types";
3
4
  export * from "./error.types";
4
5
  export * from "./helper.types";
@@ -14,27 +14,9 @@ export type RegisterUserRequest = {
14
14
  referrerId?: string;
15
15
  };
16
16
 
17
- // assessment
18
- export type CreateAssessmentRequest = { intimateTopics: boolean };
19
- export type GetAssessmentRequest = { id: string };
20
-
21
- // submission
22
- export type CreateSubmissionRequest = {
23
- assessmentId: string;
24
- };
25
- export type GetSubmissionRequest = {
26
- assessmentId: string;
27
- submissionId: string;
28
- };
29
- export type UpdateAnswerRequest = {
30
- assessmentId: string;
31
- submissionId: string;
32
- categoryId: string;
33
- answer: Answer;
34
- };
17
+ // ca
18
+ export type SubmitAnswerRequest = { categoryId: string; answer: Answer };
35
19
  export type SubmitCategoryFeedbackRequest = {
36
- assessmentId: string;
37
- submissionId: string;
38
20
  categoryId: string;
39
21
  agreement: FeedbackAgreement;
40
22
  evaluationReflection: string;
@@ -74,11 +56,34 @@ export type GetMatchableUserRequest = { userId: string };
74
56
  export type GetMatchCheckRequest = { userId: string };
75
57
 
76
58
  // pls
77
- export type CreatePLSRequest = {
59
+ export type CreatePLSInputRequest = {
78
60
  questionnaire: Record<string, string>;
79
61
  channelId: string;
80
62
  variation: string;
81
63
  };
64
+ export type CreatePLSSubmissionRequest = {
65
+ assessmentId: string;
66
+ };
67
+ export type GetPLSSubmissionRequest = {
68
+ assessmentId: string;
69
+ submissionId: string;
70
+ };
71
+ export type UpdatePLSAnswerRequest = {
72
+ assessmentId: string;
73
+ submissionId: string;
74
+ categoryId: string;
75
+ answer: Answer;
76
+ };
77
+ export type SubmitPLSCategoryFeedbackRequest = {
78
+ assessmentId: string;
79
+ submissionId: string;
80
+ categoryId: string;
81
+ agreement: FeedbackAgreement;
82
+ evaluationReflection: string;
83
+ additionalThoughts: string;
84
+ };
85
+ export type CreatePLSAssessmentRequest = { intimateTopics: boolean };
86
+ export type GetPLSAssessmentRequest = { id: string };
82
87
 
83
88
  // rating
84
89
  export type UpdateQuestionsRequest = { questions: Record<string, string> };
@@ -5,6 +5,7 @@ import { Message } from "./message.types";
5
5
  import { StripeProduct } from "./stripe.types";
6
6
  import { User } from "./user.types";
7
7
  import { Like } from "./like.types";
8
+ import { CA } from "./ca.types";
8
9
 
9
10
  // auth
10
11
  export type RegisterUserResponse = {
@@ -12,18 +13,6 @@ export type RegisterUserResponse = {
12
13
  message: string;
13
14
  };
14
15
 
15
- // assessment
16
- export type CreateAssessmentResponse = Assessment;
17
- export type GetAssessmentResponse = Assessment;
18
- export type GetAssessmentsResponse = FullAssessment[];
19
- export type CreateSubmissionResponse = Submission;
20
- export type GetSubmissionResponse = Submission;
21
- export type UpdateAnswerResponse = {
22
- submission: Submission;
23
- categoryEvaluation?: CategoryEvaluation;
24
- };
25
- export type SubmitCategoryFeedbackResponse = CategoryEvaluation;
26
-
27
16
  //BankID
28
17
  export type AuthenticateBankIDResponse = {
29
18
  orderRef: string;
@@ -38,6 +27,13 @@ export interface CollectBankIDResponse {
38
27
  hintCode?: string;
39
28
  }
40
29
 
30
+ // ca
31
+ export type SubmitAnswerResponse = {
32
+ ca: CA;
33
+ categoryEvaluation?: CategoryEvaluation;
34
+ };
35
+ export type SubmitCategoryFeedbackResponse = CategoryEvaluation;
36
+
41
37
  // message
42
38
  export type SendMessageResponse = Message;
43
39
  export type GetMessagesResponse = Message[];
@@ -57,7 +53,17 @@ export type GetLikesResponse = Like[];
57
53
  export type HandleLikeSeenResponse = void;
58
54
 
59
55
  // pls
60
- export type CreatePLSResponse = void;
56
+ export type CreatePLSInputResponse = void;
57
+ export type CreatePLSAssessmentResponse = Assessment;
58
+ export type GetPLSAssessmentResponse = Assessment;
59
+ export type GetPLSAssessmentsResponse = FullAssessment[];
60
+ export type CreatePLSSubmissionResponse = Submission;
61
+ export type GetPLSSubmissionResponse = Submission;
62
+ export type UpdatePLSAnswerResponse = {
63
+ submission: Submission;
64
+ categoryEvaluation?: CategoryEvaluation;
65
+ };
66
+ export type SubmitPLSCategoryFeedbackResponse = CategoryEvaluation;
61
67
 
62
68
  // rating
63
69
  export type UpdateQuestionsResponse = void;