Donasi Info Admni
# feat - info admin - hapus admin ## Issue: Loading data belum untuk versi alfa
This commit is contained in:
@@ -9,6 +9,8 @@ import {
|
||||
Image,
|
||||
Paper,
|
||||
Stack,
|
||||
Text,
|
||||
TextInput,
|
||||
Textarea,
|
||||
} from "@mantine/core";
|
||||
import { IconCamera } from "@tabler/icons-react";
|
||||
@@ -38,6 +40,9 @@ export default function CreateCeritaPenggalangDonasi({
|
||||
const [create, setCreate] = useState({
|
||||
pembukaan: "",
|
||||
cerita: "",
|
||||
namaBank: "",
|
||||
rekening: ""
|
||||
|
||||
});
|
||||
const [temporary, setTemporary] = useState(dataTemporary);
|
||||
const [file, setFile] = useState<File | null>(null);
|
||||
@@ -58,6 +63,8 @@ export default function CreateCeritaPenggalangDonasi({
|
||||
donasiMaster_KategoriId: temporary.donasiMaster_KategoriId,
|
||||
donasiMaster_DurasiId: temporary.donasiMaster_DurasiId,
|
||||
authorId: userId,
|
||||
namaBank: create.namaBank,
|
||||
rekening: create.rekening,
|
||||
CeritaDonasi: {
|
||||
pembukaan: create.pembukaan,
|
||||
cerita: create.cerita,
|
||||
@@ -75,79 +82,118 @@ export default function CreateCeritaPenggalangDonasi({
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<Stack spacing={"md"} px={"md"}>
|
||||
<Stack spacing={50} px={"md"}>
|
||||
{/* <pre>{JSON.stringify(dataTempo, null, 2)}</pre> */}
|
||||
<ComponentDonasi_NotedBox informasi="Ceritakan dengan jujur & benar mengapa Penggalanagn Dana ini harus diadakan!" />
|
||||
<Textarea
|
||||
autosize
|
||||
minRows={2}
|
||||
maxRows={4}
|
||||
withAsterisk
|
||||
label="Pembukaan"
|
||||
placeholder="Pembuka dari isi cerita"
|
||||
onChange={(val) =>
|
||||
setCreate({
|
||||
...create,
|
||||
pembukaan: val.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
<Stack spacing={"xs"}>
|
||||
<AspectRatio ratio={16 / 9}>
|
||||
<Paper radius={"md"}>
|
||||
<Image
|
||||
alt="Foto"
|
||||
src={imageCerita ? imageCerita : "/aset/no-img.png"}
|
||||
/>
|
||||
</Paper>
|
||||
</AspectRatio>
|
||||
<Stack spacing={"sm"}>
|
||||
<ComponentDonasi_NotedBox informasi="Ceritakan dengan jujur & benar mengapa Penggalanagn Dana ini harus diadakan!" />
|
||||
|
||||
<Center>
|
||||
<FileButton
|
||||
onChange={async (files: any | null) => {
|
||||
try {
|
||||
const buffer = URL.createObjectURL(
|
||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||
);
|
||||
// console.log(buffer, "ini buffer");
|
||||
// console.log(files, " ini file");
|
||||
setImageCerita(buffer);
|
||||
setFile(files);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}}
|
||||
accept="image/png,image/jpeg"
|
||||
>
|
||||
{(props) => (
|
||||
<Button
|
||||
{...props}
|
||||
radius={"xl"}
|
||||
variant="outline"
|
||||
w={150}
|
||||
leftIcon={<IconCamera />}
|
||||
>
|
||||
Upload
|
||||
</Button>
|
||||
)}
|
||||
</FileButton>
|
||||
</Center>
|
||||
<Textarea
|
||||
autosize
|
||||
minRows={2}
|
||||
maxRows={4}
|
||||
withAsterisk
|
||||
label="Pembukaan"
|
||||
placeholder="Pembuka dari isi cerita"
|
||||
onChange={(val) =>
|
||||
setCreate({
|
||||
...create,
|
||||
pembukaan: val.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
|
||||
<Textarea
|
||||
autosize
|
||||
minRows={2}
|
||||
maxRows={10}
|
||||
withAsterisk
|
||||
label="Cerita"
|
||||
placeholder="Ceritakan alasan mengapa harus membuat Penggalangan Dana"
|
||||
onChange={(val) =>
|
||||
setCreate({
|
||||
...create,
|
||||
cerita: val.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
|
||||
<Stack spacing={"xs"}>
|
||||
<Center>
|
||||
<FileButton
|
||||
onChange={async (files: any | null) => {
|
||||
try {
|
||||
const buffer = URL.createObjectURL(
|
||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||
);
|
||||
// console.log(buffer, "ini buffer");
|
||||
// console.log(files, " ini file");
|
||||
setImageCerita(buffer);
|
||||
setFile(files);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}}
|
||||
accept="image/png,image/jpeg"
|
||||
>
|
||||
{(props) => (
|
||||
<Button
|
||||
compact
|
||||
{...props}
|
||||
radius={"xl"}
|
||||
variant="outline"
|
||||
w={150}
|
||||
leftIcon={<IconCamera />}
|
||||
>
|
||||
Upload
|
||||
</Button>
|
||||
)}
|
||||
</FileButton>
|
||||
</Center>
|
||||
|
||||
{imageCerita ? (
|
||||
<AspectRatio ratio={16 / 9}>
|
||||
<Paper radius={"md"}>
|
||||
<Image
|
||||
alt="Foto"
|
||||
src={imageCerita ? imageCerita : "/aset/no-img.png"}
|
||||
/>
|
||||
</Paper>
|
||||
</AspectRatio>
|
||||
) : (
|
||||
<Center>
|
||||
<Text fs={"italic"} fz={10}>
|
||||
Upload poster atau gambar penggalangan !
|
||||
</Text>
|
||||
</Center>
|
||||
)}
|
||||
</Stack>
|
||||
</Stack>
|
||||
<Textarea
|
||||
autosize
|
||||
minRows={2}
|
||||
maxRows={10}
|
||||
withAsterisk
|
||||
label="Cerita"
|
||||
placeholder="Ceritakan alasan mengapa harus membuat Penggalangan Dana"
|
||||
onChange={(val) =>
|
||||
setCreate({
|
||||
...create,
|
||||
cerita: val.target.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
|
||||
<Stack spacing={"sm"}>
|
||||
<ComponentDonasi_NotedBox informasi="Lengkapi nama bank dan rekening di bawah untuk mempermudah admin jika penggalangan dana ini telah di publish!" />
|
||||
<TextInput
|
||||
withAsterisk
|
||||
placeholder="Contoh: BNI, BCA, MANDIRI, DLL"
|
||||
label="Nama Bank"
|
||||
onChange={(val) => {
|
||||
setCreate({
|
||||
...create,
|
||||
namaBank: _.upperCase(val.target.value)
|
||||
})
|
||||
}}
|
||||
/>
|
||||
<TextInput
|
||||
withAsterisk
|
||||
placeholder="Maskuan nomor rekening"
|
||||
label="Nomor rekening"
|
||||
onChange={(val) => {
|
||||
setCreate({
|
||||
...create,
|
||||
rekening: val.target.value
|
||||
})
|
||||
}}
|
||||
/>
|
||||
</Stack>
|
||||
<Button w={"100%"} radius={"xl"} onClick={() => onCreate()}>
|
||||
Simpan
|
||||
</Button>
|
||||
|
||||
@@ -91,46 +91,7 @@ export default function CreateDonasi({
|
||||
})
|
||||
}
|
||||
/>
|
||||
<Stack>
|
||||
<AspectRatio ratio={16 / 9}>
|
||||
<Paper radius={"md"}>
|
||||
<Image
|
||||
alt="Foto"
|
||||
src={imageDonasi ? imageDonasi : "/aset/no-img.png"}
|
||||
/>
|
||||
</Paper>
|
||||
</AspectRatio>
|
||||
<Center>
|
||||
<FileButton
|
||||
onChange={async (files: any | null) => {
|
||||
try {
|
||||
const buffer = URL.createObjectURL(
|
||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||
);
|
||||
// console.log(buffer, "ini buffer");
|
||||
// console.log(files, " ini file");
|
||||
setImageDonasi(buffer);
|
||||
setFile(files);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}}
|
||||
accept="image/png,image/jpeg"
|
||||
>
|
||||
{(props) => (
|
||||
<Button
|
||||
{...props}
|
||||
radius={"xl"}
|
||||
variant="outline"
|
||||
w={150}
|
||||
leftIcon={<IconCamera />}
|
||||
>
|
||||
Upload
|
||||
</Button>
|
||||
)}
|
||||
</FileButton>
|
||||
</Center>
|
||||
</Stack>
|
||||
|
||||
<Stack>
|
||||
<TextInput
|
||||
withAsterisk
|
||||
@@ -160,6 +121,56 @@ export default function CreateDonasi({
|
||||
onChange={(val: string) => setCreate({ ...create, durasiId: val })}
|
||||
/>
|
||||
</Stack>
|
||||
|
||||
<Stack>
|
||||
<Center>
|
||||
<FileButton
|
||||
onChange={async (files: any | null) => {
|
||||
try {
|
||||
const buffer = URL.createObjectURL(
|
||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||
);
|
||||
// console.log(buffer, "ini buffer");
|
||||
// console.log(files, " ini file");
|
||||
setImageDonasi(buffer);
|
||||
setFile(files);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}}
|
||||
accept="image/png,image/jpeg"
|
||||
>
|
||||
{(props) => (
|
||||
<Button
|
||||
compact
|
||||
{...props}
|
||||
radius={"xl"}
|
||||
variant="outline"
|
||||
w={150}
|
||||
leftIcon={<IconCamera />}
|
||||
>
|
||||
Upload
|
||||
</Button>
|
||||
)}
|
||||
</FileButton>
|
||||
</Center>
|
||||
{imageDonasi ? (
|
||||
<AspectRatio ratio={16 / 9}>
|
||||
<Paper radius={"md"}>
|
||||
<Image
|
||||
alt="Foto"
|
||||
src={imageDonasi ? imageDonasi : "/aset/no-img.png"}
|
||||
/>
|
||||
</Paper>
|
||||
</AspectRatio>
|
||||
) : (
|
||||
<Center>
|
||||
<Text fs={"italic"} fz={10}>
|
||||
Upload poster atau gambar penggalangan !
|
||||
</Text>
|
||||
</Center>
|
||||
)}
|
||||
</Stack>
|
||||
<Button my={"lg"} radius={"xl"} onClick={() => onCreate()}>
|
||||
Selanjutnya
|
||||
</Button>
|
||||
|
||||
@@ -21,6 +21,8 @@ import { NotifBerhasil } from "../../component/notifikasi/notif_berhasil";
|
||||
import { NotifGagal } from "../../component/notifikasi/notif_gagal";
|
||||
import _ from "lodash";
|
||||
import { NotifPeringatan } from "../../component/notifikasi/notif_peringatan";
|
||||
import ComponentDonasi_NotedBox from "../../component/noted_box";
|
||||
import { Donasi_funCreateNotif } from "../../fun/create/fun_create_notif";
|
||||
|
||||
export default function Donasi_CreateKabar({ donasiId }: { donasiId: string }) {
|
||||
const router = useRouter();
|
||||
@@ -33,6 +35,8 @@ export default function Donasi_CreateKabar({ donasiId }: { donasiId: string }) {
|
||||
return (
|
||||
<>
|
||||
<Stack>
|
||||
<ComponentDonasi_NotedBox informasi="Gambar tidak wajib di isi ! Hanya upload jika di butuhkan." />
|
||||
|
||||
<TextInput
|
||||
label="Judul"
|
||||
withAsterisk
|
||||
@@ -88,6 +92,7 @@ export default function Donasi_CreateKabar({ donasiId }: { donasiId: string }) {
|
||||
variant="outline"
|
||||
w={150}
|
||||
leftIcon={<IconCamera />}
|
||||
compact
|
||||
>
|
||||
Upload
|
||||
</Button>
|
||||
@@ -125,15 +130,19 @@ async function onSave(
|
||||
};
|
||||
|
||||
if (_.values(body).includes("")) return NotifPeringatan("Lengkapi Data");
|
||||
if (!file) return NotifPeringatan("Lengkapi Gambar");
|
||||
// if (!file) return NotifPeringatan("Lengkapi Gambar");
|
||||
|
||||
const gambar = new FormData();
|
||||
gambar.append("file", file as any);
|
||||
|
||||
await Donasi_funCreateKabar(body as any, gambar).then((res) => {
|
||||
await Donasi_funCreateKabar(body as any, gambar).then(async (res) => {
|
||||
if (res.status === 200) {
|
||||
NotifBerhasil(res.message);
|
||||
router.back()
|
||||
await Donasi_funCreateNotif(body.donasiId, res.kabarId as any).then((val) => {
|
||||
if (val.status === 200) {
|
||||
NotifBerhasil(res.message);
|
||||
router.back();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
NotifGagal(res.message);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import { AppShell } from "@mantine/core";
|
||||
import React from "react";
|
||||
import HeaderTamplateDonasi from "../../component/header_tamplate";
|
||||
import ComponentDonasi_HeaderTamplate from "../../component/header_tamplate";
|
||||
|
||||
export default function LayoutDonasi_CreateKabar({
|
||||
children,
|
||||
@@ -11,7 +11,7 @@ export default function LayoutDonasi_CreateKabar({
|
||||
}) {
|
||||
return (
|
||||
<>
|
||||
<AppShell header={<HeaderTamplateDonasi title="Buat Kabar" />}>
|
||||
<AppShell header={<ComponentDonasi_HeaderTamplate title="Buat Kabar" />}>
|
||||
{children}
|
||||
</AppShell>
|
||||
</>
|
||||
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
import { AppShell } from "@mantine/core"
|
||||
import React from "react"
|
||||
import HeaderTamplateDonasi from "../component/header_tamplate"
|
||||
import ComponentDonasi_HeaderTamplate from "../component/header_tamplate"
|
||||
|
||||
export default function LayoutCreateDonasi({children}: {children: React.ReactNode}){
|
||||
return<>
|
||||
<AppShell header={<HeaderTamplateDonasi title="Buat Donasi"/>}>
|
||||
<AppShell header={<ComponentDonasi_HeaderTamplate title="Buat Donasi"/>}>
|
||||
{children}
|
||||
</AppShell>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user