Fix: NewsTicker public fetch and Mobile Menu button interaction
This commit is contained in:
parent
63fbc0f361
commit
5e7a28878f
@ -109,8 +109,13 @@ export const Navbar = ({ entity }: { entity?: any }) => {
|
||||
|
||||
{/* Menú Móvil Toggle */}
|
||||
<button
|
||||
onClick={() => setMobileMenuOpen(!mobileMenuOpen)}
|
||||
className="lg:hidden relative z-50 p-2 text-cyan-400 hover:text-cyan-300 transition-colors bg-slate-800/50 rounded-lg border border-cyan-500/30"
|
||||
onClick={(e) => {
|
||||
e.preventDefault();
|
||||
console.log("Toggle mobile menu:", !mobileMenuOpen);
|
||||
setMobileMenuOpen(!mobileMenuOpen);
|
||||
}}
|
||||
className="lg:hidden relative z-[60] p-2 text-cyan-400 hover:text-cyan-300 transition-colors bg-slate-800/50 rounded-lg border border-cyan-500/30 active:scale-95"
|
||||
aria-label="Menu"
|
||||
>
|
||||
{mobileMenuOpen ? <X size={26} /> : <Menu size={26} />}
|
||||
</button>
|
||||
|
||||
@ -7,8 +7,14 @@ export default async function NewsTicker() {
|
||||
let noticias: any[] = [];
|
||||
|
||||
try {
|
||||
const sessionClient = await createSessionClient();
|
||||
if (!sessionClient) throw new Error("Anonymous context required"); // Nextjs might render this in public if we use anon client
|
||||
// NewsTicker is public, we use admin client if session is not available
|
||||
let client: any = await createSessionClient();
|
||||
if (!client) {
|
||||
const { createAdminClient } = await import('@/lib/appwrite.server');
|
||||
client = await createAdminClient();
|
||||
}
|
||||
|
||||
if (!client) throw new Error("No Appwrite client available");
|
||||
|
||||
// We need an Anonymous or Public read client if this is shown in home.
|
||||
// Since 'createSessionClient' uses the session cookie, we might have issues on public incognito pages.
|
||||
|
||||
@ -33,6 +33,22 @@ export async function createSessionClient() {
|
||||
};
|
||||
}
|
||||
|
||||
export async function createAdminClient() {
|
||||
const client = new Client()
|
||||
.setEndpoint(ENDPOINT)
|
||||
.setProject(PROJECT_ID)
|
||||
.setKey(process.env.APPWRITE_API_KEY || '');
|
||||
|
||||
return {
|
||||
get account() {
|
||||
return new Account(client);
|
||||
},
|
||||
get databases() {
|
||||
return new Databases(client);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
export async function getLoggedInUser() {
|
||||
const cookieStore = await cookies();
|
||||
const sessionCookie = cookieStore.get('a_session_' + PROJECT_ID.toLowerCase());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user