@stigg/react-sdk 4.4.0-beta.6 → 4.4.0-beta.8

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/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "4.4.0-beta.6",
2
+ "version": "4.4.0-beta.8",
3
3
  "license": "MIT",
4
4
  "main": "dist/index.js",
5
5
  "typings": "dist/index.d.ts",
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
2
 
3
3
  import styled from '@emotion/styled/macro';
4
- import { Button as MuiButton, ButtonProps, css } from '@mui/material';
4
+ import { Button as MuiButton, ButtonProps } from '@mui/material';
5
5
 
6
6
  export type StyledButtonProps = { $success?: boolean; $error?: boolean };
7
7
 
@@ -9,30 +9,25 @@ const StyledButton = styled(MuiButton, { shouldForwardProp: (prop) => !prop.star
9
9
  border-radius: 10px;
10
10
  text-transform: none;
11
11
 
12
- ${({ theme, $success, $error }) => {
12
+ background-color: ${({ theme, $success, $error }) => {
13
13
  if ($success) {
14
- return css`
15
- background-color: ${theme.stigg.palette.success};
16
- cursor: 'default';
17
-
18
- &:hover {
19
- background-color: ${theme.stigg.palette.successDark};
20
- }
21
- `;
14
+ return theme.stigg.palette.success;
15
+ } else if ($error) {
16
+ return theme.stigg.palette.error;
22
17
  }
23
-
24
- if ($error) {
25
- return css`
26
- background-color: ${theme.stigg.palette.error};
27
-
28
- &:hover {
29
- background-color: ${theme.stigg.palette.errorDark};
30
- }
31
- `;
32
- }
33
-
34
18
  return '';
35
- }}
19
+ }};
20
+
21
+ &:hover {
22
+ background-color: ${({ theme, $success, $error }) => {
23
+ if ($success) {
24
+ return theme.stigg.palette.successDark;
25
+ } else if ($error) {
26
+ return theme.stigg.palette.errorDark;
27
+ }
28
+ return '';
29
+ }};
30
+ }
36
31
  `;
37
32
 
38
33
  export const Button = ({ variant = 'outlined', ...props }: ButtonProps & StyledButtonProps) => {
@@ -63,8 +63,9 @@ function AddonListItem({
63
63
  setAddon(addon, initialAddonState.quantity);
64
64
  } else {
65
65
  removeAddon(addon.id);
66
- onAddonsValidationChange({ addonId: addon.id, isValid: true });
67
66
  }
67
+
68
+ onAddonsValidationChange({ addonId: addon.id, isValid: true });
68
69
  };
69
70
 
70
71
  return (
@@ -102,7 +103,12 @@ function AddonListItem({
102
103
  FormHelperTextProps={{ sx: { margin: '4px' } }}
103
104
  onChange={(event) => handleQuantityChange(event?.target?.value ? Number(event?.target?.value) : null)}
104
105
  />
105
- <TrashButton color="error" onClick={() => removeAddon(addon.id)}>
106
+ <TrashButton
107
+ color="error"
108
+ onClick={() => {
109
+ removeAddon(addon.id);
110
+ onAddonsValidationChange({ addonId: addon.id, isValid: true });
111
+ }}>
106
112
  <Icon icon="Trash" style={{ display: 'flex' }} />
107
113
  </TrashButton>
108
114
  </>
@@ -124,8 +130,7 @@ export function CheckoutAddonsStep() {
124
130
  const { initialAddons, addons, availableAddons, setAddon, removeAddon } = useAddonsStepModel();
125
131
  const [addonsValidation, setAddonsValidation] = useState(
126
132
  availableAddons?.reduce<Record<string, boolean>>((acc, curr) => {
127
- const addonState = addons.find((x) => x.addon.id === curr.id);
128
- acc[curr.id] = !!addonState && addonState.quantity > 0;
133
+ acc[curr.id] = true;
129
134
  return acc;
130
135
  }, {}) || {},
131
136
  );