name: comercialrs-settings-debugging
description: Debugging Settings page tabs and conditional rendering in ComercialRS
category: browser-debugging
ComercialRS Settings Page - Debugging Conditional Tabs
Common Issue
The "AutomaƧƵes" tab in /settings only renders when !isPreSales:
`tsx
{!isPreSales && (
AutomaƧƵes
)}
`
If the user can't see the AutomaƧƵes tab, isPreSales is evaluating to true for their profile ā even if their profiles.role shows "admin".
Debug Steps
1. Check profile role directly via Management API:
`bash
curl -s -X POST 'https://api.supabase.com/v1/projects/{ref}/database/query' \
-H 'Authorization: Bearer {pat}' \
-H 'Content-Type: application/json' \
-d '{"query": "SELECT profiles.id, profiles.user_id, profiles.role, auth.users.email FROM profiles JOIN auth.users ON profiles.user_id = auth.users.id;"}'
`
2. Check user_roles table for the user:
`bash
curl -s -X POST 'https://api.supabase.com/v1/projects/{ref}/database/query' \
-H 'Authorization: Bearer {pat}' \
-H 'Content-Type: application/json' \
-d '{"query": "SELECT * FROM user_roles WHERE user_id = '\''{user_id}'\'';"}'
`
3. In browser console, try clicking the tab directly:
`javascript
document.querySelector('[role="tab"][value="automations"]')?.click()
// or
document.querySelector('[role="tab"]:nth-of-type(5)')?.click()
`
Browser Tool Gotchas
- -
browser_clicktimes out on some interactive elements (tabs, switches) ā trybrowser_consolewith direct JS click instead - -
browser_consolereturnsnullon failure ā always follow withbrowser_snapshotto verify state change - -
browser_visionneeds actual image attachment ā file paths don't work, must paste/upload image directly in chat - -
browser_snapshotdoesn't capture React-rendered content well ā usebrowser_visionfor visual confirmation of React UIs - -
Settings.tsxlines 307-318: Tab rendering logic - -
AdmGuard.tsx: Checksuser_rolestable (NOTprofiles.role) for admin access