Skip to content
This repository has been archived by the owner on Jan 21, 2023. It is now read-only.

Commit

Permalink
get zengin-code from api
Browse files Browse the repository at this point in the history
  • Loading branch information
euglena1215 committed Nov 27, 2022
1 parent d1aefb9 commit b02ffbf
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import { motion } from "framer-motion";
import React, { forwardRef, useCallback, useState } from "react";
import zenginCode from "zengin-code";

import { Dialog } from "../../../../components/layouts/Dialog";
import { Spacer } from "../../../../components/layouts/Spacer";
import { Stack } from "../../../../components/layouts/Stack";
import { Heading } from "../../../../components/typographies/Heading";
import { useFetch } from "../../../../hooks/useFetch";
import { useMutation } from "../../../../hooks/useMutation";
import { Space } from "../../../../styles/variables";
import { jsonFetcher } from "../../../../utils/HttpUtils";

const CANCEL = "cancel";
const CHARGE = "charge";
Expand Down Expand Up @@ -67,6 +68,12 @@ export const ChargeDialog = forwardRef(({ onComplete }, ref) => {
[charge, bankCode, branchCode, accountNo, amount, onComplete, clearForm],
);

const { data: zenginCode } = useFetch("/api/zengin-code", jsonFetcher);

if (zenginCode === null) {
return <div>Loading...</div>;
}

const bankList = Object.entries(zenginCode).map(([code, { name }]) => ({
code,
name,
Expand Down
6 changes: 6 additions & 0 deletions src/server/routes/api.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
import moment from "moment-timezone";
import { Between, LessThanOrEqual, MoreThanOrEqual } from "typeorm";
import zenginCode from "zengin-code";

import { BettingTicket, Race, User } from "../../model/index.js";
import { createConnection } from "../typeorm/connection.js";
import { initialize } from "../typeorm/initialize.js";


/**
* @type {import('fastify').FastifyPluginCallback}
*/
Expand Down Expand Up @@ -157,6 +159,10 @@ export const apiRoute = async (fastify) => {
res.send(bettingTicket);
});

fastify.get("/zengin-code", async (req, res) => {
res.send(zenginCode);
});

fastify.post("/initialize", async (_req, res) => {
await initialize();
res.status(204).send();
Expand Down

0 comments on commit b02ffbf

Please sign in to comment.