Fix delete session error and inline edit duplication bug
This commit is contained in:
parent
e2c040e178
commit
970ebe4581
@ -34,7 +34,8 @@ async function requireAuth() {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// Si es modo bypass (admin-emergency), no podemos llamar a account.get() con la API Key
|
// Si es modo bypass (admin-emergency), no podemos llamar a account.get() con la API Key
|
||||||
const cookieStore = await require('@/lib/appwrite.server').cookies();
|
const { cookies } = require('next/headers');
|
||||||
|
const cookieStore = await cookies();
|
||||||
const PROJECT_ID = process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID || '69b84df5003bd8957c5c';
|
const PROJECT_ID = process.env.NEXT_PUBLIC_APPWRITE_PROJECT_ID || '69b84df5003bd8957c5c';
|
||||||
const sessionCookie = cookieStore.get(`a_session_${PROJECT_ID.toLowerCase()}`);
|
const sessionCookie = cookieStore.get(`a_session_${PROJECT_ID.toLowerCase()}`);
|
||||||
|
|
||||||
|
|||||||
@ -131,7 +131,11 @@ export default async function EntityPage({
|
|||||||
console.error(`Error fetching entity ${entity}:`, error);
|
console.error(`Error fetching entity ${entity}:`, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
const boundEditAction = saveEntityAction.bind(null, entity);
|
const boundEditAction = async (id: string, formData: FormData) => {
|
||||||
|
'use server';
|
||||||
|
const { updateEntityAction } = await import('@/app/actions/entities');
|
||||||
|
return updateEntityAction(entity, id, formData);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="space-y-6 animate-fade-in pb-10">
|
<div className="space-y-6 animate-fade-in pb-10">
|
||||||
|
|||||||
@ -17,7 +17,7 @@ export interface PublicationDrawerProps {
|
|||||||
post: Post | null;
|
post: Post | null;
|
||||||
user: AuthUser;
|
user: AuthUser;
|
||||||
relationData: Record<string, Array<{ $id: string; [key: string]: unknown }>>;
|
relationData: Record<string, Array<{ $id: string; [key: string]: unknown }>>;
|
||||||
submitAction: (formData: FormData) => Promise<{ success: boolean; error?: string; data?: unknown } | void>;
|
submitAction: (id: string, formData: FormData) => Promise<{ success: boolean; error?: string; data?: unknown } | void>;
|
||||||
appwriteConfig: {
|
appwriteConfig: {
|
||||||
endpoint: string;
|
endpoint: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
@ -64,12 +64,13 @@ export const PublicationDrawer: React.FC<PublicationDrawerProps> = ({
|
|||||||
}, [isOpen, handleKeyDown]);
|
}, [isOpen, handleKeyDown]);
|
||||||
|
|
||||||
const wrappedSubmit = useCallback(async (formData: FormData) => {
|
const wrappedSubmit = useCallback(async (formData: FormData) => {
|
||||||
const result = await submitAction(formData);
|
if (!post?.$id) return { success: false, error: 'No post ID found' };
|
||||||
|
const result = await submitAction(post.$id, formData);
|
||||||
if (!result || result.success) {
|
if (!result || result.success) {
|
||||||
onSuccess?.();
|
onSuccess?.();
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}, [submitAction, onSuccess]);
|
}, [submitAction, onSuccess, post]);
|
||||||
|
|
||||||
if (typeof document === 'undefined') return null;
|
if (typeof document === 'undefined') return null;
|
||||||
|
|
||||||
|
|||||||
@ -35,7 +35,7 @@ interface PublicationsListProps {
|
|||||||
initialPosts: Post[];
|
initialPosts: Post[];
|
||||||
user: AuthUser;
|
user: AuthUser;
|
||||||
relationData: Record<string, Array<{ $id: string; [key: string]: unknown }>>;
|
relationData: Record<string, Array<{ $id: string; [key: string]: unknown }>>;
|
||||||
submitEditAction: (formData: FormData) => Promise<{ success: boolean; error?: string; data?: unknown } | void>;
|
submitEditAction: (id: string, formData: FormData) => Promise<{ success: boolean; error?: string; data?: unknown } | void>;
|
||||||
appwriteConfig: {
|
appwriteConfig: {
|
||||||
endpoint: string;
|
endpoint: string;
|
||||||
projectId: string;
|
projectId: string;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user