@bigbinary/neeto-message-templates-frontend 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,196 @@
1
+ # neeto-message-templates
2
+
3
+ To manage message templates across the neeto products. As of now, it supports
4
+ the creation of SMS, Email and Whatsapp templates.
5
+
6
+ # Engine Installation
7
+
8
+ 1. Add this line to your application's Gemfile:
9
+
10
+ ```ruby
11
+ source "NEETO_GEM_SERVER_URL" do
12
+ # ..existing gems
13
+
14
+ gem 'neeto-message-templates-engine'
15
+ end
16
+ ```
17
+
18
+ 2. And then execute:
19
+
20
+ ```shell
21
+ bundle install
22
+ ```
23
+
24
+ 3. Configure the organization model in the host application.
25
+
26
+ ```ruby
27
+ has_many :message_templates, class_name: "NeetoMessageTemplatesEngine::MessageTemplate", dependent: :destroy
28
+ ```
29
+
30
+ 4. Add this line to your application's `config/routes.rb` file
31
+
32
+ ```ruby
33
+ mount NeetoMessageTemplatesEngine::Engine => "/neeto_message_templates_engine"
34
+ ```
35
+
36
+ 5. Copy the migrations from the engine to the host application and run
37
+ `db:migrate` in host application
38
+
39
+ ```shell
40
+ bundle exec rails neeto_message_templates_engine:install:migrations
41
+ bundle exec rails db:migrate
42
+ ```
43
+
44
+ 6. Create a file in the host app under
45
+ `app/lib/neeto_message_templates_engine/callbacks.rb` & provide the
46
+ permission (If you don't have permissions, then simply return true)
47
+
48
+ ```ruby
49
+ module NeetoMessageTemplatesEngine
50
+ class Callbacks
51
+ def self.can_manage_message_templates?(user)
52
+ user.has_permission?("admin.manage_message_templates")
53
+ end
54
+ end
55
+ end
56
+ ```
57
+
58
+ # Frontend Package Installation
59
+
60
+ Install the latest `neetoMessageTemplates` package using the below command:
61
+
62
+ ```shell
63
+ yarn add @bigbinary/neeto-message-templates-frontend
64
+ ```
65
+
66
+ ## MessageTemplates
67
+
68
+ ### Props
69
+
70
+ - `shouldIncludeTestTemplate`: A boolean value to determines whether test
71
+ message template option to be included.
72
+
73
+ - `handleSubmitTestTemplate`: The function in the host app that handles
74
+ submitting values to send test templates for email and sms.
75
+
76
+ - `isTestMessageLoading`: A boolean value that determines whether the test
77
+ template handle submit is loading or not.
78
+
79
+ - `type`: Type can be `email`, `sms` or `whatsapp`.
80
+
81
+ ### Usage
82
+
83
+ ```javascript
84
+ import React from "react";
85
+
86
+ import { MessageTemplates } from "@bigbinary/neeto-message-templates-frontend";
87
+
88
+ const App = () => {
89
+ const breadcrumbs = [
90
+ {
91
+ link: "/settings",
92
+ text: "Settings",
93
+ },
94
+ ];
95
+ const handleSubmit = () => {
96
+ //api call
97
+ };
98
+
99
+ return (
100
+ <MessageTemplates
101
+ shouldIncludeTestTemplate
102
+ breadcrumbs={breadcrumbs}
103
+ handleSubmitTestTemplate={handleSubmit}
104
+ isTestMessageLoading={isTestMessageLoading}
105
+ type={type}
106
+ />
107
+ );
108
+ };
109
+ ```
110
+
111
+ ## SendMessagePane
112
+
113
+ ### Props
114
+
115
+ - `isOpen`: To open the side pane.
116
+
117
+ - `onClose`: To close the side pane.
118
+
119
+ * `handleSubmit`: The function in the host app which is used to send sms and
120
+ email.
121
+
122
+ * `type`: Type can be `email`, `sms` or `whatsapp`.
123
+
124
+ ### Usage
125
+
126
+ ```javascript
127
+ import React, { useState } from "react";
128
+
129
+ import { SendMessagePane } from "@bigbinary/neeto-message-templates-frontend";
130
+
131
+ const App = () => {
132
+ const [isPaneOpen, setIsPaneOpen] = useState(false);
133
+
134
+ const handleSubmit = () => {
135
+ //api call
136
+ };
137
+
138
+ return (
139
+ <SendMessagePane
140
+ handleSubmit={handleSubmit}
141
+ isOpen={isPaneOpen}
142
+ type={type}
143
+ onClose={() => setIsPaneOpen(false)}
144
+ />
145
+ );
146
+ };
147
+ ```
148
+
149
+ # Development
150
+
151
+ ### Engine
152
+
153
+ 1. Add this line to your application's Gemfile (replace the path to the local
154
+ copy of neeto-message-templates-engine):
155
+
156
+ ```ruby
157
+ gem 'neeto-message-templates-engine', path: '../neeto-message-templates-engine'
158
+ ```
159
+
160
+ 2. And then execute:
161
+
162
+ ```shell
163
+ bundle install
164
+ ```
165
+
166
+ 3. Refer [engine installation](#engine-installation) steps 3, 4, 5 and 6.
167
+
168
+ ### Frontend Package
169
+
170
+ The usage of `yalc` is explained in this video:
171
+ https://www.youtube.com/watch?v=QBiYGP0Rhe0
172
+
173
+ 1. See the changes in the host app by executing the following command \
174
+ <br/> Use this command if releasing package for the first time.
175
+
176
+ ```shell
177
+ yarn build && yalc publish
178
+ ```
179
+
180
+ Use this command to see changes after the initial publish.
181
+
182
+ ```shell
183
+ yarn release
184
+ ```
185
+
186
+ # Setup dummy host app
187
+
188
+ Setup
189
+ [Instructions](https://github.com/bigbinary/neeto-engineering/tree/main/Local-Development-Setup).
190
+
191
+ Visit http://spinkart.lvh.me:9014 and login with email `oliver@example.com` and
192
+ password `welcome`.
193
+
194
+ ### Additional Instructions
195
+
196
+ - Run `yarn build` to bundle the app.