@abihealth/goapp-react-native 1.13.4
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/CHANGELOG.md +157 -0
- package/README.md +3 -0
- package/dist/common/animations/Animation.d.ts +10 -0
- package/dist/common/animations/Animation.js +38 -0
- package/dist/common/animations/FindingAnimation/index.d.ts +2 -0
- package/dist/common/animations/FindingAnimation/index.js +20 -0
- package/dist/common/animations/FindingAnimation/xml.d.ts +2 -0
- package/dist/common/animations/FindingAnimation/xml.js +7 -0
- package/dist/common/animations/HorizontalLoadingAnimation/index.d.ts +5 -0
- package/dist/common/animations/HorizontalLoadingAnimation/index.js +14 -0
- package/dist/common/animations/HorizontalLoadingAnimation/xml.d.ts +1 -0
- package/dist/common/animations/HorizontalLoadingAnimation/xml.js +5 -0
- package/dist/common/animations/LoadingCircleAnimation/index.d.ts +2 -0
- package/dist/common/animations/LoadingCircleAnimation/index.js +24 -0
- package/dist/common/animations/LoadingCircleAnimation/xml.d.ts +2 -0
- package/dist/common/animations/LoadingCircleAnimation/xml.js +5 -0
- package/dist/common/animations/LoadingDotsAnimation/index.d.ts +6 -0
- package/dist/common/animations/LoadingDotsAnimation/index.js +17 -0
- package/dist/common/animations/LoadingDotsAnimation/xml.d.ts +1 -0
- package/dist/common/animations/LoadingDotsAnimation/xml.js +5 -0
- package/dist/common/animations/LoadingHeart.d.ts +2 -0
- package/dist/common/animations/LoadingHeart.js +92 -0
- package/dist/common/api/auth.d.ts +2 -0
- package/dist/common/api/auth.js +18 -0
- package/dist/common/api/config.d.ts +7 -0
- package/dist/common/api/config.js +15 -0
- package/dist/common/api/consultation.d.ts +6 -0
- package/dist/common/api/consultation.js +80 -0
- package/dist/common/api/models/auth.d.ts +8 -0
- package/dist/common/api/models/auth.js +2 -0
- package/dist/common/api/models/consultation.d.ts +70 -0
- package/dist/common/api/models/consultation.js +23 -0
- package/dist/common/api/models/region.d.ts +1 -0
- package/dist/common/api/models/region.js +2 -0
- package/dist/common/api/models/user.d.ts +5 -0
- package/dist/common/api/models/user.js +2 -0
- package/dist/common/api/models/websocket.d.ts +6 -0
- package/dist/common/api/models/websocket.js +2 -0
- package/dist/common/api/user.d.ts +2 -0
- package/dist/common/api/user.js +10 -0
- package/dist/common/api/websocket.d.ts +6 -0
- package/dist/common/api/websocket.js +66 -0
- package/dist/common/assets/background-pattern.png +0 -0
- package/dist/common/components/ActionSheet.d.ts +6 -0
- package/dist/common/components/ActionSheet.js +43 -0
- package/dist/common/components/AnswerScreen/Card.d.ts +8 -0
- package/dist/common/components/AnswerScreen/Card.js +76 -0
- package/dist/common/components/AnswerScreen/CloseConsultationActionSheet.d.ts +2 -0
- package/dist/common/components/AnswerScreen/CloseConsultationActionSheet.js +109 -0
- package/dist/common/components/AnswerScreen/DeliveryAddressCard.d.ts +5 -0
- package/dist/common/components/AnswerScreen/DeliveryAddressCard.js +39 -0
- package/dist/common/components/AnswerScreen/PrescriptionCard/PrescriptionCardHeader.d.ts +5 -0
- package/dist/common/components/AnswerScreen/PrescriptionCard/PrescriptionCardHeader.js +79 -0
- package/dist/common/components/AnswerScreen/PrescriptionCard/index.d.ts +5 -0
- package/dist/common/components/AnswerScreen/PrescriptionCard/index.js +46 -0
- package/dist/common/components/AnswerScreen/Summary.d.ts +5 -0
- package/dist/common/components/AnswerScreen/Summary.js +49 -0
- package/dist/common/components/BackgroundPattern.d.ts +2 -0
- package/dist/common/components/BackgroundPattern.js +19 -0
- package/dist/common/components/Button.d.ts +14 -0
- package/dist/common/components/Button.js +124 -0
- package/dist/common/components/CancelConsultationButton.d.ts +2 -0
- package/dist/common/components/CancelConsultationButton.js +107 -0
- package/dist/common/components/Card.d.ts +2 -0
- package/dist/common/components/Card.js +13 -0
- package/dist/common/components/Checkbox.d.ts +7 -0
- package/dist/common/components/Checkbox.js +75 -0
- package/dist/common/components/DateInput.d.ts +8 -0
- package/dist/common/components/DateInput.js +76 -0
- package/dist/common/components/DoctorProfileCard.d.ts +8 -0
- package/dist/common/components/DoctorProfileCard.js +128 -0
- package/dist/common/components/FadeIn.d.ts +8 -0
- package/dist/common/components/FadeIn.js +66 -0
- package/dist/common/components/FormControl.d.ts +8 -0
- package/dist/common/components/FormControl.js +40 -0
- package/dist/common/components/FormWrapper.d.ts +11 -0
- package/dist/common/components/FormWrapper.js +46 -0
- package/dist/common/components/Header.d.ts +10 -0
- package/dist/common/components/Header.js +109 -0
- package/dist/common/components/Input.d.ts +8 -0
- package/dist/common/components/Input.js +74 -0
- package/dist/common/components/Modal/AttachmentPreviewModal.d.ts +9 -0
- package/dist/common/components/Modal/AttachmentPreviewModal.js +68 -0
- package/dist/common/components/Modal/CancelModal.d.ts +9 -0
- package/dist/common/components/Modal/CancelModal.js +16 -0
- package/dist/common/components/Modal/CloseConsultationModal.d.ts +9 -0
- package/dist/common/components/Modal/CloseConsultationModal.js +16 -0
- package/dist/common/components/Modal/DoctorProfileModal.d.ts +8 -0
- package/dist/common/components/Modal/DoctorProfileModal.js +47 -0
- package/dist/common/components/Modal/ModalHeader.d.ts +7 -0
- package/dist/common/components/Modal/ModalHeader.js +40 -0
- package/dist/common/components/Modal/TwoOptionsModal.d.ts +14 -0
- package/dist/common/components/Modal/TwoOptionsModal.js +58 -0
- package/dist/common/components/Modal/index.d.ts +7 -0
- package/dist/common/components/Modal/index.js +57 -0
- package/dist/common/components/PhoneInput.d.ts +11 -0
- package/dist/common/components/PhoneInput.js +81 -0
- package/dist/common/components/Reminder.d.ts +7 -0
- package/dist/common/components/Reminder.js +214 -0
- package/dist/common/components/ScreenWrapper.d.ts +12 -0
- package/dist/common/components/ScreenWrapper.js +46 -0
- package/dist/common/components/Select.d.ts +17 -0
- package/dist/common/components/Select.js +132 -0
- package/dist/common/components/Slide.d.ts +13 -0
- package/dist/common/components/Slide.js +83 -0
- package/dist/common/components/SlideUp.d.ts +8 -0
- package/dist/common/components/SlideUp.js +69 -0
- package/dist/common/components/Text.d.ts +22 -0
- package/dist/common/components/Text.js +130 -0
- package/dist/common/contexts/ConsultationContext.d.ts +22 -0
- package/dist/common/contexts/ConsultationContext.js +215 -0
- package/dist/common/contexts/FormContext.d.ts +25 -0
- package/dist/common/contexts/FormContext.js +55 -0
- package/dist/common/contexts/ThemeContext.d.ts +13 -0
- package/dist/common/contexts/ThemeContext.js +18 -0
- package/dist/common/hooks/useConsultation.d.ts +13 -0
- package/dist/common/hooks/useConsultation.js +166 -0
- package/dist/common/hooks/useForm.d.ts +10 -0
- package/dist/common/hooks/useForm.js +107 -0
- package/dist/common/hooks/useHeader.d.ts +4 -0
- package/dist/common/hooks/useHeader.js +10 -0
- package/dist/common/hooks/useTheme.d.ts +2 -0
- package/dist/common/hooks/useTheme.js +26 -0
- package/dist/common/hooks/useUser.d.ts +4 -0
- package/dist/common/hooks/useUser.js +10 -0
- package/dist/common/icons/AbiLogoIcon.d.ts +2 -0
- package/dist/common/icons/AbiLogoIcon.js +53 -0
- package/dist/common/icons/BackArrowIcon.d.ts +2 -0
- package/dist/common/icons/BackArrowIcon.js +49 -0
- package/dist/common/icons/CalendarIcon.d.ts +3 -0
- package/dist/common/icons/CalendarIcon.js +43 -0
- package/dist/common/icons/CheckSuccessIcon.d.ts +3 -0
- package/dist/common/icons/CheckSuccessIcon.js +47 -0
- package/dist/common/icons/CloseIcon.d.ts +5 -0
- package/dist/common/icons/CloseIcon.js +51 -0
- package/dist/common/icons/DoctorIcon.d.ts +3 -0
- package/dist/common/icons/DoctorIcon.js +48 -0
- package/dist/common/icons/DoctorImagePlaceholderIcon.d.ts +5 -0
- package/dist/common/icons/DoctorImagePlaceholderIcon.js +64 -0
- package/dist/common/icons/DropdownIcon.d.ts +3 -0
- package/dist/common/icons/DropdownIcon.js +41 -0
- package/dist/common/icons/ExitIcon.d.ts +2 -0
- package/dist/common/icons/ExitIcon.js +58 -0
- package/dist/common/icons/InfoIcon.d.ts +2 -0
- package/dist/common/icons/InfoIcon.js +49 -0
- package/dist/common/icons/KoCircleIcon.d.ts +3 -0
- package/dist/common/icons/KoCircleIcon.js +42 -0
- package/dist/common/icons/MotorbikeIcon.d.ts +2 -0
- package/dist/common/icons/MotorbikeIcon.js +65 -0
- package/dist/common/icons/NoCaseFoundIcon.d.ts +3 -0
- package/dist/common/icons/NoCaseFoundIcon.js +55 -0
- package/dist/common/icons/PdfDownloadIcon.d.ts +2 -0
- package/dist/common/icons/PdfDownloadIcon.js +58 -0
- package/dist/common/icons/PdfIcon.d.ts +2 -0
- package/dist/common/icons/PdfIcon.js +50 -0
- package/dist/common/icons/PersonIcon.d.ts +3 -0
- package/dist/common/icons/PersonIcon.js +45 -0
- package/dist/common/icons/PillsIcon.d.ts +2 -0
- package/dist/common/icons/PillsIcon.js +52 -0
- package/dist/common/icons/PlaneIcon.d.ts +5 -0
- package/dist/common/icons/PlaneIcon.js +48 -0
- package/dist/common/icons/RatingIcon.d.ts +2 -0
- package/dist/common/icons/RatingIcon.js +53 -0
- package/dist/common/icons/StarIcon.d.ts +4 -0
- package/dist/common/icons/StarIcon.js +57 -0
- package/dist/common/icons/TextConsultationIcon.d.ts +4 -0
- package/dist/common/icons/TextConsultationIcon.js +53 -0
- package/dist/common/icons/TrashIcon.d.ts +2 -0
- package/dist/common/icons/TrashIcon.js +49 -0
- package/dist/common/icons/VideoConsultationIcon.d.ts +4 -0
- package/dist/common/icons/VideoConsultationIcon.js +50 -0
- package/dist/common/index.d.ts +57 -0
- package/dist/common/index.js +114 -0
- package/dist/common/locale/i18n.d.ts +5 -0
- package/dist/common/locale/i18n.js +79 -0
- package/dist/common/locale/translations/ar-AE.base.json +604 -0
- package/dist/common/locale/translations/ar-LB.base.json +604 -0
- package/dist/common/locale/translations/bg.base.json +488 -0
- package/dist/common/locale/translations/cs.base.json +499 -0
- package/dist/common/locale/translations/en.base.json +923 -0
- package/dist/common/locale/translations/es-MX.base.json +827 -0
- package/dist/common/locale/translations/es.base.json +827 -0
- package/dist/common/locale/translations/fr.base.json +605 -0
- package/dist/common/locale/translations/hu.base.json +488 -0
- package/dist/common/locale/translations/pl.base.json +487 -0
- package/dist/common/locale/translations/ro.base.json +501 -0
- package/dist/common/locale/translations/ru.base.json +603 -0
- package/dist/common/locale/translations/sk.base.json +535 -0
- package/dist/common/locale/translations/zh-HK.base.json +349 -0
- package/dist/common/locale/translations/zh-SG.base.json +603 -0
- package/dist/common/locale/translations/zh-TW.base.json +873 -0
- package/dist/common/screens/AnswerScreen.d.ts +11 -0
- package/dist/common/screens/AnswerScreen.js +101 -0
- package/dist/common/screens/MatchScreen.d.ts +5 -0
- package/dist/common/screens/MatchScreen.js +36 -0
- package/dist/common/screens/MatchingScreen.d.ts +2 -0
- package/dist/common/screens/MatchingScreen.js +41 -0
- package/dist/common/screens/NoConsultationFoundScreen.d.ts +2 -0
- package/dist/common/screens/NoConsultationFoundScreen.js +34 -0
- package/dist/common/screens/PreparingSummaryScreen.d.ts +5 -0
- package/dist/common/screens/PreparingSummaryScreen.js +35 -0
- package/dist/common/screens/RatingScreen.d.ts +2 -0
- package/dist/common/screens/RatingScreen.js +198 -0
- package/dist/common/screens/index.d.ts +3 -0
- package/dist/common/screens/index.js +29 -0
- package/dist/common/types/consultation.d.ts +93 -0
- package/dist/common/types/consultation.js +41 -0
- package/dist/common/types/deliveryAddress.d.ts +18 -0
- package/dist/common/types/deliveryAddress.js +11 -0
- package/dist/common/types/events.d.ts +13 -0
- package/dist/common/types/events.js +15 -0
- package/dist/common/types/prescription.d.ts +52 -0
- package/dist/common/types/prescription.js +31 -0
- package/dist/common/types/professional.d.ts +14 -0
- package/dist/common/types/professional.js +2 -0
- package/dist/common/types/theme.d.ts +82 -0
- package/dist/common/types/theme.js +58 -0
- package/dist/common/types/user.d.ts +10 -0
- package/dist/common/types/user.js +2 -0
- package/dist/common/utils/platform.d.ts +3 -0
- package/dist/common/utils/platform.js +7 -0
- package/dist/common/utils/professional.d.ts +2 -0
- package/dist/common/utils/professional.js +12 -0
- package/dist/common/utils/zod.d.ts +5 -0
- package/dist/common/utils/zod.js +19 -0
- package/dist/index.d.ts +65 -0
- package/dist/index.js +133 -0
- package/dist/video-consultations/animations/CallingAnimation/index.d.ts +2 -0
- package/dist/video-consultations/animations/CallingAnimation/index.js +17 -0
- package/dist/video-consultations/animations/CallingAnimation/xml.d.ts +2 -0
- package/dist/video-consultations/animations/CallingAnimation/xml.js +5 -0
- package/dist/video-consultations/api/models/video.d.ts +10 -0
- package/dist/video-consultations/api/models/video.js +2 -0
- package/dist/video-consultations/api/video.d.ts +3 -0
- package/dist/video-consultations/api/video.js +12 -0
- package/dist/video-consultations/components/AgoraWrapper/components/BaseRenderUsers.d.ts +12 -0
- package/dist/video-consultations/components/AgoraWrapper/components/BaseRenderUsers.js +174 -0
- package/dist/video-consultations/components/AgoraWrapper/components/BtnControls.d.ts +14 -0
- package/dist/video-consultations/components/AgoraWrapper/components/BtnControls.js +55 -0
- package/dist/video-consultations/components/AgoraWrapper/components/ui/index.d.ts +14 -0
- package/dist/video-consultations/components/AgoraWrapper/components/ui/index.js +100 -0
- package/dist/video-consultations/components/AgoraWrapper/index.d.ts +8 -0
- package/dist/video-consultations/components/AgoraWrapper/index.js +173 -0
- package/dist/video-consultations/components/Modal/EndVideoCallModal.d.ts +8 -0
- package/dist/video-consultations/components/Modal/EndVideoCallModal.js +15 -0
- package/dist/video-consultations/components/VideoConsultation.d.ts +7 -0
- package/dist/video-consultations/components/VideoConsultation.js +42 -0
- package/dist/video-consultations/helpers/eventHandler.d.ts +14 -0
- package/dist/video-consultations/helpers/eventHandler.js +61 -0
- package/dist/video-consultations/hooks/useInitRtcEngine.d.ts +15 -0
- package/dist/video-consultations/hooks/useInitRtcEngine.js +194 -0
- package/dist/video-consultations/icons/EndVideoCallIcon.d.ts +2 -0
- package/dist/video-consultations/icons/EndVideoCallIcon.js +51 -0
- package/dist/video-consultations/icons/HangUpIcon.d.ts +3 -0
- package/dist/video-consultations/icons/HangUpIcon.js +41 -0
- package/dist/video-consultations/icons/MicroOffIcon.d.ts +7 -0
- package/dist/video-consultations/icons/MicroOffIcon.js +47 -0
- package/dist/video-consultations/icons/MicroOnIcon.d.ts +3 -0
- package/dist/video-consultations/icons/MicroOnIcon.js +42 -0
- package/dist/video-consultations/icons/PersonIcon.d.ts +3 -0
- package/dist/video-consultations/icons/PersonIcon.js +45 -0
- package/dist/video-consultations/icons/SwitchCameraIcon.d.ts +3 -0
- package/dist/video-consultations/icons/SwitchCameraIcon.js +41 -0
- package/dist/video-consultations/icons/VideoOffIcon.d.ts +5 -0
- package/dist/video-consultations/icons/VideoOffIcon.js +44 -0
- package/dist/video-consultations/icons/VideoOnIcon.d.ts +3 -0
- package/dist/video-consultations/icons/VideoOnIcon.js +41 -0
- package/dist/video-consultations/index.d.ts +10 -0
- package/dist/video-consultations/index.js +24 -0
- package/dist/video-consultations/screens/DeliveryAddressScreen.d.ts +2 -0
- package/dist/video-consultations/screens/DeliveryAddressScreen.js +84 -0
- package/dist/video-consultations/screens/EndingVideoScreen.d.ts +5 -0
- package/dist/video-consultations/screens/EndingVideoScreen.js +27 -0
- package/dist/video-consultations/screens/JoinVideoCallScreen.d.ts +5 -0
- package/dist/video-consultations/screens/JoinVideoCallScreen.js +108 -0
- package/dist/video-consultations/screens/ProcessingPrescriptionScreen.d.ts +2 -0
- package/dist/video-consultations/screens/ProcessingPrescriptionScreen.js +32 -0
- package/dist/video-consultations/screens/VideoCallScreen.d.ts +3 -0
- package/dist/video-consultations/screens/VideoCallScreen.js +77 -0
- package/dist/video-consultations/utils/permission.d.ts +14 -0
- package/dist/video-consultations/utils/permission.js +97 -0
- package/package.json +58 -0
|
@@ -0,0 +1,130 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
36
|
+
var t = {};
|
|
37
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
38
|
+
t[p] = s[p];
|
|
39
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
40
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
41
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
42
|
+
t[p[i]] = s[p[i]];
|
|
43
|
+
}
|
|
44
|
+
return t;
|
|
45
|
+
};
|
|
46
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
+
exports.Text = exports.TEXT_VARIANT = void 0;
|
|
48
|
+
var react_1 = __importStar(require("react"));
|
|
49
|
+
var react_native_1 = require("react-native");
|
|
50
|
+
var useTheme_1 = require("../hooks/useTheme");
|
|
51
|
+
var TEXT_VARIANT;
|
|
52
|
+
(function (TEXT_VARIANT) {
|
|
53
|
+
TEXT_VARIANT["h1"] = "h1";
|
|
54
|
+
TEXT_VARIANT["h2"] = "h2";
|
|
55
|
+
TEXT_VARIANT["h3"] = "h3";
|
|
56
|
+
TEXT_VARIANT["h4"] = "h4";
|
|
57
|
+
TEXT_VARIANT["base"] = "base";
|
|
58
|
+
TEXT_VARIANT["sm"] = "sm";
|
|
59
|
+
TEXT_VARIANT["button"] = "button";
|
|
60
|
+
})(TEXT_VARIANT || (exports.TEXT_VARIANT = TEXT_VARIANT = {}));
|
|
61
|
+
var getDefaultFontWeight = function (variant, bold) {
|
|
62
|
+
if (bold)
|
|
63
|
+
return 'bold';
|
|
64
|
+
switch (variant) {
|
|
65
|
+
case 'h1':
|
|
66
|
+
case 'h2':
|
|
67
|
+
case 'h3':
|
|
68
|
+
case 'h4':
|
|
69
|
+
case 'button':
|
|
70
|
+
return 'bold';
|
|
71
|
+
case 'base':
|
|
72
|
+
case 'sm':
|
|
73
|
+
default:
|
|
74
|
+
return 'normal';
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
var getDefaultFontSize = function (variant, _a) {
|
|
78
|
+
var fontSize = _a.fontSize;
|
|
79
|
+
switch (variant) {
|
|
80
|
+
case 'h1':
|
|
81
|
+
return fontSize.h1;
|
|
82
|
+
case 'h2':
|
|
83
|
+
return fontSize.h2;
|
|
84
|
+
case 'h3':
|
|
85
|
+
return fontSize.h3;
|
|
86
|
+
case 'h4':
|
|
87
|
+
return fontSize.h4;
|
|
88
|
+
case 'button':
|
|
89
|
+
return fontSize.sm;
|
|
90
|
+
case 'sm':
|
|
91
|
+
return fontSize.sm;
|
|
92
|
+
case 'base':
|
|
93
|
+
default:
|
|
94
|
+
return fontSize.base;
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
var getDefaultLineHeight = function (variant, _a) {
|
|
98
|
+
var lineHeight = _a.lineHeight;
|
|
99
|
+
switch (variant) {
|
|
100
|
+
case 'h1':
|
|
101
|
+
return lineHeight.xxl;
|
|
102
|
+
case 'h2':
|
|
103
|
+
return lineHeight.xl;
|
|
104
|
+
case 'button':
|
|
105
|
+
return lineHeight.sm;
|
|
106
|
+
case 'h3':
|
|
107
|
+
case 'h4':
|
|
108
|
+
case 'sm':
|
|
109
|
+
case 'base':
|
|
110
|
+
default:
|
|
111
|
+
return lineHeight.base;
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
exports.Text = (0, react_1.forwardRef)(function (props, ref) {
|
|
115
|
+
var theme = (0, useTheme_1.useTheme)();
|
|
116
|
+
var children = props.children, _a = props.variant, variant = _a === void 0 ? 'base' : _a, style = props.style, bold = props.bold, color = props.color, center = props.center, shrink = props.shrink, rest = __rest(props, ["children", "variant", "style", "bold", "color", "center", "shrink"]);
|
|
117
|
+
var isButton = variant === 'button';
|
|
118
|
+
var defaultStyle = (0, react_1.useMemo)(function () { return ({
|
|
119
|
+
fontSize: getDefaultFontSize(variant, theme),
|
|
120
|
+
fontWeight: getDefaultFontWeight(variant, bold),
|
|
121
|
+
lineHeight: getDefaultLineHeight(variant, theme),
|
|
122
|
+
color: color || (isButton ? theme.colors.white : theme.colors.text),
|
|
123
|
+
textTransform: isButton ? 'uppercase' : 'none',
|
|
124
|
+
textAlign: center ? 'center' : 'auto',
|
|
125
|
+
flexShrink: shrink ? 1 : 0
|
|
126
|
+
}); }, [variant, isButton, bold, color, center, shrink, theme]);
|
|
127
|
+
return (<react_native_1.Text ref={ref} style={[defaultStyle, style]} {...rest}>
|
|
128
|
+
{children}
|
|
129
|
+
</react_native_1.Text>);
|
|
130
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { Dispatch, PropsWithChildren, SetStateAction } from 'react';
|
|
2
|
+
import { REGION } from '../api/models/region';
|
|
3
|
+
import { Consultation } from '../types/consultation';
|
|
4
|
+
import { RecursivePartial, Theme } from '../types/theme';
|
|
5
|
+
import { User } from '../types/user';
|
|
6
|
+
type ErrorCallback = (_: Error) => void;
|
|
7
|
+
interface ConsultationProviderProps {
|
|
8
|
+
region: REGION;
|
|
9
|
+
token: string;
|
|
10
|
+
userId: string;
|
|
11
|
+
theme?: RecursivePartial<Theme>;
|
|
12
|
+
onError?: ErrorCallback;
|
|
13
|
+
}
|
|
14
|
+
export type ConsultationContextProps = ConsultationProviderProps & {
|
|
15
|
+
consultation: Consultation | null;
|
|
16
|
+
setConsultation: Dispatch<SetStateAction<Consultation | null>>;
|
|
17
|
+
user: User;
|
|
18
|
+
setUser: Dispatch<SetStateAction<User>>;
|
|
19
|
+
};
|
|
20
|
+
export declare const ConsultationContext: import("react").Context<ConsultationContextProps>;
|
|
21
|
+
export declare const ConsultationProvider: ({ children, token, region, userId, theme, onError }: PropsWithChildren<ConsultationProviderProps>) => import("react").JSX.Element;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,215 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
45
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
46
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
47
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
48
|
+
function step(op) {
|
|
49
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
50
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
51
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
52
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
53
|
+
switch (op[0]) {
|
|
54
|
+
case 0: case 1: t = op; break;
|
|
55
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
56
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
57
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
58
|
+
default:
|
|
59
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
60
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
61
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
62
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
63
|
+
if (t[2]) _.ops.pop();
|
|
64
|
+
_.trys.pop(); continue;
|
|
65
|
+
}
|
|
66
|
+
op = body.call(thisArg, _);
|
|
67
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
68
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
69
|
+
}
|
|
70
|
+
};
|
|
71
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
72
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
73
|
+
};
|
|
74
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
75
|
+
exports.ConsultationProvider = exports.ConsultationContext = void 0;
|
|
76
|
+
var Sentry = __importStar(require("@sentry/react-native"));
|
|
77
|
+
var axios_1 = require("axios");
|
|
78
|
+
var react_1 = require("react");
|
|
79
|
+
var react_i18next_1 = require("react-i18next");
|
|
80
|
+
var react_native_1 = require("react-native");
|
|
81
|
+
var config_1 = require("../api/config");
|
|
82
|
+
var consultation_1 = require("../api/consultation");
|
|
83
|
+
var user_1 = require("../api/user");
|
|
84
|
+
var websocket_1 = require("../api/websocket");
|
|
85
|
+
var Text_1 = require("../components/Text");
|
|
86
|
+
var i18n_1 = __importDefault(require("../locale/i18n"));
|
|
87
|
+
var consultation_2 = require("../types/consultation");
|
|
88
|
+
var theme_1 = require("../types/theme");
|
|
89
|
+
var ThemeContext_1 = require("./ThemeContext");
|
|
90
|
+
Sentry.init({
|
|
91
|
+
dsn: 'https://96715a92da01f75091f8996d706f825a@o509172.ingest.us.sentry.io/4508844894912512',
|
|
92
|
+
spotlight: __DEV__,
|
|
93
|
+
tracesSampleRate: 1.0,
|
|
94
|
+
profilesSampleRate: 1.0
|
|
95
|
+
});
|
|
96
|
+
// eslint-disable-next-line react-refresh/only-export-components
|
|
97
|
+
exports.ConsultationContext = (0, react_1.createContext)({
|
|
98
|
+
region: 'ape1',
|
|
99
|
+
token: '',
|
|
100
|
+
userId: '',
|
|
101
|
+
consultation: null,
|
|
102
|
+
setConsultation: function () { },
|
|
103
|
+
theme: theme_1.DEFAULT_THEME,
|
|
104
|
+
user: null,
|
|
105
|
+
setUser: function () { }
|
|
106
|
+
});
|
|
107
|
+
var ConsultationProvider = function (_a) {
|
|
108
|
+
var children = _a.children, token = _a.token, region = _a.region, userId = _a.userId, theme = _a.theme, _b = _a.onError, onError = _b === void 0 ? function () { } : _b;
|
|
109
|
+
var _c = (0, react_1.useState)(null), consultation = _c[0], setConsultation = _c[1];
|
|
110
|
+
var _d = (0, react_1.useState)(null), user = _d[0], setUser = _d[1];
|
|
111
|
+
var _e = (0, react_1.useState)(null), websocket = _e[0], setWebsocket = _e[1];
|
|
112
|
+
var handleError = function (e) {
|
|
113
|
+
console.error('🚨 Error caught on handler', e);
|
|
114
|
+
Sentry.captureException(e, { level: 'error' });
|
|
115
|
+
onError(e);
|
|
116
|
+
};
|
|
117
|
+
var initialise = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
118
|
+
var userResponse, e_1, activeConsultation, e_2, ws, e_3;
|
|
119
|
+
return __generator(this, function (_a) {
|
|
120
|
+
switch (_a.label) {
|
|
121
|
+
case 0:
|
|
122
|
+
_a.trys.push([0, 2, , 3]);
|
|
123
|
+
return [4 /*yield*/, (0, user_1.getUser)({ userId: userId })
|
|
124
|
+
// Alert.alert(`👤 User: ${JSON.stringify(userResponse)}`)
|
|
125
|
+
];
|
|
126
|
+
case 1:
|
|
127
|
+
userResponse = _a.sent();
|
|
128
|
+
// Alert.alert(`👤 User: ${JSON.stringify(userResponse)}`)
|
|
129
|
+
setUser(userResponse);
|
|
130
|
+
return [3 /*break*/, 3];
|
|
131
|
+
case 2:
|
|
132
|
+
e_1 = _a.sent();
|
|
133
|
+
console.error('Error getting user', e_1);
|
|
134
|
+
throw e_1;
|
|
135
|
+
case 3:
|
|
136
|
+
_a.trys.push([3, 5, , 6]);
|
|
137
|
+
return [4 /*yield*/, (0, consultation_1.getActiveConsultation)(consultation_2.CASE_TYPE.VIDEO)({ userId: userId })];
|
|
138
|
+
case 4:
|
|
139
|
+
activeConsultation = _a.sent();
|
|
140
|
+
console.log('⏮️ Active:', activeConsultation.consultation);
|
|
141
|
+
// Alert.alert(`⏮️ Active: ${JSON.stringify(activeConsultation.consultation)}`)
|
|
142
|
+
setConsultation(activeConsultation === null || activeConsultation === void 0 ? void 0 : activeConsultation.consultation);
|
|
143
|
+
return [3 /*break*/, 6];
|
|
144
|
+
case 5:
|
|
145
|
+
e_2 = _a.sent();
|
|
146
|
+
if ((0, axios_1.isAxiosError)(e_2) && e_2.status === 404) {
|
|
147
|
+
setConsultation(null);
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
console.error('Error getting active consultation', e_2);
|
|
151
|
+
throw e_2;
|
|
152
|
+
}
|
|
153
|
+
return [3 /*break*/, 6];
|
|
154
|
+
case 6:
|
|
155
|
+
_a.trys.push([6, 8, , 9]);
|
|
156
|
+
return [4 /*yield*/, (0, websocket_1.connectWebsocket)({ token: token, userId: userId, region: region })];
|
|
157
|
+
case 7:
|
|
158
|
+
ws = _a.sent();
|
|
159
|
+
console.log('🔗 Websocket connected');
|
|
160
|
+
// Alert.alert('🔗 Websocket connected')
|
|
161
|
+
setWebsocket(ws);
|
|
162
|
+
return [3 /*break*/, 9];
|
|
163
|
+
case 8:
|
|
164
|
+
e_3 = _a.sent();
|
|
165
|
+
console.error('Error connecting to websocket', e_3);
|
|
166
|
+
throw e_3;
|
|
167
|
+
case 9: return [2 /*return*/];
|
|
168
|
+
}
|
|
169
|
+
});
|
|
170
|
+
}); };
|
|
171
|
+
(0, react_1.useEffect)(function () {
|
|
172
|
+
console.log('🏁 Token effect', token === null || token === void 0 ? void 0 : token.split('.').pop());
|
|
173
|
+
if (!token || !region || !userId)
|
|
174
|
+
return;
|
|
175
|
+
(0, config_1.configureAxios)({ token: token, region: region });
|
|
176
|
+
initialise().catch(function (e) {
|
|
177
|
+
console.error('Error initialising', e);
|
|
178
|
+
// Alert.alert('Error initialising', `${e.message}\n${JSON.stringify(e)}`)
|
|
179
|
+
handleError(e);
|
|
180
|
+
});
|
|
181
|
+
return function () {
|
|
182
|
+
console.log('Authorization cleanup', { token: token });
|
|
183
|
+
delete config_1.axios.defaults.headers.common.Authorization;
|
|
184
|
+
websocket === null || websocket === void 0 ? void 0 : websocket.close();
|
|
185
|
+
};
|
|
186
|
+
}, [token, region, userId]);
|
|
187
|
+
(0, react_1.useEffect)(function () {
|
|
188
|
+
console.log('WS changed', websocket);
|
|
189
|
+
if (!websocket)
|
|
190
|
+
return;
|
|
191
|
+
console.log('👂 Connecting onMessage...');
|
|
192
|
+
websocket.onmessage = function (event) {
|
|
193
|
+
var data = JSON.parse(event.data);
|
|
194
|
+
console.log('👀 Websocket message', event.data, data);
|
|
195
|
+
if (data.consultation)
|
|
196
|
+
setConsultation(data.consultation);
|
|
197
|
+
if (data.event === 'websocketError')
|
|
198
|
+
handleError(new Error('Websocket error'));
|
|
199
|
+
if (data.event === 'websocketConnected')
|
|
200
|
+
console.log('🟢🟢 Websocket connected');
|
|
201
|
+
};
|
|
202
|
+
}, [websocket]);
|
|
203
|
+
if (!token || !user) {
|
|
204
|
+
return (<react_native_1.View style={{ flex: 1, justifyContent: 'center', alignItems: 'center' }}>
|
|
205
|
+
<Text_1.Text>User or token not found {JSON.stringify({ token: token, user: user })}</Text_1.Text>
|
|
206
|
+
</react_native_1.View>);
|
|
207
|
+
}
|
|
208
|
+
var value = { token: token, region: region, userId: userId, theme: theme, consultation: consultation, setConsultation: setConsultation, onError: handleError, user: user, setUser: setUser };
|
|
209
|
+
return (<exports.ConsultationContext.Provider value={value}>
|
|
210
|
+
<react_i18next_1.I18nextProvider i18n={i18n_1.default}>
|
|
211
|
+
<ThemeContext_1.ThemeProvider theme={theme}>{children}</ThemeContext_1.ThemeProvider>
|
|
212
|
+
</react_i18next_1.I18nextProvider>
|
|
213
|
+
</exports.ConsultationContext.Provider>);
|
|
214
|
+
};
|
|
215
|
+
exports.ConsultationProvider = ConsultationProvider;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React, { PropsWithChildren } from 'react';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export type HandleSubmitProps<T extends z.AnyZodObject> = {
|
|
4
|
+
onSuccess?: (data: z.TypeOf<T>) => Promise<void>;
|
|
5
|
+
onError?: (errors: Record<keyof z.infer<T>, string>) => Promise<void>;
|
|
6
|
+
onFinally?: () => Promise<void>;
|
|
7
|
+
};
|
|
8
|
+
export type FormContextProps<T extends z.AnyZodObject> = {
|
|
9
|
+
data: z.infer<T> | null;
|
|
10
|
+
setData: React.Dispatch<React.SetStateAction<z.infer<T> | null>>;
|
|
11
|
+
errors: Record<keyof z.infer<T>, string> | null;
|
|
12
|
+
setErrors: React.Dispatch<React.SetStateAction<Record<keyof z.infer<T>, string> | null>>;
|
|
13
|
+
schema: T;
|
|
14
|
+
onSubmit?: HandleSubmitProps<T>;
|
|
15
|
+
loading: boolean;
|
|
16
|
+
setLoading: React.Dispatch<React.SetStateAction<boolean>>;
|
|
17
|
+
};
|
|
18
|
+
export declare const FormContext: React.Context<FormContextProps<any>>;
|
|
19
|
+
type FormProviderProps<T extends z.AnyZodObject> = {
|
|
20
|
+
schema: T;
|
|
21
|
+
initialValues?: Partial<z.infer<T>>;
|
|
22
|
+
onSubmit?: HandleSubmitProps<T>;
|
|
23
|
+
};
|
|
24
|
+
export declare const FormProvider: <T extends z.AnyZodObject>({ children, schema, initialValues, onSubmit }: PropsWithChildren<FormProviderProps<T>>) => React.JSX.Element;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.FormProvider = exports.FormContext = void 0;
|
|
37
|
+
var react_1 = __importStar(require("react"));
|
|
38
|
+
var zod_1 = require("zod");
|
|
39
|
+
exports.FormContext = (0, react_1.createContext)({
|
|
40
|
+
data: null,
|
|
41
|
+
setData: function () { },
|
|
42
|
+
errors: null,
|
|
43
|
+
setErrors: function () { },
|
|
44
|
+
schema: zod_1.z.object({}),
|
|
45
|
+
loading: false,
|
|
46
|
+
setLoading: function () { }
|
|
47
|
+
});
|
|
48
|
+
var FormProvider = function (_a) {
|
|
49
|
+
var children = _a.children, schema = _a.schema, initialValues = _a.initialValues, onSubmit = _a.onSubmit;
|
|
50
|
+
var _b = (0, react_1.useState)(false), loading = _b[0], setLoading = _b[1];
|
|
51
|
+
var _c = (0, react_1.useState)(initialValues || null), data = _c[0], setData = _c[1];
|
|
52
|
+
var _d = (0, react_1.useState)(null), errors = _d[0], setErrors = _d[1];
|
|
53
|
+
return <exports.FormContext.Provider value={{ data: data, setData: setData, errors: errors, setErrors: setErrors, schema: schema, onSubmit: onSubmit, loading: loading, setLoading: setLoading }}>{children}</exports.FormContext.Provider>;
|
|
54
|
+
};
|
|
55
|
+
exports.FormProvider = FormProvider;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { Dispatch, PropsWithChildren, SetStateAction } from 'react';
|
|
2
|
+
import { HeaderT } from '../types/consultation';
|
|
3
|
+
import { RecursivePartial, Theme } from '../types/theme';
|
|
4
|
+
interface ThemeProviderProps {
|
|
5
|
+
theme?: RecursivePartial<Theme>;
|
|
6
|
+
}
|
|
7
|
+
export type ThemeContextProps = ThemeProviderProps & {
|
|
8
|
+
header?: HeaderT;
|
|
9
|
+
setHeader: Dispatch<SetStateAction<HeaderT | null>>;
|
|
10
|
+
};
|
|
11
|
+
export declare const ThemeContext: import("react").Context<ThemeContextProps>;
|
|
12
|
+
export declare const ThemeProvider: ({ children, theme }: PropsWithChildren<ThemeProviderProps>) => import("react").JSX.Element;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ThemeProvider = exports.ThemeContext = void 0;
|
|
4
|
+
var react_1 = require("react");
|
|
5
|
+
var theme_1 = require("../types/theme");
|
|
6
|
+
// eslint-disable-next-line react-refresh/only-export-components
|
|
7
|
+
exports.ThemeContext = (0, react_1.createContext)({
|
|
8
|
+
theme: theme_1.DEFAULT_THEME,
|
|
9
|
+
header: null,
|
|
10
|
+
setHeader: function () { }
|
|
11
|
+
});
|
|
12
|
+
var ThemeProvider = function (_a) {
|
|
13
|
+
var children = _a.children, theme = _a.theme;
|
|
14
|
+
var _b = (0, react_1.useState)(), header = _b[0], setHeader = _b[1];
|
|
15
|
+
var value = { theme: theme, header: header, setHeader: setHeader };
|
|
16
|
+
return <exports.ThemeContext.Provider value={value}>{children}</exports.ThemeContext.Provider>;
|
|
17
|
+
};
|
|
18
|
+
exports.ThemeProvider = ThemeProvider;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { CreateConsultationRequest } from '../api/models/consultation';
|
|
2
|
+
import { ConsultationContextProps } from '../contexts/ConsultationContext';
|
|
3
|
+
import { CASE_TYPE, Consultation } from '../types/consultation';
|
|
4
|
+
interface UseConsultationProps {
|
|
5
|
+
consultation: ConsultationContextProps['consultation'];
|
|
6
|
+
updateConsultation: (_: Consultation) => void;
|
|
7
|
+
start: (caseType: CASE_TYPE, payload: CreateConsultationRequest) => Promise<Consultation>;
|
|
8
|
+
cancel: () => Promise<Consultation>;
|
|
9
|
+
close: () => Promise<Consultation>;
|
|
10
|
+
rate: (_: number) => Promise<Consultation>;
|
|
11
|
+
}
|
|
12
|
+
export declare const useConsultation: () => UseConsultationProps;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
+
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.useConsultation = void 0;
|
|
43
|
+
var react_1 = require("react");
|
|
44
|
+
var consultation_1 = require("../api/consultation");
|
|
45
|
+
var consultation_2 = require("../api/models/consultation");
|
|
46
|
+
var ConsultationContext_1 = require("../contexts/ConsultationContext");
|
|
47
|
+
var i18n_1 = __importDefault(require("../locale/i18n"));
|
|
48
|
+
var useUser_1 = require("./useUser");
|
|
49
|
+
var useConsultation = function () {
|
|
50
|
+
var _a = (0, react_1.useContext)(ConsultationContext_1.ConsultationContext), consultation = _a.consultation, setConsultation = _a.setConsultation, onError = _a.onError;
|
|
51
|
+
var user = (0, useUser_1.useUser)().user;
|
|
52
|
+
var minLength = (0, react_1.useMemo)(function () {
|
|
53
|
+
switch (user === null || user === void 0 ? void 0 : user.language) {
|
|
54
|
+
case 'zh_hk':
|
|
55
|
+
case 'zh_cn':
|
|
56
|
+
case 'zh_sg':
|
|
57
|
+
return 10;
|
|
58
|
+
case 'hu':
|
|
59
|
+
return 40;
|
|
60
|
+
case 'ja':
|
|
61
|
+
return 25;
|
|
62
|
+
default:
|
|
63
|
+
return 50;
|
|
64
|
+
}
|
|
65
|
+
}, [user]);
|
|
66
|
+
var updateConsultation = function (consultation) { return setConsultation(consultation); };
|
|
67
|
+
var handleConsultationAction = function (callback) { return __awaiter(void 0, void 0, void 0, function () {
|
|
68
|
+
var response, e_1;
|
|
69
|
+
return __generator(this, function (_a) {
|
|
70
|
+
switch (_a.label) {
|
|
71
|
+
case 0:
|
|
72
|
+
_a.trys.push([0, 2, , 3]);
|
|
73
|
+
return [4 /*yield*/, callback()];
|
|
74
|
+
case 1:
|
|
75
|
+
response = _a.sent();
|
|
76
|
+
updateConsultation(response.consultation);
|
|
77
|
+
return [2 /*return*/, response.consultation];
|
|
78
|
+
case 2:
|
|
79
|
+
e_1 = _a.sent();
|
|
80
|
+
console.error('Error on consultation action', e_1);
|
|
81
|
+
onError(e_1);
|
|
82
|
+
throw e_1;
|
|
83
|
+
case 3: return [2 /*return*/];
|
|
84
|
+
}
|
|
85
|
+
});
|
|
86
|
+
}); };
|
|
87
|
+
var start = function (caseType, payload) { return __awaiter(void 0, void 0, void 0, function () {
|
|
88
|
+
var parsed;
|
|
89
|
+
return __generator(this, function (_a) {
|
|
90
|
+
console.log('Starting consultation', payload);
|
|
91
|
+
parsed = consultation_2.createConsultationRequestSchema
|
|
92
|
+
.refine(function (value) { return value.question.length >= minLength; }, {
|
|
93
|
+
message: i18n_1.default.t('inputs.textarea.min_length', { minLength: minLength })
|
|
94
|
+
})
|
|
95
|
+
.safeParse(payload);
|
|
96
|
+
if (!parsed.success)
|
|
97
|
+
throw new Error(parsed.error.errors[0].message);
|
|
98
|
+
return [2 /*return*/, handleConsultationAction(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
99
|
+
switch (_a.label) {
|
|
100
|
+
case 0: return [4 /*yield*/, (0, consultation_1.createConsultation)(caseType)(payload)];
|
|
101
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
102
|
+
}
|
|
103
|
+
}); }); })];
|
|
104
|
+
});
|
|
105
|
+
}); };
|
|
106
|
+
var cancel = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
107
|
+
return __generator(this, function (_a) {
|
|
108
|
+
console.log('Cancelling consultation');
|
|
109
|
+
return [2 /*return*/, handleConsultationAction(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
110
|
+
return __generator(this, function (_a) {
|
|
111
|
+
switch (_a.label) {
|
|
112
|
+
case 0: return [4 /*yield*/, (0, consultation_1.cancelConsultation)(consultation.type)({
|
|
113
|
+
consultationId: consultation.id,
|
|
114
|
+
userId: consultation.userId
|
|
115
|
+
})];
|
|
116
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}); })];
|
|
120
|
+
});
|
|
121
|
+
}); };
|
|
122
|
+
var rate = function (rating) { return __awaiter(void 0, void 0, void 0, function () {
|
|
123
|
+
var payload, parsed;
|
|
124
|
+
return __generator(this, function (_a) {
|
|
125
|
+
payload = { consultationId: consultation.id, rating: rating, userId: consultation.userId };
|
|
126
|
+
parsed = consultation_2.rateConsultationRequestSchema.safeParse(payload);
|
|
127
|
+
if (!parsed.success)
|
|
128
|
+
throw new Error(parsed.error.errors[0].message);
|
|
129
|
+
return [2 /*return*/, handleConsultationAction(function () { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
130
|
+
switch (_a.label) {
|
|
131
|
+
case 0: return [4 /*yield*/, (0, consultation_1.rateConsultation)(consultation.type)(payload)];
|
|
132
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
133
|
+
}
|
|
134
|
+
}); }); })];
|
|
135
|
+
});
|
|
136
|
+
}); };
|
|
137
|
+
var close = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
138
|
+
return __generator(this, function (_a) {
|
|
139
|
+
console.log('Closing consultation');
|
|
140
|
+
return [2 /*return*/, handleConsultationAction(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
141
|
+
return __generator(this, function (_a) {
|
|
142
|
+
switch (_a.label) {
|
|
143
|
+
case 0: return [4 /*yield*/, (0, consultation_1.closeConsultation)(consultation.type)({
|
|
144
|
+
consultationId: consultation.id,
|
|
145
|
+
userId: consultation.userId
|
|
146
|
+
})];
|
|
147
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}); })];
|
|
151
|
+
});
|
|
152
|
+
}); };
|
|
153
|
+
(0, react_1.useEffect)(function () {
|
|
154
|
+
// TODO: Remove this console.log for PROD
|
|
155
|
+
console.log('🔁 Consultation updated:', consultation);
|
|
156
|
+
}, [consultation]);
|
|
157
|
+
return {
|
|
158
|
+
consultation: consultation,
|
|
159
|
+
updateConsultation: updateConsultation,
|
|
160
|
+
start: start,
|
|
161
|
+
cancel: cancel,
|
|
162
|
+
close: close,
|
|
163
|
+
rate: rate
|
|
164
|
+
};
|
|
165
|
+
};
|
|
166
|
+
exports.useConsultation = useConsultation;
|