Hold persiapan persentase pak fahmi
- Sudah bisa create - Sudah bisa join proyek - Tambahan untuk mengisi form jika ingin join ### No issue
This commit is contained in:
@@ -1,33 +1,73 @@
|
||||
"use client"
|
||||
"use client";
|
||||
|
||||
import { Stack, TextInput, Select, Textarea, Button } from "@mantine/core";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import React, { useState } from "react";
|
||||
import {
|
||||
MODEL_COLLABORATION,
|
||||
MODEL_COLLABORATION_MASTER,
|
||||
} from "../model/interface";
|
||||
import colab_funEditById from "../fun/edit/fun_edit_by_id";
|
||||
import { ComponentGlobal_NotifikasiGagal } from "@/app_modules/component_global/notif_global/notifikasi_gagal";
|
||||
import { ComponentGlobal_NotifikasiBerhasil } from "@/app_modules/component_global/notif_global/notifikasi_berhasil";
|
||||
|
||||
export default function Colab_Edit() {
|
||||
export default function Colab_Edit({
|
||||
selectedData,
|
||||
listIndustri,
|
||||
}: {
|
||||
selectedData: MODEL_COLLABORATION;
|
||||
listIndustri: MODEL_COLLABORATION_MASTER[];
|
||||
}) {
|
||||
const [value, setValue] = useState(selectedData);
|
||||
return (
|
||||
<>
|
||||
<Stack px={"sm"}>
|
||||
{/* <pre>{JSON.stringify(value, null, 2)}</pre> */}
|
||||
<TextInput
|
||||
label="Judul"
|
||||
withAsterisk
|
||||
placeholder="Masukan judul proyek"
|
||||
value={value.title}
|
||||
onChange={(val) =>
|
||||
setValue({
|
||||
...value,
|
||||
title: val.currentTarget.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
|
||||
<TextInput
|
||||
label="Lokasi"
|
||||
withAsterisk
|
||||
placeholder="Masukan lokasi proyek"
|
||||
value={value.lokasi}
|
||||
onChange={(val) =>
|
||||
setValue({
|
||||
...value,
|
||||
lokasi: val.currentTarget.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
|
||||
<Select
|
||||
placeholder="Pilih kategori industri"
|
||||
label="Pilih Industri"
|
||||
withAsterisk
|
||||
data={[
|
||||
{ value: "1", label: "Teknologi" },
|
||||
{ value: "2", label: "Tambang Batu Bara" },
|
||||
]}
|
||||
value={value?.ProjectCollaborationMaster_Industri.id}
|
||||
data={listIndustri.map((e) => ({
|
||||
value: e.id,
|
||||
label: e.name,
|
||||
}))}
|
||||
onChange={
|
||||
(val) =>
|
||||
setValue({
|
||||
...(value as any),
|
||||
ProjectCollaborationMaster_Industri: {
|
||||
id: val as any,
|
||||
},
|
||||
})
|
||||
// console.log(val)
|
||||
}
|
||||
/>
|
||||
|
||||
<Textarea
|
||||
@@ -35,6 +75,13 @@ export default function Colab_Edit() {
|
||||
placeholder="Masukan tujuan proyek"
|
||||
withAsterisk
|
||||
minRows={5}
|
||||
value={value.purpose}
|
||||
onChange={(val) =>
|
||||
setValue({
|
||||
...value,
|
||||
purpose: val.currentTarget.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
|
||||
<Textarea
|
||||
@@ -42,20 +89,34 @@ export default function Colab_Edit() {
|
||||
placeholder="Masukan keuntungan dalam proyek"
|
||||
withAsterisk
|
||||
minRows={5}
|
||||
value={value.benefit}
|
||||
onChange={(val) =>
|
||||
setValue({
|
||||
...value,
|
||||
benefit: val.currentTarget.value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
<ButtonAction />
|
||||
<ButtonAction value={value as any} />
|
||||
</Stack>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function ButtonAction() {
|
||||
function ButtonAction({ value }: { value: React.ReactNode }) {
|
||||
const router = useRouter();
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
async function onUpdate() {
|
||||
setLoading(true);
|
||||
router.back();
|
||||
await colab_funEditById(value as any).then((res) => {
|
||||
if (res.status === 200) {
|
||||
setLoading(true);
|
||||
router.back();
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiGagal(res.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user