@kittycad/react-shared 1.1.0 → 1.1.1

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/README.md CHANGED
@@ -54,6 +54,38 @@ npm run lint
54
54
  npm run fmt
55
55
  ```
56
56
 
57
+ ### Linking package locally
58
+
59
+ Assumes your directory structure looks like
60
+ ```
61
+ .
62
+ ├── modeling-app
63
+ └── react-shared
64
+ ```
65
+
66
+ ```
67
+ git clone git@github.com:KittyCAD/react-shared.git
68
+ cd react-shared
69
+ npm link
70
+ npm install
71
+ npm run build
72
+ // edit your files
73
+ // make sure to rebuild this after code changes!
74
+ ```
75
+
76
+ ```
77
+ cd modeling-app
78
+ rm -rf node_modules
79
+ // Write "@kittycad/react-shared": "file:../react-shared", the package.json
80
+ npm install
81
+ npm install ../react-shared/ --install-links
82
+ ```
83
+
84
+ #### Gotchas
85
+ - using npm link can break with `vite` because vite will create `modeling-app/node_modules/.vite/deps` that are cached and will not be the correctly npm linked one. I needed to use the `file:` prefix to install the package to get around this `vite` issue.
86
+ - `--install-links` commmand is required because the package has a peerDependenices list and React is in that list. We need to make sure that modeling-app and the package have the same react version otherwise you will run into problems.
87
+ - Basic `npm link` and `npm link @kittycad/react-shared` will not work! `vite` bricks this!
88
+
57
89
  ### Available Components
58
90
 
59
91
  - **Button**: A customizable button component with multiple variants and sizes
@@ -93,4 +125,4 @@ This will trigger the GitHub Action to publish to npm.
93
125
  3. Make your changes
94
126
  4. Add tests and stories for new components
95
127
  5. Run `npm run lint` and `npm run type-check`
96
- 6. Submit a pull request
128
+ 6. Submit a pull request
package/dist/index.d.ts CHANGED
@@ -137,7 +137,7 @@ declare class BillingError {
137
137
  interface IBillingInfo {
138
138
  balance: number;
139
139
  allowance?: number;
140
- userPaymentBalance: CustomerBalance;
140
+ userPaymentBalance?: CustomerBalance;
141
141
  paymentMethods: PaymentMethod[];
142
142
  isOrg: boolean;
143
143
  hasSubscription: boolean;
package/dist/index.esm.js CHANGED
@@ -25826,11 +25826,20 @@ async function getBillingInfo(client) {
25826
25826
  }
25827
25827
  const subscriptions = await fetchBilling(j.get_user_subscription, { client });
25828
25828
  const org = await fetchBilling(L.get_user_org, { client });
25829
- const paymentMethods = await fetchBilling(j.list_payment_methods_for_user, { client });
25830
- if (BillingError.from(paymentMethods)) {
25829
+ const hasOrgError = BillingError.from(org);
25830
+ let paymentMethods = await fetchBilling(j.list_payment_methods_for_user, { client });
25831
+ const isOrgUserWithoutPaymentMethod = !hasOrgError &&
25832
+ BillingError.from(paymentMethods) &&
25833
+ paymentMethods.error.type === EBillingError.NotOk &&
25834
+ 'status' in paymentMethods.error.response &&
25835
+ paymentMethods.error.response.status === 404;
25836
+ if (isOrgUserWithoutPaymentMethod) {
25837
+ paymentMethods = [];
25838
+ }
25839
+ else if (BillingError.from(paymentMethods)) {
25831
25840
  return paymentMethods;
25832
25841
  }
25833
- if (!BillingError.from(org)) {
25842
+ if (!hasOrgError) {
25834
25843
  // Org override here. TODO for api: remove the need for this
25835
25844
  // If the user is part of an org, they get infinite balance.
25836
25845
  return {