kyd-shared-badge 0.3.81 → 0.3.83

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,6 +1,6 @@
1
1
  {
2
2
  "name": "kyd-shared-badge",
3
- "version": "0.3.81",
3
+ "version": "0.3.83",
4
4
  "private": false,
5
5
  "main": "./src/index.ts",
6
6
  "module": "./src/index.ts",
@@ -165,6 +165,14 @@ export function ConnectAccounts(props: ConnectAccountsProps) {
165
165
  if (url) router.push(url);
166
166
  };
167
167
 
168
+ const onGithubAppInstall = () => {
169
+ const opaqueState = window.crypto?.randomUUID?.() || Math.random().toString(36).substring(2);
170
+ const stateObj = { opaqueState, userId, companyId, inviteId };
171
+ const stateString = encodeURIComponent(JSON.stringify(stateObj));
172
+ const redirectUrl = `https://github.com/apps/${githubAppSlugId}/installations/new?state=${stateString}`;
173
+ window.location.href = redirectUrl;
174
+ };
175
+
168
176
  const selectedProvider = useMemo(() => {
169
177
  if (!selectedProviderId) return null;
170
178
  if (selectedProviderId.toLowerCase() === 'githubapp') {
@@ -200,8 +208,8 @@ export function ConnectAccounts(props: ConnectAccountsProps) {
200
208
  }, [connected]);
201
209
  const isGithubConnected = !!githubConnectedAccount;
202
210
  const isGithubAppInstalled = useMemo(() => {
203
- const setupAction = (githubConnectedAccount as any)?.app_installation_info?.setupAction;
204
- return setupAction === 'install';
211
+ const setupAction = githubConnectedAccount?.app_installation_info?.setupAction;
212
+ return setupAction === 'install' || setupAction === 'created';
205
213
  }, [githubConnectedAccount]);
206
214
 
207
215
  return (
@@ -340,13 +348,7 @@ export function ConnectAccounts(props: ConnectAccountsProps) {
340
348
  <motion.div whileHover={{ scale: 1.02 }} whileTap={{ scale: 0.98 }}>
341
349
  <Button
342
350
  className="w-full sm:w-auto bg-[var(--icon-accent)] text-white transition-colors font-semibold"
343
- onClick={() => {
344
- const opaqueState = window.crypto?.randomUUID?.() || Math.random().toString(36).substring(2);
345
- const stateObj = { opaqueState, userId, companyId, inviteId };
346
- const stateString = encodeURIComponent(JSON.stringify(stateObj));
347
- const redirectUrl = `https://github.com/apps/${githubAppSlugId}/installations/new?state=${stateString}`;
348
- window.location.href = redirectUrl;
349
- }}
351
+ onClick={onGithubAppInstall}
350
352
  >
351
353
  <span className="flex items-center justify-center">
352
354
  <ExternalLink className="w-4 h-4 mr-2" />
@@ -433,13 +435,7 @@ export function ConnectAccounts(props: ConnectAccountsProps) {
433
435
  </Button>
434
436
  ) : (
435
437
  <Button
436
- onClick={() => {
437
- const opaqueState = window.crypto?.randomUUID?.() || Math.random().toString(36).substring(2);
438
- const stateObj = { opaqueState, userId };
439
- const stateString = encodeURIComponent(JSON.stringify(stateObj));
440
- const redirectUrl = `https://github.com/apps/${githubAppSlugId}/installations/new?state=${stateString}`;
441
- window.location.href = redirectUrl;
442
- }}
438
+ onClick={onGithubAppInstall}
443
439
  className="bg-[var(--icon-accent)] text-white hover:bg-[var(--icon-accent-hover)]"
444
440
  >
445
441
  <ExternalLink className="w-4 h-4 mr-2" />