No Description

Payment.stories.tsx 8.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. import React, { MouseEvent } from 'react';
  2. import { storiesOf } from '@storybook/react';
  3. import { action } from '@storybook/addon-actions';
  4. import { withInfo } from "@storybook/addon-info";
  5. import { withKnobs, number, boolean, select } from "@storybook/addon-knobs";
  6. import { addReadme } from 'storybook-readme';
  7. import ConsumeListView from '@components/Payment/Common/ConsumeListView';
  8. import ConsumeListViewDoc from '@components/Payment/Common/ConsumeListView/README.md';
  9. import PayPlatFormOptions, { PAY_CHANNEL } from '@components/Payment/Common/PayPlatformOptions';
  10. import PayPlatFormOptionsDoc from '@components/Payment/Common/PayPlatformOptions/README.md';
  11. import PriceOptions from '@components/Payment/Common/PriceOptions';
  12. import PriceOptionsDoc from '@components/Payment/Common/PriceOptions/README.md';
  13. import WaitPayInfoView from '@components/Payment/Common/WaitPayInfoView';
  14. import WaitPayInfoViewDoc from '@components/Payment/Common/WaitPayInfoView/README.md';
  15. const stories = storiesOf('Payment', module);
  16. stories.addDecorator((storyFn) => <div style={{padding: "0px 40px"}}>{storyFn()}</div>)
  17. stories.addDecorator(withKnobs);
  18. stories.addDecorator(withInfo);
  19. stories.addDecorator(addReadme);
  20. const consumeData = [
  21. {
  22. "id": 69,
  23. "consume_id": "20190919120838283305719",
  24. "goods_id": 0,
  25. "goods_type": 4,
  26. "num": 9,
  27. "user_id": 71082,
  28. "user_nickname": "lydia",
  29. "user_avatar": "https://links123-images.oss-cn-hangzhou.aliyuncs.com/avatar/2018/8/26/10adf03c70fb128d546e0d40fea77047.jpg",
  30. "to_user_id": 1,
  31. "to_user_nickname": "",
  32. "to_user_avatar": "",
  33. "bill_price": 900,
  34. "ref_id": 0,
  35. "business_type": 3,
  36. "created_at": 1568894918,
  37. "updated_at": 1568894918
  38. },
  39. {
  40. "id": 32,
  41. "consume_id": "20190802095658644217897",
  42. "goods_id": 2,
  43. "goods_type": 1,
  44. "num": 8,
  45. "user_id": 2,
  46. "user_nickname": "jim",
  47. "user_avatar": "https://links123-images.oss-cn-hangzhou.aliyuncs.com/avatar/2018/4/6/7d4948f6e9a66789f776b0c69c8d51d9.png",
  48. "to_user_id": 1,
  49. "to_user_nickname": "",
  50. "to_user_avatar": "",
  51. "bill_price": 800,
  52. "ref_id": 0,
  53. "business_type": 3,
  54. "created_at": 1564739818,
  55. "updated_at": 1564739818
  56. },
  57. {
  58. "id": 46,
  59. "consume_id": "20190819131433734083448",
  60. "goods_id": 2,
  61. "goods_type": 1,
  62. "num": 7,
  63. "user_id": 5,
  64. "user_nickname": "Chris",
  65. "user_avatar": "https://links123-images.oss-cn-hangzhou.aliyuncs.com/avatar/2019/6/12/a1aec180fbb727cc693c7a2f14812dac.jpg",
  66. "to_user_id": 1,
  67. "to_user_nickname": "",
  68. "to_user_avatar": "",
  69. "bill_price": 700,
  70. "ref_id": 0,
  71. "business_type": 3,
  72. "created_at": 1566220473,
  73. "updated_at": 1566220473
  74. },
  75. {
  76. "id": 20,
  77. "consume_id": "20190729154830503859957",
  78. "goods_id": 2,
  79. "goods_type": 1,
  80. "num": 5,
  81. "user_id": 217,
  82. "user_nickname": "Paul",
  83. "user_avatar": "https://links123-images.oss-cn-hangzhou.aliyuncs.com/avatar/2019/12/4/b9221e3176d92c349affc3633a0ec7bf.jpg",
  84. "to_user_id": 1,
  85. "to_user_nickname": "",
  86. "to_user_avatar": "",
  87. "bill_price": 500,
  88. "ref_id": 0,
  89. "business_type": 3,
  90. "created_at": 1564415310,
  91. "updated_at": 1564415310
  92. },
  93. {
  94. "id": 127,
  95. "consume_id": "20191204115927765695546",
  96. "goods_id": 2,
  97. "goods_type": 1,
  98. "num": 1,
  99. "user_id": 45,
  100. "user_nickname": "Adam",
  101. "user_avatar": "https://links123-images.oss-cn-hangzhou.aliyuncs.com/avatar/2019/6/12/cbc5208e3a8aba6fcfc2cef2a4d5151d.jpg",
  102. "to_user_id": 1,
  103. "to_user_nickname": "",
  104. "to_user_avatar": "",
  105. "bill_price": 100,
  106. "ref_id": 0,
  107. "business_type": 3,
  108. "created_at": 1575460767,
  109. "updated_at": 1575460767
  110. },
  111. {
  112. "id": 71,
  113. "consume_id": "20190922010906704921621",
  114. "goods_id": 0,
  115. "goods_type": 4,
  116. "num": 1,
  117. "user_id": 22428,
  118. "user_nickname": "简单生活",
  119. "user_avatar": "https://links123-images.oss-cn-hangzhou.aliyuncs.com/avatar/2019/9/22/27886bb4305ab56adc0b20018b975dc5.jpg",
  120. "to_user_id": 1,
  121. "to_user_nickname": "",
  122. "to_user_avatar": "",
  123. "bill_price": 100,
  124. "ref_id": 0,
  125. "business_type": 3,
  126. "created_at": 1569114546,
  127. "updated_at": 1569114546
  128. },
  129. {
  130. "id": 70,
  131. "consume_id": "20190920014118872836942",
  132. "goods_id": 0,
  133. "goods_type": 4,
  134. "num": 1,
  135. "user_id": 70406,
  136. "user_nickname": "vicky",
  137. "user_avatar": "https://links123-images.oss-cn-hangzhou.aliyuncs.com/avatar/2019/5/5/8a0db661919f926501192eccf13740f1jpg",
  138. "to_user_id": 1,
  139. "to_user_nickname": "",
  140. "to_user_avatar": "",
  141. "bill_price": 100,
  142. "ref_id": 0,
  143. "business_type": 3,
  144. "created_at": 1568943678,
  145. "updated_at": 1568943678
  146. },
  147. {
  148. "id": 68,
  149. "consume_id": "20190917224355248346157",
  150. "goods_id": 0,
  151. "goods_type": 4,
  152. "num": 1,
  153. "user_id": 71603,
  154. "user_nickname": "Slate",
  155. "user_avatar": "https://links123-images.oss-cn-hangzhou.aliyuncs.com/avatar/2019/10/19/1cb9f491e90258ba91a189027ef774b7.jpg",
  156. "to_user_id": 1,
  157. "to_user_nickname": "",
  158. "to_user_avatar": "",
  159. "bill_price": 100,
  160. "ref_id": 0,
  161. "business_type": 3,
  162. "created_at": 1568760235,
  163. "updated_at": 1568760235
  164. }
  165. ];
  166. stories.add(
  167. 'ConsumeListView',
  168. () => {
  169. const [toggle, setToggle] = React.useState(false);
  170. return <ConsumeListView
  171. isToggle={toggle}
  172. onToggleChange={() => setToggle(!toggle)}
  173. onConsumeItemClick={(e: MouseEvent, clickData: any) => { console.log(clickData); }}
  174. dataSource={consumeData}
  175. listLength={consumeData.length}
  176. showLength={number("showLength", 5)}
  177. />
  178. },
  179. {
  180. info: {
  181. inline: true,
  182. text: `
  183. ~~~typescript
  184. <ConsumeListView
  185. isToggle={toggle}
  186. onToggleChange={() => setToggle(!toggle)}
  187. dataSource={consumeData}
  188. listLength={consumeData.length}
  189. showLength={number("showLength", 5)}
  190. />
  191. ~~~
  192. `,
  193. // TableComponent: (props: TableComponentOptionProps) => {
  194. // const { propDefinitions } = props;
  195. // return propDefinitions.map(i => {
  196. // return (
  197. // <div>
  198. // {i.defaultValue}
  199. // </div>
  200. // )
  201. // })
  202. // },
  203. source: false,
  204. maxPropStringLength: 500,
  205. },
  206. notes: 'A very simple example of addon notes',
  207. readme: {
  208. sidebar: ConsumeListViewDoc,
  209. }
  210. }
  211. );
  212. stories.add(
  213. 'PayPlatFormOptions',
  214. () => {
  215. const [payChannel, setPayChannel] = React.useState(PAY_CHANNEL.PAYPAL);
  216. return (
  217. <PayPlatFormOptions
  218. payChannel={payChannel}
  219. onPayChannelChange={(value) => {
  220. action(`PayItemChange: ${value}`);
  221. setPayChannel(value);
  222. }}
  223. isMobile={boolean("isMobile", false)}
  224. size={select("size", { Small: "small", Normal: "normal", Large: "large"}, "normal")}
  225. withTitle={boolean("withTitle", false)}
  226. locale={select("locale", { ZH: 'zh', EN: 'en' }, "zh")}
  227. />
  228. )
  229. },
  230. {
  231. info: {
  232. inline: true,
  233. text: ``,
  234. source: false,
  235. maxPropStringLength: 500,
  236. },
  237. notes: 'A very simple example of addon notes',
  238. readme: {
  239. sidebar: PayPlatFormOptionsDoc,
  240. }
  241. }
  242. );
  243. stories.add(
  244. 'PriceOptions',
  245. () => {
  246. const [price, setPrice] = React.useState(0);
  247. const refInput = React.useRef(null);
  248. return (
  249. <PriceOptions
  250. price={price}
  251. onPriceChange={(v) => setPrice(v)}
  252. size={select("size", { Small: "small", Normal: "normal", Large: "large"}, "normal")}
  253. withTitle={boolean("withTitle", false)}
  254. focusScroll={boolean("focusScroll", false)}
  255. inputRef={refInput}
  256. />
  257. )
  258. },
  259. {
  260. info: {
  261. inline: true,
  262. text: ``,
  263. source: false,
  264. maxPropStringLength: 500,
  265. },
  266. notes: 'A very simple example of addon notes',
  267. readme: {
  268. sidebar: PriceOptionsDoc,
  269. }
  270. }
  271. )
  272. stories.add(
  273. 'WaitPayInfoView',
  274. () => {
  275. return (
  276. <WaitPayInfoView />
  277. )
  278. },
  279. {
  280. info: { inline: true, text: ``, source: false, maxPropStringLength: 500 },
  281. notes: 'A very simple example of addon notes',
  282. readme: {
  283. sidebar: WaitPayInfoViewDoc,
  284. }
  285. }
  286. )