feat: accounts api done

Signed-off-by: Ameya Shenoy <shenoy.ameya@gmail.com>
This commit is contained in:
Ameya Shenoy 2023-03-22 17:51:22 +05:30
parent 327e49ce08
commit 981de5b604
Signed by: codingcoffee
GPG key ID: EEC8EA855D61CEEC
2 changed files with 147 additions and 83 deletions

View file

@ -1,96 +1,134 @@
"use client"
import styles from './centerCol.module.css'
import React from 'react'
import Dashboard from './Dashboard'
import BankAccount from './BankAccount'
import React from 'react'
import useSWR from 'swr'
export default function CenterCol() {
const bankDetails = {
banks: [{
bankName: "SBI",
bankFullName: "State Bank of India",
bankLogoSrc: "/sbi.svg",
bankAccountBalance: "27,932",
infoLines: [{
title: "Account Number",
value: "34536896852",
}, {
title: "IFSC Code",
value: "SBIN0006586",
}, {
title: "Swift BIC",
value: "6895206BB",
}, {
title: "Holder's Name",
value: "Nishant Verma",
}]
}, {
bankName: "HDFC",
bankFullName: "HDFC Bank",
bankLogoSrc: "/hdfc.svg",
bankAccountBalance: "2,58,630",
infoLines: [{
title: "Account Number",
value: "92531805286",
}, {
title: "IFSC Code",
value: "HDFC0002233",
}, {
title: "Swift BIC",
value: "HDFCINBBBNG",
}, {
title: "Holder's Name",
value: "Nishant Verma",
}]
}, {
bankName: "Axis",
bankFullName: "Axis Bank",
bankLogoSrc: "/axis.svg",
bankAccountBalance: "55,410",
infoLines: [{
title: "Account Number",
value: "34536896852",
}, {
title: "IFSC Code",
value: "SBIN0006586",
}, {
title: "Swift BIC",
value: "6895206BB",
}, {
title: "Holder's Name",
value: "Nishant Verma",
}]
}, {
bankName: "ICICI",
bankFullName: "ICICI Bank",
bankLogoSrc: "/icici.svg",
bankAccountBalance: "7,932",
infoLines: [{
title: "Account Number",
value: "92531805286",
}, {
title: "IFSC Code",
value: "HDFC0002233",
}, {
title: "Swift BIC",
value: "HDFCINBBBNG",
}, {
title: "Holder's Name",
value: "Nishant Verma",
}]
}]
}
const fetcher = (...args) => fetch(...args).then((res) => res.json())
const { data, error } = useSWR(`http://localhost:8000/api/v1/accounts/`, fetcher)
if (error) return <div>Error: Failed to load</div>
if (!data) return <div>Loading...</div>
const bankDetails = data.results
// const bankDetails = {
// banks: [{
// bankName: "SBI",
// bankFullName: "State Bank of India",
// bankLogoSrc: "/sbi.svg",
// bankAccountBalance: "27,932",
// infoLines: [{
// title: "Account Number",
// value: "34536896852",
// }, {
// title: "IFSC Code",
// value: "SBIN0006586",
// }, {
// title: "Swift BIC",
// value: "6895206BB",
// }, {
// title: "Holder's Name",
// value: "Nishant Verma",
// }]
// }, {
// bankName: "HDFC",
// bankFullName: "HDFC Bank",
// bankLogoSrc: "/hdfc.svg",
// bankAccountBalance: "2,58,630",
// infoLines: [{
// title: "Account Number",
// value: "92531805286",
// }, {
// title: "IFSC Code",
// value: "HDFC0002233",
// }, {
// title: "Swift BIC",
// value: "HDFCINBBBNG",
// }, {
// title: "Holder's Name",
// value: "Nishant Verma",
// }]
// }, {
// bankName: "Axis",
// bankFullName: "Axis Bank",
// bankLogoSrc: "/axis.svg",
// bankAccountBalance: "55,410",
// infoLines: [{
// title: "Account Number",
// value: "34536896852",
// }, {
// title: "IFSC Code",
// value: "SBIN0006586",
// }, {
// title: "Swift BIC",
// value: "6895206BB",
// }, {
// title: "Holder's Name",
// value: "Nishant Verma",
// }]
// }, {
// bankName: "ICICI",
// bankFullName: "ICICI Bank",
// bankLogoSrc: "/icici.svg",
// bankAccountBalance: "7,932",
// infoLines: [{
// title: "Account Number",
// value: "92531805286",
// }, {
// title: "IFSC Code",
// value: "HDFC0002233",
// }, {
// title: "Swift BIC",
// value: "HDFCINBBBNG",
// }, {
// title: "Holder's Name",
// value: "Nishant Verma",
// }]
// }]
// }
const bankAccounts = []
bankDetails.banks.forEach((bank) => {
const infoTitles = [
{
"title": "Account Number",
"key": "account_number",
},
{
"title": "IFSC Code",
"key": "ifsc_code",
},
{
"title": "Swift BIC",
"key": "swift_bic",
},
{
"title": "Holder's Name",
"key": "holders_name",
},
]
bankDetails.forEach((bank) => {
const infoLines = []
infoTitles.forEach((option) => {
infoLines.push({
"title": option.title,
"value": bank[option.key],
})
})
bankAccounts.push(
<BankAccount
key={bank.bankName}
bankLogoSrc={bank.bankLogoSrc}
bankName={bank.bankName}
bankFullName={bank.bankFullName}
bankAccountBalance={bank.bankAccountBalance}
infoLines={bank.infoLines}
key={bank.bank.name}
bankLogoSrc={`http://localhost:8000/media/${bank.bank.logo}`}
bankName={bank.bank.name}
bankFullName={bank.bank.name}
bankAccountBalance={bank.balance}
infoLines={infoLines}
/>
)
})

View file

@ -1,8 +1,34 @@
/** @type {import('next').NextConfig} */
const nextConfig = {
icons: {
icon: '/favicon.ico',
},
images: {
remotePatterns: [
{
protocol: 'http',
hostname: 'localhost:8000',
port: '',
pathname: '/**',
},
{
protocol: 'https',
hostname: 'foldbank.codingcoffee.me',
port: '',
pathname: '/**',
},
],
},
experimental: {
appDir: true,
},
typescript: {
// !! WARN !!
// Dangerously allow production builds to successfully complete even if
// your project has type errors.
// !! WARN !!
ignoreBuildErrors: true,
},
}
module.exports = nextConfig