|
1 | 1 | // Generated by ReScript, PLEASE EDIT WITH CARE |
2 | 2 |
|
3 | | -import * as React from "react"; |
4 | | -import * as Header from "../../Header/Header.bs.js"; |
5 | | -import * as Actions from "../../Actions/Actions.bs.js"; |
6 | | -import * as AlertError from "../../CommentList/AlertError/AlertError.bs.js"; |
7 | | -import * as ActionCable from "../../bindings/ActionCable.bs.js"; |
8 | | -import * as CommentForm from "../../CommentForm/CommentForm.bs.js"; |
9 | | -import * as CommentList from "../../CommentList/CommentList.bs.js"; |
10 | | -import * as JsxRuntime from "react/jsx-runtime"; |
| 3 | +import * as React from 'react'; |
| 4 | +import * as Header from '../../Header/Header.bs.js'; |
| 5 | +import * as Actions from '../../Actions/Actions.bs.js'; |
| 6 | +import * as AlertError from '../../CommentList/AlertError/AlertError.bs.js'; |
| 7 | +import * as ActionCable from '../../bindings/ActionCable.bs.js'; |
| 8 | +import * as CommentForm from '../../CommentForm/CommentForm.bs.js'; |
| 9 | +import * as CommentList from '../../CommentList/CommentList.bs.js'; |
| 10 | +import * as JsxRuntime from 'react/jsx-runtime'; |
11 | 11 |
|
12 | 12 | function reducer(param, action) { |
13 | | - if (typeof action !== "object") { |
| 13 | + if (typeof action !== 'object') { |
14 | 14 | return { |
15 | | - commentsFetchStatus: "FetchError" |
16 | | - }; |
| 15 | + commentsFetchStatus: 'FetchError', |
| 16 | + }; |
17 | 17 | } else { |
18 | 18 | return { |
19 | | - commentsFetchStatus: { |
20 | | - TAG: "CommentsFetched", |
21 | | - _0: action._0 |
22 | | - } |
23 | | - }; |
| 19 | + commentsFetchStatus: { |
| 20 | + TAG: 'CommentsFetched', |
| 21 | + _0: action._0, |
| 22 | + }, |
| 23 | + }; |
24 | 24 | } |
25 | 25 | } |
26 | 26 |
|
27 | 27 | function ReScriptShow$default(props) { |
28 | 28 | var match = React.useReducer(reducer, { |
29 | | - commentsFetchStatus: { |
30 | | - TAG: "CommentsFetched", |
31 | | - _0: [] |
32 | | - } |
33 | | - }); |
| 29 | + commentsFetchStatus: { |
| 30 | + TAG: 'CommentsFetched', |
| 31 | + _0: [], |
| 32 | + }, |
| 33 | + }); |
34 | 34 | var dispatch = match[1]; |
35 | 35 | var fetchData = async function () { |
36 | 36 | var comments = await Actions.Fetch.fetchComments(); |
37 | | - if (comments.TAG === "Ok") { |
| 37 | + if (comments.TAG === 'Ok') { |
38 | 38 | return dispatch({ |
39 | | - TAG: "SetComments", |
40 | | - _0: comments._0 |
41 | | - }); |
| 39 | + TAG: 'SetComments', |
| 40 | + _0: comments._0, |
| 41 | + }); |
42 | 42 | } else { |
43 | | - return dispatch("SetFetchError"); |
| 43 | + return dispatch('SetFetchError'); |
44 | 44 | } |
45 | 45 | }; |
46 | 46 | var subscribeToCommentsChannel = function () { |
47 | | - return ActionCable.subscribeConsumer("CommentsChannel", { |
48 | | - connected: (function () { |
49 | | - console.log("Connected"); |
50 | | - }), |
51 | | - received: (function (data) { |
52 | | - dispatch({ |
53 | | - TAG: "SetComments", |
54 | | - _0: [data] |
55 | | - }); |
56 | | - }), |
57 | | - disconnected: (function () { |
58 | | - console.log("Disconnected"); |
59 | | - }) |
60 | | - }); |
| 47 | + return ActionCable.subscribeConsumer('CommentsChannel', { |
| 48 | + connected: function () { |
| 49 | + console.log('Connected'); |
| 50 | + }, |
| 51 | + received: function (data) { |
| 52 | + dispatch({ |
| 53 | + TAG: 'SetComments', |
| 54 | + _0: [data], |
| 55 | + }); |
| 56 | + }, |
| 57 | + disconnected: function () { |
| 58 | + console.log('Disconnected'); |
| 59 | + }, |
| 60 | + }); |
61 | 61 | }; |
62 | | - React.useEffect((function () { |
63 | | - var scription = subscribeToCommentsChannel(); |
64 | | - return (function () { |
65 | | - scription.unsubscribe(); |
66 | | - }); |
67 | | - }), []); |
68 | | - React.useEffect((function () { |
69 | | - fetchData(); |
70 | | - }), []); |
| 62 | + React.useEffect(function () { |
| 63 | + var scription = subscribeToCommentsChannel(); |
| 64 | + return function () { |
| 65 | + scription.unsubscribe(); |
| 66 | + }; |
| 67 | + }, []); |
| 68 | + React.useEffect(function () { |
| 69 | + fetchData(); |
| 70 | + }, []); |
71 | 71 | var comments = match[0].commentsFetchStatus; |
72 | 72 | var tmp; |
73 | | - tmp = typeof comments !== "object" ? JsxRuntime.jsx(AlertError.make, { |
74 | | - errorMsg: "Can't fetch the comments!" |
75 | | - }) : JsxRuntime.jsx(CommentList.make, { |
76 | | - comments: comments._0 |
| 73 | + tmp = |
| 74 | + typeof comments !== 'object' |
| 75 | + ? JsxRuntime.jsx(AlertError.make, { |
| 76 | + errorMsg: "Can't fetch the comments!", |
| 77 | + }) |
| 78 | + : JsxRuntime.jsx(CommentList.make, { |
| 79 | + comments: comments._0, |
77 | 80 | }); |
78 | | - return JsxRuntime.jsxs("div", { |
79 | | - children: [ |
80 | | - JsxRuntime.jsxs("h2", { |
81 | | - children: [ |
82 | | - "Rescript + Rails Backend (with ", |
83 | | - JsxRuntime.jsx("a", { |
84 | | - children: "react_on_rails gem", |
85 | | - href: "https://github.com/shakacode/react_on_rails" |
86 | | - }), |
87 | | - ")" |
88 | | - ] |
89 | | - }), |
90 | | - JsxRuntime.jsx(Header.make, {}), |
91 | | - JsxRuntime.jsxs("div", { |
92 | | - children: [ |
93 | | - JsxRuntime.jsx("h2", { |
94 | | - children: "Comments" |
95 | | - }), |
96 | | - JsxRuntime.jsxs("ul", { |
97 | | - children: [ |
98 | | - JsxRuntime.jsx("li", { |
99 | | - children: "Text supports Github Flavored Markdown." |
100 | | - }), |
101 | | - JsxRuntime.jsx("li", { |
102 | | - children: "Comments older than 24 hours are deleted." |
103 | | - }), |
104 | | - JsxRuntime.jsx("li", { |
105 | | - children: "Name is preserved. Text is reset, between submits" |
106 | | - }), |
107 | | - JsxRuntime.jsx("li", { |
108 | | - children: "To see Action Cable instantly update two browsers, open two browsers and submit a comment!" |
109 | | - }) |
110 | | - ] |
111 | | - }), |
112 | | - JsxRuntime.jsx(CommentForm.make, { |
113 | | - fetchData: fetchData |
114 | | - }), |
115 | | - tmp |
116 | | - ], |
117 | | - className: "prose max-w-none prose-a:text-sky-700 prose-li:my-0" |
118 | | - }) |
119 | | - ] |
120 | | - }); |
| 81 | + return JsxRuntime.jsxs('div', { |
| 82 | + children: [ |
| 83 | + JsxRuntime.jsxs('h2', { |
| 84 | + children: [ |
| 85 | + 'Rescript + Rails Backend (with ', |
| 86 | + JsxRuntime.jsx('a', { |
| 87 | + children: 'react_on_rails gem', |
| 88 | + href: 'https://github.com/shakacode/react_on_rails', |
| 89 | + }), |
| 90 | + ')', |
| 91 | + ], |
| 92 | + }), |
| 93 | + JsxRuntime.jsx(Header.make, {}), |
| 94 | + JsxRuntime.jsxs('div', { |
| 95 | + children: [ |
| 96 | + JsxRuntime.jsx('h2', { |
| 97 | + children: 'Comments', |
| 98 | + }), |
| 99 | + JsxRuntime.jsxs('ul', { |
| 100 | + children: [ |
| 101 | + JsxRuntime.jsx('li', { |
| 102 | + children: 'Text supports Github Flavored Markdown.', |
| 103 | + }), |
| 104 | + JsxRuntime.jsx('li', { |
| 105 | + children: 'Comments older than 24 hours are deleted.', |
| 106 | + }), |
| 107 | + JsxRuntime.jsx('li', { |
| 108 | + children: 'Name is preserved. Text is reset, between submits', |
| 109 | + }), |
| 110 | + JsxRuntime.jsx('li', { |
| 111 | + children: |
| 112 | + 'To see Action Cable instantly update two browsers, open two browsers and submit a comment!', |
| 113 | + }), |
| 114 | + ], |
| 115 | + }), |
| 116 | + JsxRuntime.jsx(CommentForm.make, { |
| 117 | + fetchData: fetchData, |
| 118 | + }), |
| 119 | + tmp, |
| 120 | + ], |
| 121 | + className: 'prose max-w-none prose-a:text-sky-700 prose-li:my-0', |
| 122 | + }), |
| 123 | + ], |
| 124 | + }); |
121 | 125 | } |
122 | 126 |
|
123 | 127 | var $$default = ReScriptShow$default; |
124 | 128 |
|
125 | | -export { |
126 | | - reducer , |
127 | | - $$default as default, |
128 | | -} |
| 129 | +export { reducer, $$default as default }; |
129 | 130 | /* react Not a pure module */ |
0 commit comments