UNPKG

ruffer-pattern-portfolio

Version:

This is the end result from https://dev.to/swyx/quick-guide-to-setup-your-react--typescript-storybook-design-system-1c51

82 lines (81 loc) 3.32 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __assign = (this && this.__assign) || function () { __assign = Object.assign || function(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var react_1 = __importDefault(require("react")); var react_redux_1 = require("react-redux"); var RecentDocuments_1 = require("../RecentDocuments/RecentDocuments"); var TeamListCard_1 = __importDefault(require("../TeamListCard/TeamListCard")); var Page = /** @class */ (function (_super) { __extends(Page, _super); function Page(props) { var _this = _super.call(this, props) || this; _this.state = { loading: false, recentDocuments: props.recentDocuments, teamList: props.teamList }; return _this; } Page.prototype.api = function (url) { return fetch(url) .then(function (response) { if (!response.ok) { throw new Error(response.statusText); } return response.json(); }) .catch(function (error) { throw error; /* <-- rethrow the error so consumer can still catch it */ }); }; Page.prototype.componentDidMount = function (pageNumber, pageSize) { var _this = this; if (pageNumber === void 0) { pageNumber = 1; } if (pageSize === void 0) { pageSize = 10; } this.api("http://localhost:4000/recent-document") .then(function (docsResult) { _this.setState({ recentDocuments: docsResult }); }); this.api("http://localhost:4000/team-list") .then(function (teamsResult) { _this.setState({ teamList: teamsResult }); }); }; Page.prototype.render = function () { var searchBarProps = { elements: this.state.teamList }; return (react_1.default.createElement("div", null, react_1.default.createElement(RecentDocuments_1.RecentDocuments, { elements: this.state.recentDocuments }), react_1.default.createElement(TeamListCard_1.default, __assign({}, searchBarProps)))); }; return Page; }(react_1.default.Component)); exports.Page = Page; exports.default = react_redux_1.connect()(Page);