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

mendersoftware / mender-server / 1590815032

16 Dec 2024 01:53PM UTC coverage: 73.522% (+0.7%) from 72.839%
1590815032

Pull #253

gitlab-ci

mineralsfree
feat: updated billing section in My Organization settings

Ticket: MEN-7466
Changelog: None

Signed-off-by: Mikita Pilinka <mikita.pilinka@northern.tech>
Pull Request #253: MEN-7466-feat: updated billing section in My Organization settings

4257 of 6186 branches covered (68.82%)

Branch coverage included in aggregate %.

57 of 89 new or added lines in 11 files covered. (64.04%)

1 existing line in 1 file now uncovered.

40090 of 54132 relevant lines covered (74.06%)

22.98 hits per line

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

43.48
/frontend/src/js/components/settings/organization/OrganizationPaymentSettings.tsx
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 { useSelector } from 'react-redux';
15

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

19
import { getCard, getOrganization } from '@northern.tech/store/selectors';
20
import { useAppDispatch } from '@northern.tech/store/store';
21
import { confirmCardUpdate, getCurrentCard, startCardUpdate } from '@northern.tech/store/thunks';
22

23
import CardSection from '../CardSection';
24
import { CardDetails } from './Billing';
25

26
interface OrganizationPaymentSettingsProps {
27
  onComplete?: () => void;
28
  isValid: boolean;
29
  updatingCard: boolean;
30
  setUpdatingCard: (updatingCard: boolean) => void;
31
}
32
export const OrganizationPaymentSettings = (props: OrganizationPaymentSettingsProps) => {
8✔
33
  const { onComplete, isValid, updatingCard, setUpdatingCard } = props;
1✔
34
  const card = useSelector(getCard);
1✔
35
  const organization = useSelector(getOrganization);
1✔
36
  const dispatch = useAppDispatch();
1✔
37

38
  const onCardConfirm = async () => {
1✔
NEW
39
    await dispatch(confirmCardUpdate());
×
NEW
40
    dispatch(getCurrentCard());
×
NEW
41
    setUpdatingCard(false);
×
NEW
42
    if (onComplete) {
×
NEW
43
      onComplete();
×
44
    }
45
  };
46

47
  return (
1✔
48
    <div className="flexbox margin-top">
49
      <div className="margin-top" />
50
      <div className="flexbox column">
51
        <div className="flexbox">
52
          <h5 className="margin-top-small margin-bottom-x-small margin-right-x-small">{updatingCard ? 'Edit payment card' : 'Payment card'}</h5>
1!
NEW
53
          <Button className="align-self-start" onClick={() => setUpdatingCard(!updatingCard)}>
×
54
            {updatingCard ? 'cancel' : 'edit'}
1!
55
          </Button>
56
        </div>
57
        {updatingCard ? (
1!
58
          <CardSection
59
            isSignUp={false}
60
            organization={organization}
NEW
61
            onClose={() => setUpdatingCard(false)}
×
62
            onCardConfirmed={onCardConfirm}
63
            isValid={isValid}
NEW
64
            beforeCardSubmit={() => dispatch(startCardUpdate()).unwrap()}
×
65
          />
66
        ) : (
67
          <CardDetails card={card} />
68
        )}
69
      </div>
70
    </div>
71
  );
72
};
73

74
export default OrganizationPaymentSettings;
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