fix(10-04): prettier format + remove unnecessary type assertions
- Run prettier on all new/modified PWA files (CredentialSheet, SetupBanner, AdminPage, admin.spec.ts) - Remove unnecessary 'as React.RefObject<HTMLElement | null>' casts flagged by @typescript-eslint/no-unnecessary-type-assertion - Format pre-existing API files from Plans 02/03 (me.ts, user.test.ts, requireAdmin.test.ts, me.test.ts) - All 270 API tests + 191 PWA vitest tests pass; lint/typecheck/build clean
This commit is contained in:
@@ -100,9 +100,7 @@ test.describe('Non-admin user — admin nav entry hidden + /admin redirect', ()
|
||||
await page.waitForURL(/\/calendar/, { timeout: 10_000 });
|
||||
// Should have landed on /calendar
|
||||
const url = new URL(page.url());
|
||||
expect(url.pathname, `Expected /calendar but got ${url.pathname}`).toMatch(
|
||||
/^\/(calendar)?$/,
|
||||
);
|
||||
expect(url.pathname, `Expected /calendar but got ${url.pathname}`).toMatch(/^\/(calendar)?$/);
|
||||
// "Admin Settings" heading must NOT be present
|
||||
await expect(page.getByRole('heading', { name: 'Admin Settings' })).toHaveCount(0);
|
||||
});
|
||||
|
||||
@@ -296,7 +296,9 @@ export function CredentialSheet({
|
||||
id="credential-helper"
|
||||
style={{
|
||||
fontSize: 'var(--text-label-size, 13px)',
|
||||
color: validationError ? 'var(--color-destructive, #DC2626)' : 'var(--color-text-secondary)',
|
||||
color: validationError
|
||||
? 'var(--color-destructive, #DC2626)'
|
||||
: 'var(--color-text-secondary)',
|
||||
lineHeight: 1.4,
|
||||
marginBottom: 'var(--space-6, 24px)',
|
||||
display: 'flex',
|
||||
|
||||
@@ -30,6 +30,7 @@ import { CredentialSheet } from './CredentialSheet.js';
|
||||
|
||||
export function SetupBanner() {
|
||||
const [sheetOpen, setSheetOpen] = useState(false);
|
||||
// Use HTMLButtonElement for the ref (assignable to the CredentialSheet's HTMLElement trigger)
|
||||
const ctaRef = useRef<HTMLButtonElement>(null);
|
||||
|
||||
const meQuery = useQuery({
|
||||
@@ -124,7 +125,7 @@ export function SetupBanner() {
|
||||
onClose={() => setSheetOpen(false)}
|
||||
mode="self-service"
|
||||
memberName={memberName}
|
||||
triggerRef={ctaRef as React.RefObject<HTMLElement | null>}
|
||||
triggerRef={ctaRef}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
||||
@@ -77,8 +77,7 @@ export function AdminPage() {
|
||||
});
|
||||
|
||||
// Derive current saved shared calendar id from the data
|
||||
const currentSharedId =
|
||||
calendarsQuery.data?.calendars.find((c) => c.isShared)?.id ?? null;
|
||||
const currentSharedId = calendarsQuery.data?.calendars.find((c) => c.isShared)?.id ?? null;
|
||||
|
||||
// Effective selected = user pick OR fallback to current saved
|
||||
const effectiveSelected = selectedCalendarId ?? currentSharedId;
|
||||
@@ -97,8 +96,7 @@ export function AdminPage() {
|
||||
// Open credential sheet for a member
|
||||
function openSheet(member: AdminMember, buttonRef: React.RefObject<HTMLButtonElement | null>) {
|
||||
// Capture the button so focus can return on close
|
||||
(triggerRef as React.MutableRefObject<HTMLElement | null>).current =
|
||||
buttonRef.current;
|
||||
(triggerRef as React.MutableRefObject<HTMLElement | null>).current = buttonRef.current;
|
||||
setSheetMember(member);
|
||||
setSheetMode(member.hasCredential ? 'admin-rotate' : 'admin-add');
|
||||
setSheetOpen(true);
|
||||
@@ -298,7 +296,7 @@ export function AdminPage() {
|
||||
mode={sheetMode}
|
||||
memberName={sheetMember.displayName}
|
||||
memberId={sheetMember.id}
|
||||
triggerRef={triggerRef as React.RefObject<HTMLElement | null>}
|
||||
triggerRef={triggerRef}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user