diff --git a/package.json b/package.json index 9778089..a3489bc 100644 --- a/package.json +++ b/package.json @@ -14,7 +14,7 @@ "dependencies": { "@emotion/react": "^11.10.5", "@emotion/styled": "^11.10.5", - "@frontend/kitui": "1.0.47", + "@frontend/kitui": "1.0.52", "@mui/icons-material": "^5.10.14", "@mui/material": "^5.10.14", "@popperjs/core": "^2.11.8", diff --git a/src/api/history.ts b/src/api/history.ts index 460fad0..48a5f04 100644 --- a/src/api/history.ts +++ b/src/api/history.ts @@ -12,11 +12,13 @@ type HistoryRecord = { id: string; isDeleted: boolean; key: string; - rawDetails: { Key: string; Value: string | number }[]; + rawDetails: KeyValue[][]; updatedAt: string; userId: string; }; +type KeyValue = { Key: string; Value: string | number }; + export async function getHistory(): Promise<[GetHistoryResponse | null, string?]> { try { const historyResponse = await makeRequest({ diff --git a/src/components/CustomAccordion.tsx b/src/components/CustomAccordion.tsx index b254b34..be1659a 100644 --- a/src/components/CustomAccordion.tsx +++ b/src/components/CustomAccordion.tsx @@ -8,9 +8,11 @@ interface Props { text: string; divide?: boolean; price?: number; + last?: boolean; + first?: boolean; } -export default function CustomAccordion({ header, text, divide = false, price }: Props) { +export default function CustomAccordion({ header, text, divide = false, price, last, first }: Props) { const theme = useTheme(); const upMd = useMediaQuery(theme.breakpoints.up("md")); const upXs = useMediaQuery(theme.breakpoints.up("xs")); @@ -20,17 +22,13 @@ export default function CustomAccordion({ header, text, divide = false, price }: { + valuesByKey[item.Key] = item.Value; + }); + + const extractDateFromString = (tariffName: string) => { + const dateMatch = tariffName.match(/\d{4}-\d{2}-\d{2}/); + return dateMatch ? dateMatch[0] : null; + }; + return ( - {content.map((accordionItem, index) => ( - - - - {accordionItem.date} - + {extractDateFromString(valuesByKey.createdat)} + - - {accordionItem.title} - - + + {valuesByKey.name} + + + + + {valuesByKey.payMethod && Способ оплаты: {valuesByKey.payMethod}} + - {accordionItem.payMethod && Способ оплаты: {accordionItem.payMethod}} + {valuesByKey.price} руб. - - - {accordionItem.info} - - - } - /> - ))} + + } + /> ); } diff --git a/src/pages/History/index.tsx b/src/pages/History/index.tsx index e6ce43e..716036f 100644 --- a/src/pages/History/index.tsx +++ b/src/pages/History/index.tsx @@ -9,9 +9,6 @@ import { Tabs } from "@root/components/Tabs"; import AccordionWrapper from "./AccordionWrapper"; import { HISTORY } from "./historyMocks"; import { useHistoryTracker } from "@root/utils/hooks/useHistoryTracker"; -import { makeRequest, useToken } from "@frontend/kitui"; -import axios from "axios"; -import { getHistory } from "@root/api/history"; import { useHistoryData } from "@root/utils/hooks/useHistoryData"; const subPages = ["Платежи", "Покупки тарифов", "Окончания тарифов"]; @@ -28,7 +25,7 @@ export default function History() { const handleCustomBackNavigation = useHistoryTracker(); if (!error && historyData) { - console.log(historyData?.records[0].rawDetails.map((rawDetails) => console.log(rawDetails.Key))); + console.log(historyData?.records[0].rawDetails[0].map(({ Key, Value }) => (Key == "id" ? console.log(Value) : ""))); } return ( @@ -68,9 +65,13 @@ export default function History() { ) : ( )} - {HISTORY.map((history, index) => ( -