import { useState } from 'react';
import { useQueryClient } from '@tanstack/react-query';
import { setAuthUserId, useAuthUserId } from '../config';
export default function DevAuthSwitcher() {
const authUserId = useAuthUserId();
if (!import.meta.env.DEV) {
return null;
}
return (
);
}
function DevAuthSwitcherForm({
authUserId,
}: {
authUserId: string | null;
}) {
const queryClient = useQueryClient();
const [inputValue, setInputValue] = useState(authUserId ?? '');
function updateAuthUserId(nextValue: string | null) {
setAuthUserId(nextValue);
void queryClient.invalidateQueries();
}
return (
Dev Auth
X-Auth-User-Id
setInputValue(event.target.value)}
placeholder="Mongo User ID"
className="mt-1 w-full border border-base-content/10 bg-transparent px-2 py-2 text-xs text-base-content focus:outline-none focus:border-primary/30"
/>
현재값: {authUserId ?? '없음'}
);
}