v2.0.2 #119
@@ -11,6 +11,7 @@ import { Button } from "../../../../_components/ui/Button";
|
||||
import { redirect } from "next/navigation";
|
||||
import dynamic from "next/dynamic";
|
||||
import toast from "react-hot-toast";
|
||||
import { cn } from "@repo/shared-components";
|
||||
|
||||
const MarkdownEditor = dynamic(() => import("@uiw/react-md-editor"), { ssr: false });
|
||||
|
||||
@@ -24,6 +25,7 @@ export const ChangelogForm = ({ changelog }: { changelog?: Changelog }) => {
|
||||
previewImage: changelog?.previewImage || "", // Changed to accept a URL as a string
|
||||
},
|
||||
});
|
||||
const [skipUserUpdate, setSkipUserUpdate] = useState(false);
|
||||
const [markdownText, setMarkdownText] = useState(changelog?.text || "");
|
||||
const [imageError, setImageError] = useState(false);
|
||||
const [showImage, setShowImage] = useState(false);
|
||||
@@ -61,6 +63,9 @@ export const ChangelogForm = ({ changelog }: { changelog?: Changelog }) => {
|
||||
text: markdownText,
|
||||
},
|
||||
changelog?.id,
|
||||
{
|
||||
skipUserUpdate: skipUserUpdate,
|
||||
},
|
||||
);
|
||||
toast.success("Daten gespeichert");
|
||||
if (!changelog) redirect(`/admin/changelog`);
|
||||
@@ -96,6 +101,7 @@ export const ChangelogForm = ({ changelog }: { changelog?: Changelog }) => {
|
||||
{(() => {
|
||||
if (showImage && isValidImageUrl(previewImage) && !imageError) {
|
||||
return (
|
||||
// eslint-disable-next-line @next/next/no-img-element
|
||||
<img
|
||||
src={previewImage}
|
||||
alt="Preview"
|
||||
@@ -127,6 +133,19 @@ export const ChangelogForm = ({ changelog }: { changelog?: Changelog }) => {
|
||||
</div>
|
||||
|
||||
<div className="card bg-base-200 col-span-6 shadow-xl">
|
||||
{!changelog?.id && (
|
||||
<label className="label mx-6 mt-6 w-full cursor-pointer">
|
||||
<input
|
||||
type="checkbox"
|
||||
className={cn("toggle")}
|
||||
checked={skipUserUpdate}
|
||||
onChange={(e) => setSkipUserUpdate(e.target.checked)}
|
||||
/>
|
||||
<span className={cn("label-text w-full text-left")}>
|
||||
Kein Popup für Nutzer für dieses Update anzeigen
|
||||
</span>
|
||||
</label>
|
||||
)}
|
||||
<div className="card-body">
|
||||
<div className="flex w-full gap-4">
|
||||
<Button
|
||||
|
||||
@@ -4,6 +4,9 @@ import { prisma, Prisma, Changelog } from "@repo/db";
|
||||
export const upsertChangelog = async (
|
||||
changelog: Prisma.ChangelogCreateInput,
|
||||
id?: Changelog["id"],
|
||||
options?: {
|
||||
skipUserUpdate?: boolean;
|
||||
},
|
||||
) => {
|
||||
const newChangelog = id
|
||||
? await prisma.changelog.update({
|
||||
@@ -12,10 +15,13 @@ export const upsertChangelog = async (
|
||||
})
|
||||
: await prisma.$transaction(async (prisma) => {
|
||||
const createdChangelog = await prisma.changelog.create({ data: changelog });
|
||||
if (!options?.skipUserUpdate) {
|
||||
// Update all users to acknowledge the new changelog
|
||||
|
||||
await prisma.user.updateMany({
|
||||
data: { changelogAck: false },
|
||||
});
|
||||
await prisma.user.updateMany({
|
||||
data: { changelogAck: false },
|
||||
});
|
||||
}
|
||||
|
||||
return createdChangelog;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user