Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/app/admin/queue/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ const QueuePage = () => {
fetchPolicy: "network-only",
});

console.log(data);

useEffect(() => {
queryOrders();
}, []);
Expand Down
317 changes: 4 additions & 313 deletions src/app/admin/resources/page.tsx
Original file line number Diff line number Diff line change
@@ -1,321 +1,12 @@
"use client";

import React, { useEffect, useState } from "react";
import {
Typography,
Upload,
Button,
Table,
DatePicker,
Divider,
Form,
ConfigProvider,
Modal,
} from "antd";
import { UploadOutlined } from "@ant-design/icons";
import type { ColumnsType } from "antd/es/table";
import dayjs from "dayjs";
import csCZ from "antd/locale/cs_CZ";
import { Resources } from "@/components/Resources";

const ResourcesPage = () => {
const [csv, setCsv] = useState<string | undefined>();
const { Title } = Typography;

const [transactionFilterForm] = Form.useForm();

const [isModalVisible, setIsModalVisible] = useState(false);
const [modaldata, setmodaldata] = useState<TransactionsType>({
key: "0",
variableSymbol: 0,
amount: 0,
date: new Date(),
fromAcoount: "",
name: "",
notice: "",
status: 0,
});

interface TransactionsType {
key: React.Key;
variableSymbol: number;
amount: number;
date: Date;
fromAcoount: string;
name: string;
notice: string;
status: number;
}

const transactionsColoumns: ColumnsType<TransactionsType> = [
{
title: "Název",
dataIndex: "name",
},
{
title: "Částka",
dataIndex: "amount",
render: (text, record) => <p>{record.amount} Kč</p>,
},
{
title: "Variabilní symbol",
dataIndex: "variableSymbol",
},
{
title: "Čas",
dataIndex: "date",
render: (text, record) => (
<DatePicker
showTime
defaultValue={dayjs(record.date)}
disabled
className="w-full min-w-[180px]"
/>
),
filterDropdown: ({ setSelectedKeys, confirm, close, clearFilters }) => (
<Form
className="p-2"
form={transactionFilterForm}
validateMessages={{ required: "Toto pole je povinné!" }}
onFinish={(values) => {
setSelectedKeys([values.date]);
confirm();
close();
}}
>
<ConfigProvider locale={csCZ}>
<Form.Item
name="date"
className="mb-0"
rules={[{ required: false }]}
>
<DatePicker.RangePicker
onChange={(values) => {
if (!values) {
clearFilters ? clearFilters() : null;
confirm();
close();
}
}}
/>
</Form.Item>
</ConfigProvider>
<Divider className="my-2" />
<div className="flex justify-end mb-0 -mt-1">
<Form.Item className="my-0">
<Button
type="primary"
htmlType="submit"
size="small"
className="mr-2"
>
OK
</Button>
</Form.Item>
</div>
</Form>
),
onFilter: (value, record) => {
const typedValue = value as unknown as [Date, Date];
return value
? record.date >= typedValue[0] && record.date <= typedValue[1]
: true;
},
filterMode: "tree",
},
{
title: "Odesílatel",
dataIndex: "fromAcoount",
},
{
title: "Zpráva",
dataIndex: "notice",
},
{
title: "Akce",
render: (text, record) => (
<>
<Button
type="primary"
size="small"
className="mr-2"
onClick={() => {
setmodaldata(record as TransactionsType);
setIsModalVisible(true);
}}
>
Přiřadit
</Button>
</>
),
},
];

const transactionsData: TransactionsType[] = [
{
key: "1",
name: "John Brown",
amount: 32,
variableSymbol: 1234567890,
date: new Date("2022"),
fromAcoount: "1234567890/1234",
notice: "Příjem",
status: 1,
},
{
key: "2",
name: "Jim Green",
amount: 42,
variableSymbol: 4567893210,
date: new Date(),
fromAcoount: "1234567890/1234",
notice: "Příjem",
status: 1,
},
{
key: "3",
name: "Joe Black",
amount: 32,
variableSymbol: 9876543210,
date: new Date("2022"),
fromAcoount: "1234567890/1234",
notice: "Příjem",
status: 1,
},
{
key: "4",
name: "Joe Black",
amount: 32,
variableSymbol: 9876543210,
date: new Date("2022"),
fromAcoount: "1234567890/1234",
notice: "Příjem",
status: 1,
},
{
key: "5",
name: "Joe Black",
amount: 32,
variableSymbol: 9876543210,
date: new Date("2022"),
fromAcoount: "1234567890/1234",
notice: "Příjem",
status: 1,
},
{
key: "6",
name: "Joe Black",
amount: 32,
variableSymbol: 9876543210,
date: new Date("2022"),
fromAcoount: "1234567890/1234",
notice: "Příjem",
status: 1,
},
{
key: "7",
name: "Joe Black",
amount: 32,
variableSymbol: 9876543210,
date: new Date("2022"),
fromAcoount: "1234567890/1234",
notice: "Příjem",
status: 1,
},
{
key: "8",
name: "Joe Black",
amount: 32,
variableSymbol: 9876543210,
date: new Date("2022"),
fromAcoount: "1234567890/1234",
notice: "Příjem",
status: 1,
},
{
key: "9",
name: "Joe Black",
amount: 32,
variableSymbol: 9876543210,
date: new Date("2022"),
fromAcoount: "1234567890/1234",
notice: "Příjem",
status: 1,
},
{
key: "10",
name: "Joe Black",
amount: 32,
variableSymbol: 9876543210,
date: new Date("2022"),
fromAcoount: "1234567890/1234",
notice: "Příjem",
status: 1,
},
{
key: "11",
name: "Joe Black",
amount: 32,
variableSymbol: 9876543210,
date: new Date("2022"),
fromAcoount: "1234567890/1234",
notice: "Příjem",
status: 1,
},
{
key: "12",
name: "Joe Black",
amount: 32,
variableSymbol: 9876543210,
date: new Date("2022"),
fromAcoount: "1234567890/1234",
notice: "Příjem",
status: 1,
},
];

useEffect(() => {
if (csv) {
}
}, [csv]);

return (
<div>
<Title className="text-5xl sm:text-7xl m-0 font-black text-[#1F2937] mb-4">
<h1 className="text-5xl sm:text-7xl m-0 font-black text-[#1F2937] mb-4">
Účetní pohyby
</Title>
<Upload
accept=".csv"
beforeUpload={(file) => {
const reader = new FileReader();

reader.onload = (e) => {
setCsv(e.target?.result as string);
};

reader.readAsText(file);

return false;
}}
>
<Button className="w-[5rem] my-4" icon={<UploadOutlined />}></Button>
</Upload>
<Table
className="overflow-scroll"
columns={transactionsColoumns}
dataSource={transactionsData}
/>
<Modal
title="Přiřadit uživatele"
open={isModalVisible}
onOk={() => {
setIsModalVisible(false);
}}
onCancel={() => {
setIsModalVisible(false);
}}
>
<p>user select for {modaldata.variableSymbol}</p>
</Modal>
</h1>
<Resources />
</div>
);
};
Expand Down
Loading