QC Investasi
# fix Tampilan admin investasi Tampilan admin donasi ## No issuee
This commit is contained in:
@@ -22,6 +22,11 @@ import { NotifPeringatan } from "../../component/notifikasi/notif_peringatan";
|
||||
import _ from "lodash";
|
||||
import { Donasi_funUpdateCerita } from "../../fun/update/fun_update_cerita_donasi";
|
||||
import { NotifBerhasil } from "../../component/notifikasi/notif_berhasil";
|
||||
import {
|
||||
ComponentGlobal_WarningMaxUpload,
|
||||
maksimalUploadFile,
|
||||
} from "@/app_modules/component_global/variabel_global";
|
||||
import ComponentGlobal_ErrorInput from "@/app_modules/component_global/error_input";
|
||||
|
||||
export default function EditCeritaPenggalangDonasi({
|
||||
dataCerita,
|
||||
@@ -29,6 +34,8 @@ export default function EditCeritaPenggalangDonasi({
|
||||
dataCerita: MODEL_CERITA_DONASI;
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
|
||||
const [tabsPostingDonasi, setTabsPostingDonasi] = useAtom(
|
||||
gs_donasi_tabs_posting
|
||||
);
|
||||
@@ -48,6 +55,13 @@ export default function EditCeritaPenggalangDonasi({
|
||||
label="Pembukaan"
|
||||
placeholder="Pembuka dari isi cerita"
|
||||
value={value.pembukaan}
|
||||
error={
|
||||
value.pembukaan === "" ? (
|
||||
<ComponentGlobal_ErrorInput text="Masukan pembukaan cerita" />
|
||||
) : (
|
||||
""
|
||||
)
|
||||
}
|
||||
onChange={(val) =>
|
||||
setValue({
|
||||
...value,
|
||||
@@ -64,8 +78,13 @@ export default function EditCeritaPenggalangDonasi({
|
||||
const buffer = URL.createObjectURL(
|
||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||
);
|
||||
setUpdateImage(buffer);
|
||||
setFile(files);
|
||||
|
||||
if (files.size > maksimalUploadFile) {
|
||||
ComponentGlobal_WarningMaxUpload({});
|
||||
} else {
|
||||
setUpdateImage(buffer);
|
||||
setFile(files);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
@@ -74,6 +93,7 @@ export default function EditCeritaPenggalangDonasi({
|
||||
>
|
||||
{(props) => (
|
||||
<Button
|
||||
compact
|
||||
{...props}
|
||||
radius={"xl"}
|
||||
variant="outline"
|
||||
@@ -108,6 +128,13 @@ export default function EditCeritaPenggalangDonasi({
|
||||
label="Cerita"
|
||||
placeholder="Ceritakan alasan mengapa harus membuat Penggalangan Dana"
|
||||
value={value.cerita}
|
||||
error={
|
||||
value.cerita === "" ? (
|
||||
<ComponentGlobal_ErrorInput text="Masukan pembukaan cerita" />
|
||||
) : (
|
||||
""
|
||||
)
|
||||
}
|
||||
onChange={(val) =>
|
||||
setValue({
|
||||
...value,
|
||||
@@ -117,6 +144,14 @@ export default function EditCeritaPenggalangDonasi({
|
||||
/>
|
||||
|
||||
<Button
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
}}
|
||||
loaderPosition="center"
|
||||
loading={isLoading ? true : false}
|
||||
disabled={
|
||||
value.cerita === "" || value.pembukaan === "" ? true : false
|
||||
}
|
||||
w={"100%"}
|
||||
radius={"xl"}
|
||||
onClick={() => onUpdate(router, value, file as any)}
|
||||
@@ -139,14 +174,14 @@ async function onUpdate(
|
||||
id: value.id,
|
||||
pembukaan: value.pembukaan,
|
||||
cerita: value.cerita,
|
||||
imagesId: value.imageCeritaDonasi.id
|
||||
imagesId: value.imageCeritaDonasi.id,
|
||||
};
|
||||
|
||||
const gambar = new FormData();
|
||||
gambar.append("file", file as any);
|
||||
|
||||
if (_.values(body).includes("")) return NotifPeringatan("Lengkapi Data");
|
||||
await Donasi_funUpdateCerita(body as any,gambar).then((res) => {
|
||||
await Donasi_funUpdateCerita(body as any, gambar).then((res) => {
|
||||
if (res.status === 200) {
|
||||
NotifBerhasil(res.message);
|
||||
router.back();
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
Modal,
|
||||
Group,
|
||||
Title,
|
||||
Text,
|
||||
} from "@mantine/core";
|
||||
import { IconCamera } from "@tabler/icons-react";
|
||||
import { useAtom } from "jotai";
|
||||
@@ -28,6 +29,11 @@ import { NotifBerhasil } from "../../component/notifikasi/notif_berhasil";
|
||||
import { NotifPeringatan } from "../../component/notifikasi/notif_peringatan";
|
||||
import _ from "lodash";
|
||||
import { Donasi_getOneById } from "../../fun/get/get_one_donasi_by_id";
|
||||
import {
|
||||
ComponentGlobal_WarningMaxUpload,
|
||||
maksimalUploadFile,
|
||||
} from "@/app_modules/component_global/variabel_global";
|
||||
import ComponentGlobal_ErrorInput from "@/app_modules/component_global/error_input";
|
||||
|
||||
export default function EditDonasi({
|
||||
dataDonasi,
|
||||
@@ -39,6 +45,8 @@ export default function EditDonasi({
|
||||
masterDurasi: MODEL_DONASI_ALL_MASTER[];
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
|
||||
const [tabsPostingDonasi, setTabsPostingDonasi] = useAtom(
|
||||
gs_donasi_tabs_posting
|
||||
);
|
||||
@@ -91,10 +99,13 @@ export default function EditDonasi({
|
||||
const buffer = URL.createObjectURL(
|
||||
new Blob([new Uint8Array(await files.arrayBuffer())])
|
||||
);
|
||||
// console.log(buffer, "ini buffer");
|
||||
// console.log(files, " ini file");
|
||||
setUpdateImage(buffer);
|
||||
setFile(files);
|
||||
|
||||
if (files.size > maksimalUploadFile) {
|
||||
ComponentGlobal_WarningMaxUpload({});
|
||||
} else {
|
||||
setUpdateImage(buffer);
|
||||
setFile(files);
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
@@ -103,11 +114,12 @@ export default function EditDonasi({
|
||||
>
|
||||
{(props) => (
|
||||
<Button
|
||||
compact
|
||||
{...props}
|
||||
radius={"xl"}
|
||||
variant="outline"
|
||||
w={150}
|
||||
leftIcon={<IconCamera />}
|
||||
w={150}
|
||||
>
|
||||
Upload
|
||||
</Button>
|
||||
@@ -121,6 +133,14 @@ export default function EditDonasi({
|
||||
label="Judul Donasi"
|
||||
placeholder="Contoh: Renovasi Masjid pada kampung, dll"
|
||||
value={value.title}
|
||||
maxLength={100}
|
||||
error={
|
||||
value.title === "" ? (
|
||||
<ComponentGlobal_ErrorInput text="Masukan judul" />
|
||||
) : (
|
||||
""
|
||||
)
|
||||
}
|
||||
onChange={(val) =>
|
||||
setValue({
|
||||
...value,
|
||||
@@ -129,17 +149,39 @@ export default function EditDonasi({
|
||||
}
|
||||
/>
|
||||
<TextInput
|
||||
type="number"
|
||||
icon={<Text fw={"bold"}>Rp.</Text>}
|
||||
min={0}
|
||||
withAsterisk
|
||||
label="Target Dana"
|
||||
placeholder="Masukan nominal angka"
|
||||
value={+value.target ? +value.target : ""}
|
||||
onChange={(val) =>
|
||||
placeholder="0"
|
||||
value={value.target}
|
||||
error={
|
||||
value.target === "" || value.target === "0" ? (
|
||||
<ComponentGlobal_ErrorInput text="Masukan target dana" />
|
||||
) : (
|
||||
""
|
||||
)
|
||||
}
|
||||
onChange={(val) => {
|
||||
const match = val.currentTarget.value
|
||||
.replace(/\./g, "")
|
||||
.match(/^[0-9]+$/);
|
||||
|
||||
if (val.currentTarget.value === "")
|
||||
return setValue({
|
||||
...value,
|
||||
target: 0 + "",
|
||||
});
|
||||
if (!match?.[0]) return null;
|
||||
|
||||
const nilai = val.currentTarget.value.replace(/\./g, "");
|
||||
const target = Intl.NumberFormat("id-ID").format(+nilai);
|
||||
|
||||
setValue({
|
||||
...value,
|
||||
target: val.target.value,
|
||||
})
|
||||
}
|
||||
target: target,
|
||||
});
|
||||
}}
|
||||
/>
|
||||
<Select
|
||||
label="Durasi"
|
||||
@@ -161,6 +203,12 @@ export default function EditDonasi({
|
||||
/>
|
||||
</Stack>
|
||||
<Button
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
}}
|
||||
disabled={value.title === "" || value.target === "0" ? true : false}
|
||||
loaderPosition="center"
|
||||
loading={isLoading ? true : false}
|
||||
my={"lg"}
|
||||
radius={"xl"}
|
||||
onClick={() => {
|
||||
@@ -169,29 +217,11 @@ export default function EditDonasi({
|
||||
>
|
||||
Update
|
||||
</Button>
|
||||
{/* <Modal opened={opened} onClose={close} withCloseButton={false} centered >
|
||||
<ModalEdit />
|
||||
</Modal> */}
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
// function ModalEdit() {
|
||||
// return (
|
||||
// <>
|
||||
// <Stack>
|
||||
// <Title order={6}>Anda yakin menyimpan data ini ?</Title>
|
||||
// <Group position="center">
|
||||
// <Button variant="outline" >Batal</Button>
|
||||
// <Button>Simpan</Button>
|
||||
// </Group>
|
||||
// </Stack>
|
||||
|
||||
// </>
|
||||
// );
|
||||
// }
|
||||
|
||||
async function onUpdate(value: MODEL_DONASI, file: FormData, router: any) {
|
||||
const body = {
|
||||
id: value.id,
|
||||
|
||||
@@ -9,6 +9,7 @@ import { AppRouterInstance } from "next/dist/shared/lib/app-router-context.share
|
||||
import { Donasi_funUpdateRekening } from "../../fun/update/fun_update_rekening";
|
||||
import { NotifBerhasil } from "../../component/notifikasi/notif_berhasil";
|
||||
import { NotifGagal } from "../../component/notifikasi/notif_gagal";
|
||||
import ComponentGlobal_ErrorInput from "@/app_modules/component_global/error_input";
|
||||
|
||||
export default function Donasi_EditRekening({
|
||||
dataDonasi,
|
||||
@@ -17,6 +18,7 @@ export default function Donasi_EditRekening({
|
||||
}) {
|
||||
const router = useRouter();
|
||||
const [donasi, setDonasi] = useState(dataDonasi);
|
||||
const [isLoading, setLoading] = useState(false);
|
||||
|
||||
return (
|
||||
<>
|
||||
@@ -27,6 +29,13 @@ export default function Donasi_EditRekening({
|
||||
label="Nama Bank"
|
||||
placeholder="Masukan Nama Bank"
|
||||
value={donasi.namaBank}
|
||||
error={
|
||||
donasi.namaBank === "" ? (
|
||||
<ComponentGlobal_ErrorInput text="Masukan nama bank" />
|
||||
) : (
|
||||
""
|
||||
)
|
||||
}
|
||||
onChange={(val) =>
|
||||
setDonasi({
|
||||
...donasi,
|
||||
@@ -36,18 +45,37 @@ export default function Donasi_EditRekening({
|
||||
/>
|
||||
<TextInput
|
||||
withAsterisk
|
||||
type="number"
|
||||
label="Nomor Rekening"
|
||||
placeholder="Masukkan Nomor Rekening"
|
||||
value={donasi.rekening}
|
||||
error={
|
||||
donasi.rekening === "" ? (
|
||||
<ComponentGlobal_ErrorInput text="Masukan nomor rekening" />
|
||||
) : (
|
||||
""
|
||||
)
|
||||
}
|
||||
onChange={(val) =>
|
||||
setDonasi({
|
||||
...donasi,
|
||||
rekening: val.target.value,
|
||||
rekening: val.currentTarget.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
</Stack>
|
||||
<Button radius={"xl"} onClick={() => onUpdate(router, donasi)}>
|
||||
<Button
|
||||
style={{
|
||||
transition: "0.5s",
|
||||
}}
|
||||
loaderPosition="center"
|
||||
loading={isLoading ? true : false}
|
||||
disabled={
|
||||
donasi.namaBank === "" || donasi.rekening === "" ? true : false
|
||||
}
|
||||
radius={"xl"}
|
||||
onClick={() => onUpdate(router, donasi, setLoading)}
|
||||
>
|
||||
Update
|
||||
</Button>
|
||||
</Stack>
|
||||
@@ -55,9 +83,14 @@ export default function Donasi_EditRekening({
|
||||
);
|
||||
}
|
||||
|
||||
async function onUpdate(router: AppRouterInstance, donasi: MODEL_DONASI) {
|
||||
async function onUpdate(
|
||||
router: AppRouterInstance,
|
||||
donasi: MODEL_DONASI,
|
||||
setLoading: any
|
||||
) {
|
||||
await Donasi_funUpdateRekening(donasi).then((res) => {
|
||||
if (res.status === 200) {
|
||||
setLoading(true);
|
||||
router.back();
|
||||
NotifBerhasil(res.message);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user