bam32bittheme
Advanced tools
Comparing version 2.1.76 to 2.1.77
@@ -26,5 +26,8 @@ "use strict"; | ||
var _VerifiedUserRounded = _interopRequireDefault(require("@mui/icons-material/VerifiedUserRounded")); | ||
var _reactCookie = require("react-cookie"); | ||
var _ModalComponent = _interopRequireDefault(require("../components/ModalComponent")); | ||
var _axios = _interopRequireDefault(require("axios")); | ||
var _formik = require("formik"); | ||
var _lab = require("@mui/lab"); | ||
var yup = _interopRequireWildcard(require("yup")); | ||
var _PopUpOkey = _interopRequireDefault(require("../components/PopUpOkey")); | ||
var _ValidateForm = require("./ValidateForm"); | ||
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); } | ||
@@ -52,4 +55,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; } | ||
const [collapseHeight, setCollapseHeight] = (0, _react.useState)(0); | ||
const [open, setOpen] = (0, _react.useState)(false); | ||
const [verifyOpen, setVerifyOpen] = (0, _react.useState)(false); | ||
const [qrCodeData, setQrCodeData] = (0, _react.useState)(null); | ||
const [loading, setLoading] = (0, _react.useState)(false); | ||
const [openMessageVerify, setOpenMessageVerify] = (0, _react.useState)(false); | ||
const [controlVerify, setControlVerify] = (0, _react.useState)(false); | ||
const { | ||
@@ -61,3 +67,2 @@ $t: t | ||
const refUserSection = (0, _react.useRef)(); | ||
const [cookies, setCookie] = (0, _reactCookie.useCookies)(['deviceGuid']); | ||
const isMobile = (0, _material.useMediaQuery)(theme.breakpoints.down('md')); | ||
@@ -127,2 +132,24 @@ const sidebarCollapsed = (0, _react.useMemo)(() => { | ||
(0, _react.useEffect)(() => { | ||
if (localStorage.getItem('token')) { | ||
const url = window.location.origin.includes('localhost') ? 'https://easyflowtest.32bit.com.tr' : window.location.origin; | ||
fetch("".concat(url, "/portal/api/twofa/check2FaForUser?"), { | ||
method: 'GET', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: "Bearer ".concat(localStorage.getItem('token')) | ||
} | ||
}).then(response => { | ||
return response.json(); | ||
}).then(data => { | ||
if (data !== null && data !== void 0 && data.data) { | ||
setControlVerify(true); | ||
} else { | ||
setControlVerify(false); | ||
} | ||
}).catch(error => { | ||
console.error('Error fetching user:', error); | ||
}); | ||
} | ||
}, []); | ||
(0, _react.useEffect)(() => { | ||
if (!refUserSection.current) return; | ||
@@ -148,18 +175,64 @@ const resizeObserver = new ResizeObserver(() => { | ||
}).then(response => { | ||
if (!response.ok) { | ||
throw new Error('Network response was not ok'); | ||
return response.json(); | ||
}).then(data => { | ||
var _data$data; | ||
setQrCodeData(data === null || data === void 0 || (_data$data = data.data) === null || _data$data === void 0 ? void 0 : _data$data.qrCode); | ||
setVerifyOpen(true); | ||
}).catch(error => { | ||
console.error('Error fetching QR code:', error); | ||
setOpenMessageVerify(t({ | ||
id: 'theme.verify.error' | ||
})); | ||
}); | ||
}; | ||
const handleVerifySubmit = async values => { | ||
setLoading(true); | ||
const url = window.location.origin.includes('localhost') ? 'https://easyflowtest.32bit.com.tr' : window.location.origin; | ||
fetch("".concat(url, "/portal/api/twofa/verify?code=").concat(values.verificationCode), { | ||
method: 'POST', | ||
headers: { | ||
'Content-Type': 'application/json', | ||
Authorization: "Bearer ".concat(localStorage.getItem('token')) | ||
} | ||
return response.json(); // JSON formatındaki yanıtı dönüyoruz | ||
}).then(response => { | ||
return response.json(); | ||
}).then(data => { | ||
var _data$data, _data$data2, _data$data3; | ||
setQrCodeData(data === null || data === void 0 || (_data$data = data.data) === null || _data$data === void 0 ? void 0 : _data$data.qrCode); // response.data yerine data kullanıyoruz | ||
setOpen(true); | ||
console.log('deneme1', data === null || data === void 0 ? void 0 : data.data); | ||
console.log('deneme2', data === null || data === void 0 ? void 0 : data.data.data); | ||
console.log('deneme3', data === null || data === void 0 || (_data$data2 = data.data) === null || _data$data2 === void 0 ? void 0 : _data$data2.qrCode); | ||
console.log('deneme4', data === null || data === void 0 || (_data$data3 = data.data) === null || _data$data3 === void 0 || (_data$data3 = _data$data3.data) === null || _data$data3 === void 0 ? void 0 : _data$data3.qrCode); | ||
if ((data === null || data === void 0 ? void 0 : data.status) === 'success') { | ||
setVerifyOpen(false); | ||
setOpenMessageVerify(t({ | ||
id: 'theme.verify.success' | ||
})); | ||
} | ||
}).catch(error => { | ||
console.error('Error fetching QR code:', error); | ||
setOpenMessageVerify(t({ | ||
id: 'theme.verify.error' | ||
})); | ||
}); | ||
setLoading(false); | ||
}; | ||
const verifyValidationSchema = yup.object().shape({ | ||
verificationCode: yup.string().required(t({ | ||
id: 'theme.validation.verificationCode.required' | ||
})) | ||
}); | ||
const formik = (0, _formik.useFormik)({ | ||
initialValues: { | ||
verificationCode: '' | ||
}, | ||
validationSchema: verifyValidationSchema, | ||
onSubmit: handleVerifySubmit | ||
}); | ||
const validationControl = () => { | ||
const validationErrors = (0, _ValidateForm.verifyFormData)(formik.values); | ||
if (Object.values(validationErrors).filter(item => !item).length > 0) { | ||
setOpenMessageVerify(Object.values(formik.errors).map((item, index) => /*#__PURE__*/_react.default.createElement("p", { | ||
key: index | ||
}, item))); | ||
} | ||
}; | ||
const handleSubmit = async () => { | ||
validationControl(); | ||
formik.handleSubmit(); | ||
}; | ||
return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_material.Box, { | ||
@@ -232,5 +305,6 @@ sx: { | ||
"aria-label": t({ | ||
id: 'common.verify' | ||
id: 'theme.verify.iconButton' | ||
}), | ||
color: "error", | ||
color: "success", | ||
disabled: controlVerify, | ||
onClick: () => getQrCode() | ||
@@ -337,6 +411,6 @@ }, /*#__PURE__*/_react.default.createElement(_VerifiedUserRounded.default, null)))), /*#__PURE__*/_react.default.createElement(_material.Typography, { | ||
}, item.label))))), /*#__PURE__*/_react.default.createElement(_ModalComponent.default, { | ||
handleClose: () => setOpen(false), | ||
open: Boolean(open), | ||
handleClose: () => setVerifyOpen(false), | ||
open: Boolean(verifyOpen), | ||
modalText: t({ | ||
id: 'verify.modalText' | ||
id: 'theme.verify.modalText' | ||
}), | ||
@@ -350,3 +424,7 @@ boxProps: { | ||
p: 2 | ||
}, /*#__PURE__*/_react.default.createElement(_material.Stack, null, qrCodeData && /*#__PURE__*/_react.default.createElement(_material.Box, { | ||
}, /*#__PURE__*/_react.default.createElement(_material.Stack, null, /*#__PURE__*/_react.default.createElement(_material.Typography, { | ||
variant: "body2" | ||
}, t({ | ||
id: 'theme.verify.modal.text1' | ||
})), qrCodeData && /*#__PURE__*/_react.default.createElement(_material.Box, { | ||
component: "img", | ||
@@ -356,8 +434,43 @@ src: "".concat(qrCodeData), | ||
sx: { | ||
maxWidth: '100%', | ||
// Görüntüyü ekran genişliğine göre ayarlar | ||
maxWidth: '200px', | ||
height: 'auto', | ||
borderRadius: '8px' // Köşeleri yuvarlar | ||
borderRadius: '8px' | ||
} | ||
})))))), /*#__PURE__*/_react.default.createElement(_material.Backdrop, { | ||
}), /*#__PURE__*/_react.default.createElement(_material.Typography, { | ||
variant: "body2" | ||
}, t({ | ||
id: 'theme.verify.modal.text2' | ||
})), /*#__PURE__*/_react.default.createElement("form", { | ||
onSubmit: handleSubmit | ||
}, /*#__PURE__*/_react.default.createElement(_material.Input, { | ||
label: t({ | ||
id: 'theme.verify.modal.input.verificationCode' | ||
}), | ||
name: "verificationCode", | ||
id: "verificationCode", | ||
required: true, | ||
value: formik.values.verificationCode, | ||
onChange: formik.handleChange('verificationCode'), | ||
onBlur: formik.handleBlur, | ||
error: formik.touched.verificationCode && Boolean(formik.errors.verificationCode) | ||
}), /*#__PURE__*/_react.default.createElement(_lab.LoadingButton, { | ||
variant: "contained", | ||
sx: { | ||
mt: 2 | ||
}, | ||
loading: loading, | ||
type: "submit" | ||
}, t({ | ||
id: 'theme.button.verify' | ||
})))))), /*#__PURE__*/_react.default.createElement(_PopUpOkey.default, { | ||
open: Boolean(openMessageVerify), | ||
text: openMessageVerify, | ||
title: t({ | ||
id: 'common.warning' | ||
}), | ||
buttonText: t({ | ||
id: 'common.okey' | ||
}), | ||
handleOkeyClick: () => setOpenMessageVerify(false) | ||
}))), /*#__PURE__*/_react.default.createElement(_material.Backdrop, { | ||
open: isMobile && showMobileMenu, | ||
@@ -364,0 +477,0 @@ sx: { |
{ | ||
"name": "bam32bittheme", | ||
"version": "2.1.76", | ||
"version": "2.1.77", | ||
"private": false, | ||
@@ -18,3 +18,4 @@ "description": "32bit Theme for Material UI v5.x", | ||
"react-use-websocket": "^4.5.0", | ||
"use-debounce": "^9.0.4" | ||
"use-debounce": "^9.0.4", | ||
"yup": "^1.4.0" | ||
}, | ||
@@ -21,0 +22,0 @@ "devDependencies": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1566739
64
5257
7
21
+ Addedyup@^1.4.0
+ Addedproperty-expr@2.0.6(transitive)
+ Addedtiny-case@1.0.3(transitive)
+ Addedtoposort@2.0.2(transitive)
+ Addedtype-fest@2.19.0(transitive)
+ Addedyup@1.6.1(transitive)