@bigbinary/neeto-email-notifications-frontend
v2.2.6
Published
A repo acts as the source of truth for the new nano's structure, configs, data etc.
Downloads
1,229
Readme
neeto-email-notifications-nano
The neeto-email-notifications-nano enables the management of email notifications within neeto applications. The nano exports the @bigbinary/neeto-email-notifications-frontend NPM package and neeto-email-notifications-engine Rails engine for development.
Contents
Development with Host Application
Engine
The engine is used to manage email notifications across neeto products.
Installation
Add this line to your application's Gemfile:
source "NEETO_GEM_SERVER_URL" do # Rails engine to manage email notifications gem "neeto-email-notifications-engine" end
And then execute:
bundle install
Add this line to your application's
config/routes.rb
file (replaceat
to your desired route):mount NeetoEmailNotificationsEngine::Engine, at: "/neeto_email_notifications"
Add required migrations in the
db/migrate
folder. Run the following commands to generate the migrations.rails g neeto_email_notifications_engine:install
This will generate the migration to create the
neeto_email_notifications_engine_email_notifications
table, which holds the data for the email notifications, and havecustom_fields
column to include custom attributesRun the following command to create the tables.
rails db:migrate
Usage
Create required email notification models inherited from
NeetoEmailNotificationsEngine::EmailNotification
. For example,class PushEmailNotification < ::NeetoEmailNotificationsEngine::EmailNotification default_scope { where("custom_fields -> 'notification_type' ? :value", value: "Push") } after_initialize :set_custom_field def set_custom_field self.custom_fields ||= {} self.custom_fields[custom_field_key] = "Push" end def custom_field_key "notification_type" end end
Add the required associations to the polymorphic model. For example,
class Form < ApplicationRecord .... has_many :email_notifications, as: :notification_holder, class_name: "::NeetoEmailNotificationsEngine::EmailNotification", dependent: :destroy has_one :push_email_notification, as: :notification_holder .... end
You can learn more about the setup and usage here:
Frontend package
Installation
Add the
neeto-email-notifications-frontend
package to thepackage.json
yarn add @bigbinary/neeto-email-notifications-frontend
This package will provide a single component
NeetoEmailNotification
, which uses components fromneeto-molecules
.
Instructions for development
Check the Frontend package development guide for step-by-step instructions to develop the frontend package.
Usage
- Add the component to the host application. For example,
<NeetoEmailNotificationForm title="Email notification" subtitle="Send an email notification when a new event occurred" emailPreviewProps={{ productName: "Product" }} emailNotificationParams={{ notificationHolderType: "Form", notificationHolderId: formId, customFields: { notificationType: "Push" }, }} />
NeetoEmailNotificationForm
The component is a form-based interface for adding or editing team members.
Props
title
: The title of the component.subtitle
: The subtitle of the component.onSuccess
: Function that will be called when the email notification is updated successfully.disabled
: Disables the component.
You can learn more about the NeetoEmailNotificationForm component and usage here:
Instructions for Publishing
Consult the building and releasing packages guide for details on how to publish.