@huma-finance/widgets 0.0.48-beta.283 → 0.0.48-beta.285

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 CHANGED
@@ -5225,36 +5225,19 @@ function LendSupply(_ref) {
5225
5225
  var _templateObject$a, _templateObject2$8, _templateObject3$7;
5226
5226
  function ChooseTranche$1(_ref) {
5227
5227
  let {
5228
- poolInfo,
5229
5228
  poolUnderlyingToken,
5230
5229
  selectedTranche,
5231
5230
  changeTranche
5232
5231
  } = _ref;
5233
5232
  const theme = useTheme();
5234
- const {
5235
- poolName
5236
- } = poolInfo;
5237
5233
  const dispatch = useAppDispatch();
5238
- const {
5239
- account,
5240
- provider
5241
- } = useWeb3React();
5242
- const [lenderApprovedSenior] = useLenderApprovedV2(poolName, 'senior', account, provider);
5243
- const [lenderApprovedJunior] = useLenderApprovedV2(poolName, 'junior', account, provider);
5244
- const isLoading = lenderApprovedSenior === undefined || lenderApprovedJunior === undefined;
5245
5234
  const styles = {
5246
5235
  subTitle: css(_templateObject$a || (_templateObject$a = _taggedTemplateLiteral(["\n color: ", " !important;\n font-family: 'Uni-Neue-Regular';\n font-size: 16px;\n line-height: 150%;\n letter-spacing: 0.15px;\n margin-top: ", ";\n margin-left: ", ";\n "])), theme.palette.text.primary, theme.spacing(5), theme.spacing(2)),
5247
5236
  radioGroup: css(_templateObject2$8 || (_templateObject2$8 = _taggedTemplateLiteral(["\n margin-left: ", ";\n margin-top: ", ";\n "])), theme.spacing(3), theme.spacing(3)),
5248
5237
  formControl: css(_templateObject3$7 || (_templateObject3$7 = _taggedTemplateLiteral(["\n margin-bottom: ", ";\n\n .MuiFormControlLabel-label {\n color: ", ";\n font-family: 'Uni-Neue-Regular';\n font-size: 16px;\n line-height: 150%;\n letter-spacing: 0.15px;\n }\n "])), theme.spacing(1), theme.palette.text.primary)
5249
5238
  };
5250
5239
  const handleNext = () => {
5251
- if (selectedTranche === 'senior' && lenderApprovedSenior || selectedTranche === 'junior' && lenderApprovedJunior) {
5252
- dispatch(setStep(WIDGET_STEP.ChooseAmount));
5253
- } else if (poolInfo.KYC) {
5254
- dispatch(setStep(WIDGET_STEP.Evaluation));
5255
- } else if (poolInfo.supplyLink) {
5256
- openInNewTab(poolInfo.supplyLink);
5257
- }
5240
+ dispatch(setStep(WIDGET_STEP.ChooseAmount));
5258
5241
  };
5259
5242
  const items = [{
5260
5243
  label: 'Senior',
@@ -5263,11 +5246,6 @@ function ChooseTranche$1(_ref) {
5263
5246
  label: 'Junior',
5264
5247
  value: 'junior'
5265
5248
  }];
5266
- if (isLoading) {
5267
- return jsx(LoadingModal, {
5268
- title: "Supply ".concat(poolUnderlyingToken.symbol)
5269
- });
5270
- }
5271
5249
  return jsxs(WrapperModal, {
5272
5250
  title: "Supply ".concat(poolUnderlyingToken.symbol),
5273
5251
  children: [jsxs(FormControl, {
@@ -5755,7 +5733,8 @@ function LendSupplyV2(_ref) {
5755
5733
  const poolName = POOL_NAME[poolNameStr];
5756
5734
  const {
5757
5735
  chainId,
5758
- provider
5736
+ provider,
5737
+ account
5759
5738
  } = useWeb3React();
5760
5739
  const poolInfo = usePoolInfoV2(poolName, chainId);
5761
5740
  const {
@@ -5764,12 +5743,35 @@ function LendSupplyV2(_ref) {
5764
5743
  } = useAppSelector(selectWidgetState);
5765
5744
  const [selectedTranche, setSelectedTranche] = useState();
5766
5745
  const poolUnderlyingToken = usePoolUnderlyingTokenInfoV2(poolName, provider);
5746
+ const [lenderApprovedSenior] = useLenderApprovedV2(poolName, 'senior', account, provider);
5747
+ const [lenderApprovedJunior] = useLenderApprovedV2(poolName, 'junior', account, provider);
5748
+ const lenderApproveStatusFetched = lenderApprovedSenior !== undefined && lenderApprovedJunior !== undefined;
5767
5749
  useEffect(() => {
5768
- if (!step) {
5769
- dispatch(setStep(WIDGET_STEP.ChooseTranche));
5750
+ if (!step && poolInfo && lenderApproveStatusFetched) {
5751
+ if (lenderApprovedJunior && !lenderApprovedSenior) {
5752
+ setSelectedTranche('junior');
5753
+ dispatch(setStep(WIDGET_STEP.ChooseAmount));
5754
+ return;
5755
+ }
5756
+ if (lenderApprovedSenior && !lenderApprovedJunior) {
5757
+ setSelectedTranche('senior');
5758
+ dispatch(setStep(WIDGET_STEP.ChooseAmount));
5759
+ return;
5760
+ }
5761
+ if (lenderApprovedJunior && lenderApprovedSenior) {
5762
+ dispatch(setStep(WIDGET_STEP.ChooseTranche));
5763
+ return;
5764
+ }
5765
+ if (poolInfo.KYC) {
5766
+ dispatch(setStep(WIDGET_STEP.Evaluation));
5767
+ return;
5768
+ }
5769
+ if (poolInfo.supplyLink) {
5770
+ openInNewTab(poolInfo.supplyLink);
5771
+ }
5770
5772
  }
5771
- }, [dispatch, step]);
5772
- if (!poolInfo || !poolUnderlyingToken) {
5773
+ }, [dispatch, lenderApproveStatusFetched, lenderApprovedJunior, lenderApprovedSenior, poolInfo, step]);
5774
+ if (!poolInfo || !poolUnderlyingToken || !lenderApproveStatusFetched) {
5773
5775
  return jsx(WidgetWrapper, {
5774
5776
  isOpen: true,
5775
5777
  isLoading: true,
@@ -5784,7 +5786,6 @@ function LendSupplyV2(_ref) {
5784
5786
  handleClose: handleClose,
5785
5787
  handleSuccess: handleSuccess,
5786
5788
  children: [step === WIDGET_STEP.ChooseTranche && jsx(ChooseTranche$1, {
5787
- poolInfo: poolInfo,
5788
5789
  poolUnderlyingToken: poolUnderlyingToken,
5789
5790
  selectedTranche: selectedTranche,
5790
5791
  changeTranche: setSelectedTranche