{"version":3,"file":"pages/Resources/RuleIndex/index.mjs","sources":["../../../../src/pages/Resources/RuleIndex/index.tsx"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { Rule } from '@rsdoctor/types';\nimport { Badge, Card, Space, Typography, Col, Row, Tag } from 'antd';\nimport ReactMarkdown from 'react-markdown';\nimport { Title } from '../../../components/Title';\nimport { Size } from '../../../constants';\nimport { useUrlQuery } from '../../../utils';\n\nexport const Page: React.FC = () => {\n  const query = useUrlQuery();\n\n  const defaultErrorCode =\n    query[Rule.RsdoctorRuleClientConstant.UrlQueryForErrorCode] || '';\n\n  const [ruleMessage, setRuleMessage] = useState<Rule.RuleMessage>(\n    Rule.RuleErrorMap[defaultErrorCode as keyof typeof Rule.RuleErrorMap],\n  );\n\n  const dataSource = Object.values(Rule.RuleErrorMap)!;\n\n  useEffect(() => {\n    window.scrollTo({ top: 0 });\n  }, []);\n\n  return (\n    <Row gutter={Size.BasePadding / 2}>\n      <Col span={8}>\n        <Card title={<Title text=\"list of the error codes.\" />} bordered>\n          <Space direction=\"vertical\">\n            {dataSource.map((e, i) => (\n              <Space\n                style={{\n                  marginTop: i === 0 ? 0 : Size.BasePadding / 2,\n                  cursor: 'pointer',\n                }}\n                onClick={() => setRuleMessage(e)}\n                key={e.code}\n                align=\"center\"\n              >\n                <Badge status=\"default\" />\n                <Typography.Text code>\n                  <a>{e.code}</a>\n                </Typography.Text>\n                <Typography.Text\n                  style={{\n                    color:\n                      ruleMessage && ruleMessage.code === e.code\n                        ? '#1890ff'\n                        : undefined,\n                  }}\n                >\n                  {e.title}\n                </Typography.Text>\n              </Space>\n            ))}\n          </Space>\n        </Card>\n      </Col>\n      <Col span={16}>\n        {ruleMessage ? (\n          <Card\n            title={\n              <Row justify=\"space-between\">\n                <Space>\n                  <Typography.Text code>{ruleMessage.code}</Typography.Text>\n                  <Typography.Text>{ruleMessage.title}</Typography.Text>\n                </Space>\n                <div>\n                  <Tag>{ruleMessage.category}</Tag>\n                </div>\n              </Row>\n            }\n            bodyStyle={{ paddingTop: 0 }}\n            bordered\n          >\n            <Typography.Paragraph>\n              {ruleMessage.type === 'markdown' ? (\n                // TODO: ReactMarkdown will increase the bundle size by 100 KB. Need to optimize with another component or solution.\n                <ReactMarkdown>{ruleMessage.description}</ReactMarkdown>\n              ) : (\n                <Typography.Text>{ruleMessage.description}</Typography.Text>\n              )}\n            </Typography.Paragraph>\n          </Card>\n        ) : (\n          <Card\n            title={\n              'This page lists all the error codes emitted by the Rsdoctor.'\n            }\n            bordered\n          >\n            <Typography.Text>\n              click the error code in left bar to show more details.\n            </Typography.Text>\n          </Card>\n        )}\n      </Col>\n    </Row>\n  );\n};\n\nexport * from './constants';\n"],"names":["Page","query","useUrlQuery","defaultErrorCode","Rule","ruleMessage","setRuleMessage","useState","dataSource","Object","useEffect","window","Row","Size","Col","Card","Title","Space","e","i","Badge","Typography","undefined","Tag","ReactMarkdown"],"mappings":";;;;;;;;;AAQO,MAAMA,OAAiB;IAC5B,MAAMC,QAAQC;IAEd,MAAMC,mBACJF,KAAK,CAACG,KAAK,0BAA0B,CAAC,oBAAoB,CAAC,IAAI;IAEjE,MAAM,CAACC,aAAaC,eAAe,GAAGC,SACpCH,KAAK,YAAY,CAACD,iBAAmD;IAGvE,MAAMK,aAAaC,OAAO,MAAM,CAACL,KAAK,YAAY;IAElDM,UAAU;QACRC,OAAO,QAAQ,CAAC;YAAE,KAAK;QAAE;IAC3B,GAAG,EAAE;IAEL,OAAO,WAAP,GACE,KAACC,KAAGA;QAAC,QAAQC,KAAK,WAAW,GAAG;;0BAC9B,IAACC,KAAGA;gBAAC,MAAM;0BACT,kBAACC,MAAIA;oBAAC,qBAAO,IAACC,OAAKA;wBAAC,MAAK;;oBAA+B,UAAQ;8BAC9D,kBAACC,OAAKA;wBAAC,WAAU;kCACdT,WAAW,GAAG,CAAC,CAACU,GAAGC,IAAAA,WAAAA,GAClB,KAACF,OAAKA;gCACJ,OAAO;oCACL,WAAWE,AAAM,MAANA,IAAU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