mirror of
https://github.com/samkaraca/lazuri-doviguram.git
synced 2026-04-29 17:59:51 +00:00
isr on demand fixed.
This commit is contained in:
parent
c7eae15a96
commit
65f17fdc2d
@ -324,7 +324,7 @@ export function useAdminViewModel(): AdminViewModel {
|
||||
|
||||
const publishChanges = async () => {
|
||||
setStalling(true);
|
||||
const resObj = await fetch(`/api/admin/temalar`, {
|
||||
const resObj = await fetch(`/api/admin/temalar/${themeId}`, {
|
||||
method: "POST",
|
||||
body: JSON.stringify({ type: "publishChanges" }),
|
||||
headers: {
|
||||
|
||||
@ -35,6 +35,29 @@ async function handler(req: NextApiRequest, res: NextApiResponse) {
|
||||
const theme = req.query.theme as string;
|
||||
const themeData = await themeRepo.getThemeData(theme);
|
||||
return res.status(200).json(themeData);
|
||||
} else if (req.method === "POST") {
|
||||
const { type } = req.body;
|
||||
const themeId = req.query.theme;
|
||||
|
||||
if (type === "publishChanges") {
|
||||
try {
|
||||
await res.revalidate(`/temalar/${themeId}`);
|
||||
await res.revalidate("/");
|
||||
return res.status(200).send({
|
||||
status: "success",
|
||||
message: "Değişiklikler başarıyla yayınlandı.",
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(
|
||||
`/api/admin/temalar/${themeId} -> POST -> publishChanges ->`,
|
||||
error
|
||||
);
|
||||
return res.status(200).send({
|
||||
status: "error",
|
||||
message: "Değişikliklerin yayınlanması başarısız.",
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res.status(501).json({ error: "Unsopported request method" });
|
||||
|
||||
@ -27,26 +27,6 @@ export default async function handler(
|
||||
return res.status(200).json(result.data);
|
||||
}
|
||||
return res.status(200).json([]);
|
||||
} else if (req.method === "POST") {
|
||||
const { type } = req.body;
|
||||
|
||||
if (type === "publishChanges") {
|
||||
try {
|
||||
await res.revalidate("/temalar/[theme]");
|
||||
return res.status(200).send({
|
||||
status: "success",
|
||||
message: "Değişiklikler başarıyla yayınlandı.",
|
||||
});
|
||||
} catch (error) {
|
||||
console.error(error);
|
||||
return res.status(200).send({
|
||||
status: "error",
|
||||
message: "Değişikliklerin yayınlanması başarısız.",
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return res.status(501).json({ error: "Unsopported action" });
|
||||
}
|
||||
|
||||
return res.status(501).json({ error: "Unsopported request method" });
|
||||
|
||||
@ -28,5 +28,5 @@ export async function getStaticPaths() {
|
||||
return { paths: themePaths, fallback: false };
|
||||
}
|
||||
|
||||
return { paths: [{ params: { theme: "id1234" } }], fallback: false };
|
||||
return { paths: [], fallback: false };
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user