Pembelian Saham

# feat:
- Fitur pembelian saham
- Status transaksi
- Table transaksi
- Table nama bank
### No Issue
This commit is contained in:
2023-11-21 10:08:46 +08:00
parent 19e870f8cd
commit 812f47fbf9
155 changed files with 208 additions and 359411 deletions

View File

@@ -28,29 +28,7 @@ import { gs_TransferValue } from "../g_state";
import getNorekInvestasi from "../fun/get_norek";
import _ from "lodash";
import funCreateTransaksiInvestasi from "../fun/fun_create_transaksi";
// const listNoRekening = [
// {
// id: 1,
// name: "BRI",
// norek: "9065456754325643",
// },
// {
// id: 2,
// name: "BCA",
// norek: "2304235678854332",
// },
// {
// id: 3,
// name: "BNI",
// norek: "1104786754324564",
// },
// {
// id: 4,
// name: "BSI",
// norek: "7076543567898976",
// },
// ];
import { myConsole } from "@/app/fun/my_console";
export default function MetodeTransferInvestasi({
dataInvestasi,
@@ -61,49 +39,45 @@ export default function MetodeTransferInvestasi({
namaBank: Model_Nama_Bank[];
authorId: string;
}) {
const [total, setTotal] = useState<any | null>(null);
const [investasi, setInvestasi] = useState(dataInvestasi);
const [bank, setBank] = useState(namaBank);
const [pilihBank, setPilihBank] = useState("");
const [pilihBank, setPilihBank] = useState<string | null>(null);
const router = useRouter();
const [transferValue, setTransferValue] = useAtom(gs_TransferValue);
const [transaksi, setTransaksi] = useState<MODEL_Transaksi_Investasi>();
async function onSubmit() {
// Cek Nomor Rekening
const getNorek = await getNorekInvestasi(pilihBank).then((res) => {
// Create Transaksi
await funCreateTransaksiInvestasi(
transferValue as any,
investasi.id,
authorId
).then(async (res) => {
if (res.status === 201) {
toast(res.message);
router.push(RouterInvestasi.transfer + `${res.res?.id}`);
} else {
toast(res.message);
}
});
}
async function onSelect(id: string) {
await getNorekInvestasi(id).then((res) => {
if (res.status === 200) {
setTransferValue({
...transferValue,
namaBank: res.res?.name as any,
nomorRekening: res.res?.norek as any,
});
return res.status;
} else {
toast(res.message);
}
});
if (getNorek === 200) {
// Create Transaksi
await funCreateTransaksiInvestasi(
transferValue as any,
investasi.id,
authorId
).then(async (res) => {
if (res.status === 201) {
toast(res.message);
router.push(RouterInvestasi.transfer + `${res.res?.id}`);
} else {
toast(res.message);
}
});
}
}
return (
<>
{/* <pre>{JSON.stringify(transferValue, null, 2)}</pre> */}
<pre>{JSON.stringify(transferValue, null, 2)}</pre>
{/* Box judul */}
<Paper bg={"gray"} p={"xs"} shadow="lg" mb={"md"}>
<Title order={5}>{investasi.title}</Title>
@@ -117,7 +91,11 @@ export default function MetodeTransferInvestasi({
description="Pilih salah satu bank"
withAsterisk
my={"md"}
onChange={setPilihBank}
onChange={(val) => {
setPilihBank(val);
onSelect(val);
}}
value={"" + pilihBank}
>
<Flex direction={"column"} gap={"lg"} mt="xs">
{bank.map((e) => (
@@ -127,10 +105,11 @@ export default function MetodeTransferInvestasi({
))}
</Flex>
</Radio.Group>
<Center>
{pilihBank === "" ? (
{pilihBank === null ? (
<Button my={"md"} w={300} disabled radius={50}>
Pilih
Pilih Bank
</Button>
) : (
<Button