• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mendersoftware / gui / 988636826

01 Sep 2023 04:04AM UTC coverage: 82.384% (-17.6%) from 99.964%
988636826

Pull #3969

gitlab-ci

web-flow
chore: Bump autoprefixer from 10.4.14 to 10.4.15

Bumps [autoprefixer](https://github.com/postcss/autoprefixer) from 10.4.14 to 10.4.15.
- [Release notes](https://github.com/postcss/autoprefixer/releases)
- [Changelog](https://github.com/postcss/autoprefixer/blob/main/CHANGELOG.md)
- [Commits](https://github.com/postcss/autoprefixer/compare/10.4.14...10.4.15)

---
updated-dependencies:
- dependency-name: autoprefixer
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #3969: chore: Bump autoprefixer from 10.4.14 to 10.4.15

4346 of 6321 branches covered (0.0%)

8259 of 10025 relevant lines covered (82.38%)

192.73 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

33.33
/src/js/components/settings/cardsection.js
1
// Copyright 2020 Northern.tech AS
2
//
3
//    Licensed under the Apache License, Version 2.0 (the "License");
4
//    you may not use this file except in compliance with the License.
5
//    You may obtain a copy of the License at
6
//
7
//        http://www.apache.org/licenses/LICENSE-2.0
8
//
9
//    Unless required by applicable law or agreed to in writing, software
10
//    distributed under the License is distributed on an "AS IS" BASIS,
11
//    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
//    See the License for the specific language governing permissions and
13
//    limitations under the License.
14
import React, { useState } from 'react';
15

16
import { Button } from '@mui/material';
17

18
import { CardElement, useElements, useStripe } from '@stripe/react-stripe-js';
19

20
import stripeImage from '../../../assets/img/powered_by_stripe.png';
21
import InfoText from '../common/infotext';
22
import Loader from '../common/loader';
23

24
const CardSection = ({ isSignUp, onCancel, onComplete, onSubmit, setSnackbar }) => {
9✔
25
  const stripe = useStripe();
1✔
26
  const elements = useElements();
1✔
27
  const [errors, setErrors] = useState(false);
1✔
28
  const [loading, setLoading] = useState(false);
1✔
29
  const [empty, setEmpty] = useState(true);
1✔
30

31
  const handleSubmit = async event => {
1✔
32
    event.preventDefault();
×
33
    setLoading(true);
×
34
    return onSubmit()
×
35
      .then(confirmCard)
36
      .finally(() => setLoading(false));
×
37
  };
38

39
  const confirmCard = async secret => {
1✔
40
    // Use elements.getElement to get a reference to the mounted Element.
41
    const cardElement = elements.getElement(CardElement);
×
42

43
    // Use your card Element with other Stripe.js APIs
44
    try {
×
45
      const result = await stripe.confirmCardSetup(secret, {
×
46
        payment_method: {
47
          card: cardElement
48
        }
49
      });
50

51
      if (result.error) {
×
52
        setSnackbar(`Error while confirming card: ${result.error.message}`);
×
53
        onCancel();
×
54
      } else {
55
        setSnackbar(`Card confirmed. Updating your account...`);
×
56
        onComplete();
×
57
      }
58
    } catch (err) {
59
      setSnackbar(`Something went wrong while submitting the form. Please contact support.`);
×
60
      onCancel();
×
61
    }
62
  };
63

64
  const stripeElementChange = event => {
1✔
65
    setEmpty(false);
×
66
    if (event.complete) {
×
67
      // enable payment button
68
      setErrors(false);
×
69
    } else if (event.error) {
×
70
      // show validation to customer
71
      setErrors(true);
×
72
    }
73
  };
74

75
  return (
1✔
76
    <form className="margin-top-small" onSubmit={handleSubmit} onReset={onCancel}>
77
      <CardElement className="warning" onChange={event => stripeElementChange(event)} />
×
78
      {!!errors && <p className="warning">There is an error in the form. Please check that your details are correct</p>}
1!
79

80
      <div id="poweredByStripe">
81
        <div>All standard credit card fees apply (e.g. foreign transaction fee, if your card has one)</div>
82
        <img src={stripeImage} />
83
      </div>
84

85
      {isSignUp && <InfoText>Billing will be scheduled monthly, starting from today. You can cancel at any time.</InfoText>}
2✔
86

87
      <div className="flexbox center-aligned margin-top-small" style={{ justifyContent: 'flex-end' }}>
88
        {!isSignUp && (
1!
89
          <Button type="reset" disabled={loading} style={{ marginRight: 15 }}>
90
            Cancel
91
          </Button>
92
        )}
93
        <Button variant="contained" color="secondary" type="submit" disabled={errors || loading || empty}>
3✔
94
          {isSignUp ? 'Sign up' : 'Save'}
1!
95
        </Button>
96
      </div>
97
      <Loader show={loading} />
98
    </form>
99
  );
100
};
101

102
export default CardSection;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc