@sanvika/auth 2.10.0 → 2.10.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +219 -46
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -882,11 +882,11 @@ function SanvikaAccountButton(props) {
|
|
|
882
882
|
}
|
|
883
883
|
|
|
884
884
|
// SanvikaAdminLogin.jsx
|
|
885
|
-
import { useState as
|
|
885
|
+
import { useState as useState4, useEffect as useEffect4 } from "react";
|
|
886
886
|
import { useRouter } from "next/navigation";
|
|
887
887
|
|
|
888
888
|
// MobilePolicyPhoneInput.jsx
|
|
889
|
-
import PhoneInput
|
|
889
|
+
import PhoneInput from "react-phone-number-input";
|
|
890
890
|
import flags from "react-phone-number-input/flags";
|
|
891
891
|
import en from "react-phone-number-input/locale/en.json";
|
|
892
892
|
import { parsePhoneNumber } from "libphonenumber-js/min";
|
|
@@ -924,6 +924,12 @@ function isCountryLocked(config) {
|
|
|
924
924
|
const list = countriesForPolicy(config);
|
|
925
925
|
return Array.isArray(list) && list.length === 1;
|
|
926
926
|
}
|
|
927
|
+
function countryOptionsOrderForPolicy(config) {
|
|
928
|
+
const list = countriesForPolicy(config);
|
|
929
|
+
if (Array.isArray(list) && list.length <= 1) return void 0;
|
|
930
|
+
const top = defaultCountryForPolicy(config);
|
|
931
|
+
return top ? [top, "|"] : void 0;
|
|
932
|
+
}
|
|
927
933
|
function toPhoneInputValue(raw, config) {
|
|
928
934
|
if (!raw) return void 0;
|
|
929
935
|
const s = String(raw).trim();
|
|
@@ -934,14 +940,179 @@ function toPhoneInputValue(raw, config) {
|
|
|
934
940
|
return `+${digits}`;
|
|
935
941
|
}
|
|
936
942
|
|
|
943
|
+
// PolicySearchableCountrySelect.jsx
|
|
944
|
+
import { useEffect as useEffect3, useMemo as useMemo2, useRef as useRef2, useState as useState3 } from "react";
|
|
945
|
+
import { getCountryCallingCode } from "react-phone-number-input";
|
|
946
|
+
|
|
947
|
+
// unicodeCountryFlag.js
|
|
948
|
+
function unicodeCountryFlag(countryCode) {
|
|
949
|
+
if (!countryCode || countryCode === "ZZ" || countryCode.length !== 2) return "";
|
|
950
|
+
const upper = countryCode.toUpperCase();
|
|
951
|
+
if (!/^[A-Z]{2}$/.test(upper)) return "";
|
|
952
|
+
return String.fromCodePoint(
|
|
953
|
+
...[...upper].map((char) => 127397 + char.charCodeAt(0))
|
|
954
|
+
);
|
|
955
|
+
}
|
|
956
|
+
|
|
957
|
+
// PolicySearchableCountrySelect.jsx
|
|
958
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
959
|
+
function dialCodeFor(country) {
|
|
960
|
+
if (!country) return "";
|
|
961
|
+
try {
|
|
962
|
+
return `+${getCountryCallingCode(country)}`;
|
|
963
|
+
} catch {
|
|
964
|
+
return "";
|
|
965
|
+
}
|
|
966
|
+
}
|
|
967
|
+
function countryWords(label) {
|
|
968
|
+
return String(label || "").toLowerCase().split(/[\s,().-]+/).filter(Boolean);
|
|
969
|
+
}
|
|
970
|
+
function matchScore(label, q, code, dialDigits, qDigits) {
|
|
971
|
+
const normalized = String(label || "").toLowerCase();
|
|
972
|
+
if (normalized.startsWith(q)) return 0;
|
|
973
|
+
if (countryWords(label).some((word) => word.startsWith(q))) return 1;
|
|
974
|
+
if (code.startsWith(q)) return 2;
|
|
975
|
+
if (qDigits && dialDigits.startsWith(qDigits)) return 3;
|
|
976
|
+
return -1;
|
|
977
|
+
}
|
|
978
|
+
function PolicySearchableCountrySelect({
|
|
979
|
+
value,
|
|
980
|
+
onChange,
|
|
981
|
+
options,
|
|
982
|
+
disabled,
|
|
983
|
+
readOnly
|
|
984
|
+
}) {
|
|
985
|
+
const [open, setOpen] = useState3(false);
|
|
986
|
+
const [query, setQuery] = useState3("");
|
|
987
|
+
const rootRef = useRef2(null);
|
|
988
|
+
const searchRef = useRef2(null);
|
|
989
|
+
const selectable = useMemo2(
|
|
990
|
+
() => options.filter((o) => !o.divider && o.value),
|
|
991
|
+
[options]
|
|
992
|
+
);
|
|
993
|
+
const filtered = useMemo2(() => {
|
|
994
|
+
const q = query.trim().toLowerCase();
|
|
995
|
+
if (!q) return selectable;
|
|
996
|
+
const qDigits = q.replace(/\D/g, "");
|
|
997
|
+
return selectable.map((o) => ({
|
|
998
|
+
option: o,
|
|
999
|
+
score: matchScore(
|
|
1000
|
+
o.label,
|
|
1001
|
+
q,
|
|
1002
|
+
(o.value || "").toLowerCase(),
|
|
1003
|
+
dialCodeFor(o.value).replace(/\D/g, ""),
|
|
1004
|
+
qDigits
|
|
1005
|
+
)
|
|
1006
|
+
})).filter((row) => row.score >= 0).sort((a, b) => a.score - b.score || a.option.label.localeCompare(b.option.label)).map((row) => row.option);
|
|
1007
|
+
}, [query, selectable]);
|
|
1008
|
+
useEffect3(() => {
|
|
1009
|
+
if (!open) return void 0;
|
|
1010
|
+
const onDoc = (event) => {
|
|
1011
|
+
if (rootRef.current && !rootRef.current.contains(event.target)) {
|
|
1012
|
+
setOpen(false);
|
|
1013
|
+
}
|
|
1014
|
+
};
|
|
1015
|
+
document.addEventListener("click", onDoc);
|
|
1016
|
+
return () => document.removeEventListener("click", onDoc);
|
|
1017
|
+
}, [open]);
|
|
1018
|
+
useEffect3(() => {
|
|
1019
|
+
if (!open) return;
|
|
1020
|
+
setQuery("");
|
|
1021
|
+
requestAnimationFrame(() => {
|
|
1022
|
+
var _a;
|
|
1023
|
+
return (_a = searchRef.current) == null ? void 0 : _a.focus();
|
|
1024
|
+
});
|
|
1025
|
+
}, [open]);
|
|
1026
|
+
const locked = disabled || readOnly;
|
|
1027
|
+
const flag = value ? unicodeCountryFlag(value) : "\u{1F310}";
|
|
1028
|
+
const dial = dialCodeFor(value);
|
|
1029
|
+
const pick = (code) => {
|
|
1030
|
+
if (!code || code === value) {
|
|
1031
|
+
setOpen(false);
|
|
1032
|
+
setQuery("");
|
|
1033
|
+
return;
|
|
1034
|
+
}
|
|
1035
|
+
onChange(code);
|
|
1036
|
+
setOpen(false);
|
|
1037
|
+
setQuery("");
|
|
1038
|
+
};
|
|
1039
|
+
return /* @__PURE__ */ jsx3("div", { className: "PhoneInputCountry", children: /* @__PURE__ */ jsxs2("div", { className: "sa-country-picker", ref: rootRef, children: [
|
|
1040
|
+
/* @__PURE__ */ jsxs2(
|
|
1041
|
+
"button",
|
|
1042
|
+
{
|
|
1043
|
+
type: "button",
|
|
1044
|
+
className: "sa-country-picker__trigger",
|
|
1045
|
+
disabled: locked,
|
|
1046
|
+
"aria-expanded": open,
|
|
1047
|
+
"aria-haspopup": "listbox",
|
|
1048
|
+
"aria-label": value ? `Country ${value}` : "Select country",
|
|
1049
|
+
onClick: (event) => {
|
|
1050
|
+
event.stopPropagation();
|
|
1051
|
+
if (!locked) setOpen((v) => !v);
|
|
1052
|
+
},
|
|
1053
|
+
children: [
|
|
1054
|
+
/* @__PURE__ */ jsx3("span", { className: "sa-country-picker__flag", "aria-hidden": "true", children: flag }),
|
|
1055
|
+
dial ? /* @__PURE__ */ jsx3("span", { className: "sa-country-picker__dial", children: dial }) : null,
|
|
1056
|
+
!locked ? /* @__PURE__ */ jsx3("span", { className: "sa-country-picker__chev", "aria-hidden": "true", children: "\u25BE" }) : null
|
|
1057
|
+
]
|
|
1058
|
+
}
|
|
1059
|
+
),
|
|
1060
|
+
open && !locked ? /* @__PURE__ */ jsxs2(
|
|
1061
|
+
"div",
|
|
1062
|
+
{
|
|
1063
|
+
className: "sa-country-picker__panel",
|
|
1064
|
+
role: "listbox",
|
|
1065
|
+
onMouseDown: (event) => event.stopPropagation(),
|
|
1066
|
+
children: [
|
|
1067
|
+
/* @__PURE__ */ jsx3(
|
|
1068
|
+
"input",
|
|
1069
|
+
{
|
|
1070
|
+
ref: searchRef,
|
|
1071
|
+
type: "search",
|
|
1072
|
+
className: "sa-country-picker__search",
|
|
1073
|
+
placeholder: "Search country",
|
|
1074
|
+
value: query,
|
|
1075
|
+
onChange: (e) => setQuery(e.target.value),
|
|
1076
|
+
"aria-label": "Search country",
|
|
1077
|
+
autoComplete: "off"
|
|
1078
|
+
}
|
|
1079
|
+
),
|
|
1080
|
+
/* @__PURE__ */ jsxs2("ul", { className: "sa-country-picker__list", children: [
|
|
1081
|
+
filtered.map((o) => /* @__PURE__ */ jsx3("li", { children: /* @__PURE__ */ jsxs2(
|
|
1082
|
+
"button",
|
|
1083
|
+
{
|
|
1084
|
+
type: "button",
|
|
1085
|
+
role: "option",
|
|
1086
|
+
"aria-selected": o.value === value,
|
|
1087
|
+
className: `sa-country-picker__option${o.value === value ? " sa-country-picker__option--active" : ""}`,
|
|
1088
|
+
onMouseDown: (event) => {
|
|
1089
|
+
event.preventDefault();
|
|
1090
|
+
event.stopPropagation();
|
|
1091
|
+
pick(o.value);
|
|
1092
|
+
},
|
|
1093
|
+
children: [
|
|
1094
|
+
/* @__PURE__ */ jsx3("span", { className: "sa-country-picker__option-flag", "aria-hidden": "true", children: unicodeCountryFlag(o.value) }),
|
|
1095
|
+
/* @__PURE__ */ jsx3("span", { className: "sa-country-picker__name", children: o.label }),
|
|
1096
|
+
/* @__PURE__ */ jsx3("span", { className: "sa-country-picker__code", children: dialCodeFor(o.value) })
|
|
1097
|
+
]
|
|
1098
|
+
}
|
|
1099
|
+
) }, o.value)),
|
|
1100
|
+
!filtered.length ? /* @__PURE__ */ jsx3("li", { className: "sa-country-picker__empty", children: "No matches" }) : null
|
|
1101
|
+
] })
|
|
1102
|
+
]
|
|
1103
|
+
}
|
|
1104
|
+
) : null
|
|
1105
|
+
] }) });
|
|
1106
|
+
}
|
|
1107
|
+
|
|
937
1108
|
// MobilePolicyPhoneInput.jsx
|
|
938
1109
|
import "react-phone-number-input/style.css";
|
|
939
1110
|
|
|
940
1111
|
// MobilePolicyPhoneInput.css
|
|
941
|
-
styleInject(".sa-phone-field {\n margin-bottom: 16px;\n}\n.sa-phone-input {\n display: block;\n}\n.sa-phone-input .PhoneInput {\n display: flex;\n align-items: stretch;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid #dddddd;\n background: #ffffff;\n}\n.sa-phone-input--dark .PhoneInput {\n border-color: #333333;\n background: #222222;\n}\n.sa-phone-input .PhoneInputCountry {\n align-self: stretch;\n display: flex;\n align-items: center;\n
|
|
1112
|
+
styleInject(".sa-phone-field {\n margin-bottom: 16px;\n}\n.sa-phone-input {\n display: block;\n}\n.sa-phone-input .PhoneInput {\n display: flex;\n align-items: stretch;\n border-radius: 8px;\n overflow: hidden;\n border: 1px solid #dddddd;\n background: #ffffff;\n}\n.sa-phone-input--searchable-country .PhoneInput {\n overflow: visible;\n}\n.sa-phone-input--dark .PhoneInput {\n border-color: #333333;\n background: #222222;\n}\n.sa-phone-input .PhoneInputCountry {\n position: relative;\n flex: 0 0 auto;\n align-self: stretch;\n display: flex;\n align-items: center;\n justify-content: center;\n margin: 0;\n min-width: 5.25rem;\n max-width: 6.75rem;\n border-right: 1px solid #dddddd;\n background: #f5f5f5;\n}\n.sa-phone-input--dark .PhoneInputCountry {\n border-right-color: #333333;\n background: #2a2a2a;\n}\n.sa-phone-input--searchable-country .PhoneInputCountryIcon,\n.sa-phone-input--searchable-country .PhoneInputCountryIconUnicode,\n.sa-phone-input--searchable-country .PhoneInputCountrySelectArrow {\n display: none !important;\n}\n.sa-phone-input .PhoneInputInput {\n flex: 1 1 auto;\n min-width: 0;\n width: 100%;\n border: none;\n outline: none;\n padding: 10px 12px;\n font-size: 15px;\n background: transparent;\n color: #222222;\n}\n.sa-phone-input--dark .PhoneInputInput {\n color: #ffffff;\n}\n.sa-phone-input .PhoneInputInput::placeholder {\n color: #999999;\n}\n.sa-phone-input--dark .PhoneInputInput::placeholder {\n color: #666666;\n}\n.sa-country-picker {\n position: relative;\n width: 100%;\n height: 100%;\n min-height: 42px;\n}\n.sa-country-picker__trigger {\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 4px;\n width: 100%;\n height: 100%;\n min-height: 42px;\n padding: 0 8px;\n margin: 0;\n border: none;\n background: transparent;\n cursor: pointer;\n color: inherit;\n font: inherit;\n}\n.sa-country-picker__trigger:disabled {\n cursor: default;\n opacity: 0.65;\n}\n.sa-country-picker__flag {\n font-size: 1.15rem;\n line-height: 1;\n flex-shrink: 0;\n}\n.sa-country-picker__dial {\n font-size: 13px;\n font-weight: 600;\n white-space: nowrap;\n flex-shrink: 0;\n}\n.sa-country-picker__chev {\n font-size: 10px;\n opacity: 0.7;\n flex-shrink: 0;\n margin-left: 1px;\n}\n.sa-country-picker__panel {\n position: absolute;\n top: calc(100% + 4px);\n left: 0;\n z-index: 50;\n width: min(20rem, calc(100vw - 2rem));\n max-height: min(20rem, 55vh);\n display: flex;\n flex-direction: column;\n border-radius: 10px;\n border: 1px solid #dddddd;\n background: #ffffff;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);\n overflow: hidden;\n}\n.sa-phone-input--dark .sa-country-picker__panel {\n border-color: #444444;\n background: #1e1e1e;\n box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);\n}\n.sa-country-picker__search {\n flex-shrink: 0;\n width: 100%;\n padding: 10px 12px;\n border: none;\n border-bottom: 1px solid #eeeeee;\n outline: none;\n font-size: 14px;\n background: #fafafa;\n color: #222222;\n}\n.sa-phone-input--dark .sa-country-picker__search {\n border-bottom-color: #333333;\n background: #252525;\n color: #ffffff;\n}\n.sa-country-picker__list {\n list-style: none;\n margin: 0;\n padding: 4px 0;\n overflow-y: auto;\n flex: 1;\n min-height: 0;\n}\n.sa-country-picker__option {\n display: flex;\n align-items: center;\n gap: 8px;\n width: 100%;\n padding: 8px 12px;\n border: none;\n background: transparent;\n cursor: pointer;\n text-align: left;\n font-size: 14px;\n color: #222222;\n}\n.sa-phone-input--dark .sa-country-picker__option {\n color: #eeeeee;\n}\n.sa-country-picker__option:hover,\n.sa-country-picker__option--active {\n background: #f0f4ff;\n}\n.sa-phone-input--dark .sa-country-picker__option:hover,\n.sa-phone-input--dark .sa-country-picker__option--active {\n background: #2a3344;\n}\n.sa-country-picker__option-flag {\n font-size: 1.1rem;\n line-height: 1;\n flex-shrink: 0;\n}\n.sa-country-picker__name {\n flex: 1;\n min-width: 0;\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n}\n.sa-country-picker__code {\n flex-shrink: 0;\n font-size: 12px;\n font-weight: 600;\n color: #666666;\n}\n.sa-phone-input--dark .sa-country-picker__code {\n color: #999999;\n}\n.sa-country-picker__empty {\n padding: 12px;\n font-size: 13px;\n color: #888888;\n text-align: center;\n}\n.sa-phone-preview {\n display: flex;\n flex-wrap: wrap;\n align-items: center;\n gap: 6px 10px;\n margin-top: 8px;\n padding: 8px 10px;\n border-radius: 6px;\n font-size: 12px;\n background: #f0f7ff;\n border: 1px solid #cce4ff;\n}\n.sa-phone-preview--dark {\n background: #1a2433;\n border-color: #2a3f5f;\n}\n.sa-phone-preview__label {\n font-weight: 600;\n color: #555555;\n text-transform: uppercase;\n letter-spacing: 0.04em;\n font-size: 10px;\n}\n.sa-phone-preview--dark .sa-phone-preview__label {\n color: #8899aa;\n}\n.sa-phone-preview__value {\n color: #0984e3;\n font-weight: 500;\n}\n.sa-phone-preview--dark .sa-phone-preview__value {\n color: #88c5ff;\n}\n.sa-phone-preview__e164 {\n font-family:\n ui-monospace,\n SFMono-Regular,\n Menlo,\n monospace;\n color: #333333;\n background: rgba(0, 0, 0, 0.05);\n padding: 2px 6px;\n border-radius: 4px;\n}\n.sa-phone-preview--dark .sa-phone-preview__e164 {\n color: #cccccc;\n background: rgba(255, 255, 255, 0.06);\n}\n");
|
|
942
1113
|
|
|
943
1114
|
// MobilePolicyPhoneInput.jsx
|
|
944
|
-
import {
|
|
1115
|
+
import { jsx as jsx4, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
945
1116
|
function MobilePolicyPhoneInput({
|
|
946
1117
|
config,
|
|
947
1118
|
value,
|
|
@@ -949,53 +1120,58 @@ function MobilePolicyPhoneInput({
|
|
|
949
1120
|
theme = "dark",
|
|
950
1121
|
inputRef,
|
|
951
1122
|
id = "mobile-phone-input",
|
|
952
|
-
placeholder = "Enter phone number"
|
|
1123
|
+
placeholder = "Enter phone number",
|
|
1124
|
+
showPreview = true
|
|
953
1125
|
}) {
|
|
954
1126
|
const policy = mergeMobilePolicy(config);
|
|
955
1127
|
const countries = countriesForPolicy(config);
|
|
956
1128
|
const defaultCountry = defaultCountryForPolicy(config);
|
|
957
1129
|
const countryLocked = isCountryLocked(config);
|
|
958
|
-
|
|
959
|
-
let
|
|
1130
|
+
const countryOrder = countryOptionsOrderForPolicy(config);
|
|
1131
|
+
let e164Display = "";
|
|
960
1132
|
if (value) {
|
|
961
1133
|
try {
|
|
962
|
-
intlFormatted = formatPhoneNumberIntl(value) || value;
|
|
963
1134
|
const parsed = parsePhoneNumber(value);
|
|
964
1135
|
if (parsed == null ? void 0 : parsed.isValid()) {
|
|
965
|
-
|
|
1136
|
+
e164Display = parsed.number;
|
|
966
1137
|
} else {
|
|
967
|
-
|
|
1138
|
+
const digits = normalizeMobileWithPolicy(value, policy) || String(value).replace(/\D/g, "");
|
|
1139
|
+
e164Display = digits ? `+${digits}` : "";
|
|
968
1140
|
}
|
|
969
1141
|
} catch {
|
|
970
|
-
|
|
1142
|
+
e164Display = "";
|
|
971
1143
|
}
|
|
972
1144
|
}
|
|
973
|
-
return /* @__PURE__ */
|
|
974
|
-
/* @__PURE__ */
|
|
1145
|
+
return /* @__PURE__ */ jsxs3("div", { className: "sa-phone-field", children: [
|
|
1146
|
+
/* @__PURE__ */ jsx4(
|
|
975
1147
|
"div",
|
|
976
1148
|
{
|
|
977
|
-
className: `sa-phone-input sa-phone-input--${theme}`,
|
|
1149
|
+
className: `sa-phone-input sa-phone-input--${theme} sa-phone-input--searchable-country`,
|
|
978
1150
|
"data-theme": theme,
|
|
979
|
-
children: /* @__PURE__ */
|
|
1151
|
+
children: /* @__PURE__ */ jsx4(
|
|
980
1152
|
PhoneInput,
|
|
981
1153
|
{
|
|
982
1154
|
id,
|
|
983
|
-
international:
|
|
1155
|
+
international: false,
|
|
984
1156
|
countryCallingCodeEditable: false,
|
|
985
1157
|
defaultCountry,
|
|
986
1158
|
countries,
|
|
1159
|
+
countryOptionsOrder: countryOrder,
|
|
1160
|
+
addInternationalOption: false,
|
|
1161
|
+
countrySelectComponent: PolicySearchableCountrySelect,
|
|
987
1162
|
flags,
|
|
988
1163
|
labels: en,
|
|
989
1164
|
value,
|
|
990
1165
|
onChange,
|
|
991
1166
|
placeholder,
|
|
992
1167
|
smartCaret: true,
|
|
1168
|
+
inputRef,
|
|
1169
|
+
focusInputOnCountrySelection: Boolean(inputRef),
|
|
993
1170
|
countrySelectProps: {
|
|
994
1171
|
unicodeFlags: true,
|
|
995
1172
|
...countryLocked ? { disabled: true } : {}
|
|
996
1173
|
},
|
|
997
1174
|
numberInputProps: {
|
|
998
|
-
ref: inputRef,
|
|
999
1175
|
autoComplete: "tel",
|
|
1000
1176
|
inputMode: "tel",
|
|
1001
1177
|
"aria-label": "Phone number"
|
|
@@ -1004,14 +1180,10 @@ function MobilePolicyPhoneInput({
|
|
|
1004
1180
|
)
|
|
1005
1181
|
}
|
|
1006
1182
|
),
|
|
1007
|
-
value && /* @__PURE__ */
|
|
1008
|
-
/* @__PURE__ */
|
|
1009
|
-
/* @__PURE__ */
|
|
1010
|
-
|
|
1011
|
-
/* @__PURE__ */ jsx3("span", { className: "sa-phone-preview__label", children: "E.164" }),
|
|
1012
|
-
/* @__PURE__ */ jsx3("span", { className: "sa-phone-preview__e164", children: e164Digits })
|
|
1013
|
-
] }) : null
|
|
1014
|
-
] })
|
|
1183
|
+
showPreview && value && e164Display ? /* @__PURE__ */ jsxs3("div", { className: `sa-phone-preview sa-phone-preview--${theme}`, children: [
|
|
1184
|
+
/* @__PURE__ */ jsx4("span", { className: "sa-phone-preview__label", children: "E.164" }),
|
|
1185
|
+
/* @__PURE__ */ jsx4("span", { className: "sa-phone-preview__e164", children: e164Display })
|
|
1186
|
+
] }) : null
|
|
1015
1187
|
] });
|
|
1016
1188
|
}
|
|
1017
1189
|
|
|
@@ -1071,7 +1243,7 @@ function mobilePlaceholder(config) {
|
|
|
1071
1243
|
}
|
|
1072
1244
|
|
|
1073
1245
|
// SanvikaAdminLogin.jsx
|
|
1074
|
-
import { jsx as
|
|
1246
|
+
import { jsx as jsx5, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
1075
1247
|
var DEVICE_ID_KEY = "sanvika_admin_device_id";
|
|
1076
1248
|
var ADMIN_MOBILE_POLICY = CLIENT_MOBILE_POLICIES.IN_10;
|
|
1077
1249
|
function getDeviceId() {
|
|
@@ -1116,12 +1288,12 @@ function SanvikaAdminLogin({
|
|
|
1116
1288
|
}) {
|
|
1117
1289
|
const router = useRouter();
|
|
1118
1290
|
const { isAuthenticated, loading, user, setAuth, clientId } = useSanvikaAuth();
|
|
1119
|
-
const [phoneValue, setPhoneValue] =
|
|
1120
|
-
const [password, setPassword] =
|
|
1121
|
-
const [error, setError] =
|
|
1122
|
-
const [submitting, setSubmitting] =
|
|
1123
|
-
const [ready, setReady] =
|
|
1124
|
-
|
|
1291
|
+
const [phoneValue, setPhoneValue] = useState4(void 0);
|
|
1292
|
+
const [password, setPassword] = useState4("");
|
|
1293
|
+
const [error, setError] = useState4("");
|
|
1294
|
+
const [submitting, setSubmitting] = useState4(false);
|
|
1295
|
+
const [ready, setReady] = useState4(false);
|
|
1296
|
+
useEffect4(() => {
|
|
1125
1297
|
if (loading) return;
|
|
1126
1298
|
if (isAuthenticated && (user == null ? void 0 : user.role) === "superadmin") {
|
|
1127
1299
|
router.replace(dashboardPath);
|
|
@@ -1242,10 +1414,10 @@ function SanvikaAdminLogin({
|
|
|
1242
1414
|
}
|
|
1243
1415
|
};
|
|
1244
1416
|
if (loading || !ready) {
|
|
1245
|
-
return /* @__PURE__ */
|
|
1417
|
+
return /* @__PURE__ */ jsx5("div", { style: S.page, children: /* @__PURE__ */ jsx5("div", { style: S.card, children: /* @__PURE__ */ jsx5("p", { style: S.subtitle, children: "Loading\u2026" }) }) });
|
|
1246
1418
|
}
|
|
1247
|
-
return /* @__PURE__ */
|
|
1248
|
-
/* @__PURE__ */
|
|
1419
|
+
return /* @__PURE__ */ jsx5("div", { style: S.page, children: /* @__PURE__ */ jsxs4("div", { style: S.card, children: [
|
|
1420
|
+
/* @__PURE__ */ jsx5(
|
|
1249
1421
|
"button",
|
|
1250
1422
|
{
|
|
1251
1423
|
style: S.closeBtn,
|
|
@@ -1254,15 +1426,15 @@ function SanvikaAdminLogin({
|
|
|
1254
1426
|
children: "\u2715"
|
|
1255
1427
|
}
|
|
1256
1428
|
),
|
|
1257
|
-
/* @__PURE__ */
|
|
1258
|
-
/* @__PURE__ */
|
|
1429
|
+
/* @__PURE__ */ jsx5("div", { style: S.logo, children: "\u{1F6E1}\uFE0F" }),
|
|
1430
|
+
/* @__PURE__ */ jsxs4("h1", { style: S.title, children: [
|
|
1259
1431
|
serviceName,
|
|
1260
1432
|
" Admin"
|
|
1261
1433
|
] }),
|
|
1262
|
-
/* @__PURE__ */
|
|
1263
|
-
/* @__PURE__ */
|
|
1264
|
-
/* @__PURE__ */
|
|
1265
|
-
/* @__PURE__ */
|
|
1434
|
+
/* @__PURE__ */ jsx5("p", { style: S.subtitle, children: "SuperAdmin access \u2014 Sanvika Accounts SSO" }),
|
|
1435
|
+
/* @__PURE__ */ jsxs4("form", { onSubmit: handleLogin, style: S.form, autoComplete: "off", children: [
|
|
1436
|
+
/* @__PURE__ */ jsx5("label", { style: S.label, htmlFor: "admin-mobile-phone", children: "Mobile Number" }),
|
|
1437
|
+
/* @__PURE__ */ jsx5(
|
|
1266
1438
|
MobilePolicyPhoneInput,
|
|
1267
1439
|
{
|
|
1268
1440
|
config: ADMIN_MOBILE_POLICY,
|
|
@@ -1270,11 +1442,12 @@ function SanvikaAdminLogin({
|
|
|
1270
1442
|
onChange: setPhoneValue,
|
|
1271
1443
|
theme: "dark",
|
|
1272
1444
|
id: "admin-mobile-phone",
|
|
1273
|
-
placeholder: "Enter phone number"
|
|
1445
|
+
placeholder: "Enter phone number",
|
|
1446
|
+
showPreview: false
|
|
1274
1447
|
}
|
|
1275
1448
|
),
|
|
1276
|
-
/* @__PURE__ */
|
|
1277
|
-
/* @__PURE__ */
|
|
1449
|
+
/* @__PURE__ */ jsx5("label", { style: S.label, children: "Password" }),
|
|
1450
|
+
/* @__PURE__ */ jsx5(
|
|
1278
1451
|
"input",
|
|
1279
1452
|
{
|
|
1280
1453
|
type: "password",
|
|
@@ -1286,7 +1459,7 @@ function SanvikaAdminLogin({
|
|
|
1286
1459
|
autoComplete: "new-password"
|
|
1287
1460
|
}
|
|
1288
1461
|
),
|
|
1289
|
-
/* @__PURE__ */
|
|
1462
|
+
/* @__PURE__ */ jsx5(
|
|
1290
1463
|
"button",
|
|
1291
1464
|
{
|
|
1292
1465
|
type: "submit",
|
|
@@ -1296,7 +1469,7 @@ function SanvikaAdminLogin({
|
|
|
1296
1469
|
}
|
|
1297
1470
|
)
|
|
1298
1471
|
] }),
|
|
1299
|
-
error && /* @__PURE__ */
|
|
1472
|
+
error && /* @__PURE__ */ jsx5("p", { style: S.error, children: error })
|
|
1300
1473
|
] }) });
|
|
1301
1474
|
}
|
|
1302
1475
|
var ADMIN_LOGIN_API_URL = authApiUrl(AUTH_API.LOGIN, DEFAULT_AUTH_URL);
|