Skip to content

[Dashboard] Add staff mode for viewing teams without membership #7299

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conversation

jnsdls
Copy link
Member

@jnsdls jnsdls commented Jun 6, 2025

Summary by CodeRabbit

  • New Features
    • Added a "STAFF MODE" warning banner for users viewing a team they do not belong to, with a button to leave staff mode.
  • User Interface
    • Adjusted the team header layout for improved accessibility, ensuring the team badge is no longer nested inside the team link.

PR-Codex overview

This PR focuses on enhancing the team management interface by updating the TeamHeaderUI component and modifying the layout for team and project pages. It introduces a "Staff Mode" feature to restrict actions for certain users.

Detailed summary

  • Refactored TeamHeaderUI to wrap content in a span for better structure.
  • Added "Staff Mode" warning message in both TeamLayout and ProjectLayout if the user is restricted from actions.
  • Updated data fetching to include getTeamBySlug in both layouts.
  • Ensured redirection logic is based on team existence.

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

vercel bot commented Jun 6, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
thirdweb-www ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jun 6, 2025 9:49pm
4 Skipped Deployments
Name Status Preview Comments Updated (UTC)
docs-v2 ⬜️ Skipped (Inspect) Jun 6, 2025 9:49pm
login ⬜️ Skipped (Inspect) Jun 6, 2025 9:49pm
thirdweb_playground ⬜️ Skipped (Inspect) Jun 6, 2025 9:49pm
wallet-ui ⬜️ Skipped (Inspect) Jun 6, 2025 9:49pm

@vercel vercel bot temporarily deployed to Preview – wallet-ui June 6, 2025 21:13 Inactive
@vercel vercel bot temporarily deployed to Preview – login June 6, 2025 21:13 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground June 6, 2025 21:13 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 June 6, 2025 21:13 Inactive
Copy link

changeset-bot bot commented Jun 6, 2025

⚠️ No Changeset found

Latest commit: 7fa5be5

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

Copy link
Contributor

coderabbitai bot commented Jun 6, 2025

## Walkthrough

The updates modify how a team is fetched by slug in the dashboard app, replacing manual searching with a direct API call. A "STAFF MODE" warning banner is introduced for users viewing teams they do not belong to. Additionally, the structure of the team header is adjusted to separate the team badge from the team link.

## Changes

| File(s)                                                                                 | Change Summary                                                                                      |
|----------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------|
| apps/dashboard/src/app/(app)/team/[team_slug]/(team)/layout.tsx                        | Uses `getTeamBySlug` API for direct team fetching, adds "STAFF MODE" banner for non-member views, updates login redirect logic. |
| apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/layout.tsx      | Uses `getTeamBySlug` and `getProject` APIs for direct fetching, removes manual team/project search, adds "STAFF MODE" banner for non-member views. |
| apps/dashboard/src/app/(app)/team/components/TeamHeader/TeamHeaderUI.tsx               | Refactors structure to move `TeamPlanBadge` outside the team link and adds explanatory comment.     |

## Sequence Diagram(s)

```mermaid
sequenceDiagram
    participant User
    participant Layout
    participant API
    participant UI

    User->>Layout: Access team page by slug
    Layout->>API: getTeamBySlug(slug)
    API-->>Layout: Return team or null
    Layout->>API: getTeams() (fetch user teams)
    API-->>Layout: Return list of teams
    Layout->>UI: Render team layout
    alt Team not in user's teams
        UI->>User: Show "STAFF MODE" banner with "Leave Staff Mode" button
    end
    UI->>User: Show team header and content

Possibly related PRs


## Suggested reviewers

- jnsdls


<!-- walkthrough_end -->


---

<details>
<summary>📜 Recent review details</summary>

**Configuration used: CodeRabbit UI**
**Review profile: CHILL**
**Plan: Pro**


<details>
<summary>📥 Commits</summary>

Reviewing files that changed from the base of the PR and between f305c2d9ff44c89a37e8f280896becd6de23ef69 and 7fa5be53173e7c167b93e3cb30aa6ece578cde50.

</details>

<details>
<summary>📒 Files selected for processing (3)</summary>

* `apps/dashboard/src/app/(app)/team/[team_slug]/(team)/layout.tsx` (3 hunks)
* `apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/layout.tsx` (3 hunks)
* `apps/dashboard/src/app/(app)/team/components/TeamHeader/TeamHeaderUI.tsx` (1 hunks)

</details>

<details>
<summary>🚧 Files skipped from review as they are similar to previous changes (3)</summary>

* apps/dashboard/src/app/(app)/team/components/TeamHeader/TeamHeaderUI.tsx
* apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/layout.tsx
* apps/dashboard/src/app/(app)/team/[team_slug]/(team)/layout.tsx

</details>

<details>
<summary>⏰ Context from checks skipped due to timeout of 90000ms (8)</summary>

* GitHub Check: E2E Tests (pnpm, esbuild)
* GitHub Check: Size
* GitHub Check: E2E Tests (pnpm, webpack)
* GitHub Check: E2E Tests (pnpm, vite)
* GitHub Check: Lint Packages
* GitHub Check: Build Packages
* GitHub Check: Unit Tests
* GitHub Check: Analyze (javascript)

</details>

</details>
<!-- internal state start -->


<!-- DwQgtGAEAqAWCWBnSTIEMB26CuAXA9mAOYCmGJATmriQCaQDG+Ats2bgFyQAOFk+AIwBWJBrngA3EsgEBPRvlqU0AgfFwA6NPEgQAfACgjoCEYDEZyAAUASpETZWaCrKNwSPbABsvkCiQBHbGlcSHFcLzpIACIAbQARNERYAXxnWgBdSABBWnpEXDQAMyLIZkUPIvw+CXgSAHd4DCIwkjRmZEbcWHw8MpJmAUpk+G5oyHqk+2wBZnUaejkw2A9sREpIIQxEWi9kKdtIDEchvgB2ACYATiuULG6PbvgKWnqSATAlCQB6IWR/bj4RDqaqyDQwBDIQ5NXAURTYBjSdAxADKhRKkAAshVxkU2rhsP5ltQ/CEKPAxMg1hs0GJ4PhtpABEkogzWu1+oNhghuAAadA+fCNZr2dGlakUZAESC1BrsjqQEhSL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4oc/091AM9IJhKB4Y+00VdFXQSgZdiM5d3FtEvpi8DERE3dKkzFOA/A0ArFJNnBs8FAHE1FnFNE3EDBQiOF1AklLJEAklusRI6AUkgtQgeEsi+FGAABWAAFgAA4LhGiABmeogABlqLQAAEY2gzgGABALhmi8QzgzhaALg0ALgLgujqjmjaBqizgBAzh6izhajXFDBQirhLgp4ujmizg2jmirgLgAA2Wo6otANAUQNotogQNoi4NohgIoC4Wo2georoxo2oi4R4q4AQNYyoiANCZoto6ohgC4WgK4EoWo2ohgeoq4NAXYkgeox49omEo4oYBgWgI4pQQYqeI424LRKos4IoNAaooYGYros4ZokgPoroo4hYq4Sk5o/owE84o40QEgeY+o9E9kto34v4qAHI3API2gAooohoEogRNYoAA= -->

<!-- internal state end -->
<!-- finishing_touch_checkbox_start -->

<details open="true">
<summary>✨ Finishing Touches</summary>

- [ ] <!-- {"checkboxId": "7962f53c-55bc-4827-bfbf-6a18da830691"} --> 📝 Generate Docstrings

</details>

<!-- finishing_touch_checkbox_end -->
<!-- tips_start -->

---



<details>
<summary>🪧 Tips</summary>

### Chat

There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai?utm_source=oss&utm_medium=github&utm_campaign=thirdweb-dev/js&utm_content=7299):

- Review comments: Directly reply to a review comment made by CodeRabbit. Example:
  - `I pushed a fix in commit <commit_id>, please review it.`
  - `Explain this complex logic.`
  - `Open a follow-up GitHub issue for this discussion.`
- Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples:
  - `@coderabbitai explain this code block.`
  -	`@coderabbitai modularize this function.`
- PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
  - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.`
  - `@coderabbitai read src/utils.ts and explain its main purpose.`
  - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.`
  - `@coderabbitai help me debug CodeRabbit configuration file.`

### Support

Need help? Create a ticket on our [support page](https://www.coderabbit.ai/contact-us/support) for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

### CodeRabbit Commands (Invoked using PR comments)

- `@coderabbitai pause` to pause the reviews on a PR.
- `@coderabbitai resume` to resume the paused reviews.
- `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
- `@coderabbitai full review` to do a full review from scratch and review all the files again.
- `@coderabbitai summary` to regenerate the summary of the PR.
- `@coderabbitai generate docstrings` to [generate docstrings](https://docs.coderabbit.ai/finishing-touches/docstrings) for this PR.
- `@coderabbitai generate sequence diagram` to generate a sequence diagram of the changes in this PR.
- `@coderabbitai resolve` resolve all the CodeRabbit review comments.
- `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository.
- `@coderabbitai help` to get help.

### Other keywords and placeholders

- Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed.
- Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description.
- Add `@coderabbitai` anywhere in the PR title to generate the title automatically.

### CodeRabbit Configuration File (`.coderabbit.yaml`)

- You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository.
- Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information.
- If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json`

### Documentation and Community

- Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit.
- Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback.
- Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.

</details>

<!-- tips_end -->

Copy link
Member Author

jnsdls commented Jun 6, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge-queue - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added the Dashboard Involves changes to the Dashboard. label Jun 6, 2025
@jnsdls jnsdls marked this pull request as ready for review June 6, 2025 21:13
@jnsdls jnsdls requested review from a team as code owners June 6, 2025 21:13
Copy link

codecov bot commented Jun 6, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.57%. Comparing base (69bf925) to head (7fa5be5).
Report is 2 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #7299      +/-   ##
==========================================
- Coverage   55.57%   55.57%   -0.01%     
==========================================
  Files         909      909              
  Lines       58673    58673              
  Branches     4158     4158              
==========================================
- Hits        32609    32607       -2     
- Misses      25957    25959       +2     
  Partials      107      107              
Flag Coverage Δ
packages 55.57% <ø> (-0.01%) ⬇️

see 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/layout.tsx (1)

51-65: Well-implemented staff mode banner with clear UX.

The implementation correctly identifies when a user is viewing a team they don't belong to and provides:

  • Clear visual indication with warning styling and emoji
  • Informative message about read-only access
  • Easy exit via "Leave Staff Mode" button

The condition !teams.some((t) => t.slug === team.slug) properly checks if the current team is not in the user's teams list.

However, consider adding error boundary handling for edge cases where the staff mode might cause unexpected behavior in downstream components that assume team membership.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2510c4f and c548282.

📒 Files selected for processing (2)
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/layout.tsx (3 hunks)
  • apps/dashboard/src/app/(app)/team/components/TeamHeader/TeamHeaderUI.tsx (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
apps/dashboard/src/app/(app)/team/components/TeamHeader/TeamHeaderUI.tsx (1)
apps/dashboard/src/app/(app)/components/TeamPlanBadge.tsx (1)
  • TeamPlanBadge (35-70)
apps/dashboard/src/app/(app)/team/[team_slug]/(team)/layout.tsx (4)
apps/dashboard/src/app/(app)/api/lib/getAuthToken.ts (2)
  • getAuthTokenWalletAddress (16-30)
  • getAuthToken (6-14)
apps/dashboard/src/app/(app)/account/settings/getAccount.ts (1)
  • getValidAccount (44-53)
apps/dashboard/src/@/api/team.ts (2)
  • getTeams (53-68)
  • getTeamBySlug (11-30)
apps/dashboard/src/@/components/ui/button.tsx (1)
  • Button (85-85)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Size
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (4)
apps/dashboard/src/app/(app)/team/components/TeamHeader/TeamHeaderUI.tsx (1)

57-73: Good fix for HTML validity and accessibility.

The restructuring correctly addresses the nested link issue. TeamPlanBadge conditionally renders its own <Link> when the plan is "free" (as shown in the relevant code snippets), so moving it outside the main team link prevents invalid nested <a> elements while maintaining the desired layout.

apps/dashboard/src/app/(app)/team/[team_slug]/(team)/layout.tsx (3)

2-8: Imports look appropriate.

The added imports (getTeamBySlug, Button, Link) are all used in the implementation and necessary for the staff mode functionality.


25-31: Good performance improvement with direct API call.

Fetching the team directly by slug using getTeamBySlug is more efficient than the previous approach of fetching all teams and searching through them. This also enables the staff mode functionality by allowing access to teams the user doesn't belong to.


33-35: Proper error handling for team existence.

The updated redirect condition correctly handles the case where the team doesn't exist, ensuring users are redirected to login when the team cannot be fetched.

Copy link
Contributor

github-actions bot commented Jun 6, 2025

size-limit report 📦

Path Size Loading time (3g) Running time (snapdragon) Total time
thirdweb (esm) 62.57 KB (0%) 1.3 s (0%) 250 ms (+144.77% 🔺) 1.6 s
thirdweb (cjs) 345.55 KB (0%) 7 s (0%) 905 ms (+4.38% 🔺) 7.9 s
thirdweb (minimal + tree-shaking) 5.7 KB (0%) 114 ms (0%) 107 ms (+1055.21% 🔺) 221 ms
thirdweb/chains (tree-shaking) 531 B (0%) 11 ms (0%) 12 ms (+421.08% 🔺) 22 ms
thirdweb/react (minimal + tree-shaking) 19.56 KB (0%) 392 ms (0%) 91 ms (+444.78% 🔺) 482 ms

@jnsdls jnsdls force-pushed the _Dashboard_Add_staff_mode_for_viewing_teams_without_membership branch from c548282 to 972ef13 Compare June 6, 2025 21:24
@vercel vercel bot temporarily deployed to Preview – login June 6, 2025 21:24 Inactive
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground June 6, 2025 21:24 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 June 6, 2025 21:24 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui June 6, 2025 21:24 Inactive
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🔭 Outside diff range comments (1)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/layout.tsx (1)

47-49: ⚠️ Potential issue

Critical: Staff mode users cannot access projects due to faulty search logic.

The project finding logic searches within teamsAndProjects which is built from teams (user's accessible teams). When a user views a team in staff mode (not a member), that team won't exist in teams, causing this search to always fail and redirect to the team page, breaking the staff mode functionality for project access.

Consider this fix to handle staff mode project access:

- const project = teamsAndProjects
-   .find((t) => t.team.slug === decodeURIComponent(params.team_slug))
-   ?.projects.find((p) => p.slug === params.project_slug);
+ // For staff mode: if team is not in user's teams, fetch projects directly
+ let project;
+ const userTeamProjects = teamsAndProjects
+   .find((t) => t.team.slug === decodeURIComponent(params.team_slug))
+   ?.projects;
+ 
+ if (userTeamProjects) {
+   project = userTeamProjects.find((p) => p.slug === params.project_slug);
+ } else {
+   // Staff mode: fetch projects for the team directly
+   const staffModeProjects = await getProjects(team.slug);
+   project = staffModeProjects?.find((p) => p.slug === params.project_slug);
+ }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c548282 and 972ef13.

📒 Files selected for processing (3)
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/layout.tsx (3 hunks)
  • apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/layout.tsx (2 hunks)
  • apps/dashboard/src/app/(app)/team/components/TeamHeader/TeamHeaderUI.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • apps/dashboard/src/app/(app)/team/components/TeamHeader/TeamHeaderUI.tsx
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/layout.tsx
🧰 Additional context used
🧠 Learnings (1)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/layout.tsx (1)
Learnt from: jnsdls
PR: thirdweb-dev/js#6929
File: apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/insight/webhooks/page.tsx:14-19
Timestamp: 2025-05-21T05:17:31.283Z
Learning: In Next.js server components, the `params` object can sometimes be a Promise that needs to be awaited, despite type annotations suggesting otherwise. In apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/insight/webhooks/page.tsx, it's necessary to await the params object before accessing its properties.
🧬 Code Graph Analysis (1)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/layout.tsx (3)
apps/dashboard/src/app/(app)/api/lib/getAuthToken.ts (2)
  • getAuthTokenWalletAddress (16-30)
  • getAuthToken (6-14)
apps/dashboard/src/@/api/team.ts (2)
  • getTeams (53-68)
  • getTeamBySlug (11-30)
apps/dashboard/src/app/(app)/account/settings/getAccount.ts (1)
  • getValidAccount (44-53)
⏰ Context from checks skipped due to timeout of 90000ms (8)
  • GitHub Check: E2E Tests (pnpm, esbuild)
  • GitHub Check: Size
  • GitHub Check: E2E Tests (pnpm, webpack)
  • GitHub Check: E2E Tests (pnpm, vite)
  • GitHub Check: Build Packages
  • GitHub Check: Unit Tests
  • GitHub Check: Lint Packages
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (1)
apps/dashboard/src/app/(app)/team/[team_slug]/[project_slug]/(sidebar)/layout.tsx (1)

2-2: LGTM! Import addition is correct.

The import of getTeamBySlug is properly added to support direct team fetching by slug.

@jnsdls jnsdls force-pushed the _Dashboard_Add_staff_mode_for_viewing_teams_without_membership branch from 972ef13 to f305c2d Compare June 6, 2025 21:33
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground June 6, 2025 21:33 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui June 6, 2025 21:33 Inactive
@vercel vercel bot temporarily deployed to Preview – login June 6, 2025 21:33 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 June 6, 2025 21:33 Inactive
Copy link
Contributor

graphite-app bot commented Jun 6, 2025

Merge activity

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **New Features**
  - Added a "STAFF MODE" warning banner for users viewing a team they do not belong to, with a button to leave staff mode.
- **User Interface**
  - Adjusted the team header layout for improved accessibility, ensuring the team badge is no longer nested inside the team link.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->

<!-- start pr-codex -->

---

## PR-Codex overview
This PR primarily focuses on updating the `TeamHeaderUI` component and enhancing the `TeamLayout` and `ProjectLayout` components to incorporate a "Staff Mode" feature, which restricts user actions based on team membership.

### Detailed summary
- Modified the structure of the `TeamHeaderUI` component to wrap the `Link` inside a `span`.
- Added a "Staff Mode" warning message in `TeamLayout` if the user is not part of the team.
- Implemented the same "Staff Mode" warning in `ProjectLayout`.
- Updated API calls to include `getTeamBySlug` and `getProject`.

> ✨ Ask PR-Codex anything about this PR by commenting with `/codex {your question}`

<!-- end pr-codex -->
@graphite-app graphite-app bot force-pushed the _Dashboard_Add_staff_mode_for_viewing_teams_without_membership branch from f305c2d to 7fa5be5 Compare June 6, 2025 21:42
@vercel vercel bot temporarily deployed to Preview – thirdweb_playground June 6, 2025 21:42 Inactive
@vercel vercel bot temporarily deployed to Preview – wallet-ui June 6, 2025 21:42 Inactive
@vercel vercel bot temporarily deployed to Preview – docs-v2 June 6, 2025 21:42 Inactive
@vercel vercel bot temporarily deployed to Preview – login June 6, 2025 21:42 Inactive
@graphite-app graphite-app bot merged commit 7fa5be5 into main Jun 6, 2025
24 checks passed
@graphite-app graphite-app bot deleted the _Dashboard_Add_staff_mode_for_viewing_teams_without_membership branch June 6, 2025 21:50
@vercel vercel bot temporarily deployed to Production – login June 6, 2025 21:50 Inactive
@vercel vercel bot temporarily deployed to Production – thirdweb_playground June 6, 2025 21:50 Inactive
@vercel vercel bot temporarily deployed to Production – docs-v2 June 6, 2025 21:50 Inactive
@vercel vercel bot temporarily deployed to Production – wallet-ui June 6, 2025 21:50 Inactive
@coderabbitai coderabbitai bot mentioned this pull request Jun 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Dashboard Involves changes to the Dashboard.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants