mirror of
https://github.com/R0m1k3/Socialflow.git
synced 2026-10-17 20:26:24 +02:00
Enable users to edit and delete their managed social media pages
Adds PUT and DELETE API endpoints for social pages, along with UI elements for editing and deleting pages on the client-side. Replit-Commit-Author: Agent Replit-Commit-Session-Id: ae4037a0-2a6f-4530-9bac-79b543286bda Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/397bca8c-984f-43ff-841a-10897aeb8140/ae4037a0-2a6f-4530-9bac-79b543286bda/Ob3gzfQ
This commit is contained in:
1 parent
82b73620dd
commit
cce7c511d0
3 files changed
+161
-15
No files matched your search
@@ -541,6 +541,45 @@ export async function registerRoutes(app: Express): Promise<Server> {
|
||||
}
|
||||
});
|
||||
|
||||
app.put("/api/pages/:id", requireAuth, async (req, res) => {
|
||||
try {
|
||||
const user = req.user as User;
|
||||
const userId = user.id;
|
||||
const pageId = req.params.id;
|
||||
|
||||
const existingPage = await storage.getSocialPage(pageId);
|
||||
if (!existingPage || existingPage.userId !== userId) {
|
||||
return res.status(404).json({ error: "Page non trouvée" });
|
||||
}
|
||||
|
||||
const pageData = insertSocialPageSchema.partial().parse(req.body);
|
||||
const updatedPage = await storage.updateSocialPage(pageId, pageData);
|
||||
res.json(updatedPage);
|
||||
} catch (error) {
|
||||
console.error("Error updating page:", error);
|
||||
res.status(500).json({ error: "Failed to update page" });
|
||||
}
|
||||
});
|
||||
|
||||
app.delete("/api/pages/:id", requireAuth, async (req, res) => {
|
||||
try {
|
||||
const user = req.user as User;
|
||||
const userId = user.id;
|
||||
const pageId = req.params.id;
|
||||
|
||||
const existingPage = await storage.getSocialPage(pageId);
|
||||
if (!existingPage || existingPage.userId !== userId) {
|
||||
return res.status(404).json({ error: "Page non trouvée" });
|
||||
}
|
||||
|
||||
await storage.deleteSocialPage(pageId);
|
||||
res.json({ success: true });
|
||||
} catch (error) {
|
||||
console.error("Error deleting page:", error);
|
||||
res.status(500).json({ error: "Failed to delete page" });
|
||||
}
|
||||
});
|
||||
|
||||
// AI Generations
|
||||
app.get("/api/ai/generations", requireAuth, async (req, res) => {
|
||||
try {
|
||||
|
||||
Reference in new issue
Block a user