first commit

This commit is contained in:
2024-11-10 21:08:49 +01:00
commit 0d932ce5ee
14455 changed files with 2567501 additions and 0 deletions

View File

@@ -0,0 +1,597 @@
/* global stockalertappLocalizer */
import React from 'react';
import Select from 'react-select';
import axios from 'axios';
export default class DynamicForm extends React.Component {
state = {};
constructor(props) {
super(props);
this.state = {
datamclist: [],
from_loading: false,
errordisplay: ''
};
this.handle_get_mailchimp_list = this.handle_get_mailchimp_list.bind(this);
}
handle_get_mailchimp_list() {
axios
.get(
`${stockalertappLocalizer.apiUrl}/mvx_stockalert_pro/v1/get_mailchimp_list`,
)
.then((response) => {
this.setState({
datamclist: response.data,
});
});
}
onSubmit = (e) => {
// block to refresh pages
const prop_submitbutton =
this.props.submitbutton && this.props.submitbutton === 'false'
? ''
: 'true';
if (prop_submitbutton) {
e.preventDefault();
}
this.setState({ from_loading: true });
axios({
method: this.props.method,
url: stockalertappLocalizer.apiUrl + '/' + this.props.url,
data: {
model: this.state,
modulename: this.props.modulename,
},
}).then((res) => {
this.setState({
from_loading: false,
errordisplay: res.data.error,
});
setTimeout(() => {
this.setState({ errordisplay: '' });
}, 2000);
if (res.data.redirect_link) {
window.location.href = res.data.redirect_link;
}
});
};
componentDidMount() {
//Fetch all datas
this.props.model.map((m) => {
this.setState({
[m.key]: m.database_value,
});
});
this.handle_get_mailchimp_list();
}
onChange = (e, key, type = 'single', from_type = '', array_values = []) => {
if (type === 'single') {
if (from_type === 'select') {
this.setState(
{
[key]: array_values[e.index],
},
() => {}
);
} else if (from_type === 'mailchimp_select') {
this.setState(
{
[key]: array_values[e.index],
},
() => {}
);
} else if (from_type === 'multi-select') {
this.setState(
{
[key]: e,
},
() => {}
);
} else if (from_type === 'text_api') {
this.setState(
{
[key]: e.target.value,
},
() => {}
);
this.setState({
datamclist: [],
});
this.setState({
selected_mailchimp_list: '',
});
} else {
this.setState(
{
[key]: e.target.value,
},
() => {}
);
}
} else {
// Array of values (e.g. checkbox): TODO: Optimization needed.
const found = this.state[key]
? this.state[key].find((d) => d === e.target.value)
: false;
if (found) {
const data = this.state[key].filter((d) => {
return d !== found;
});
this.setState({
[key]: data,
});
} else {
const others = this.state[key] ? [...this.state[key]] : [];
this.setState({
[key]: [e.target.value, ...others],
});
}
}
if (this.props.submitbutton && this.props.submitbutton === 'false') {
if (key != 'password') {
setTimeout(() => {
this.onSubmit('');
}, 10);
}
}
};
renderForm = () => {
const model = this.props.model;
const formUI = model.map((m, index) => {
const key = m.key;
const type = m.type || 'text';
const props = m.props || {};
const name = m.name;
let value = m.value;
const placeholder = m.placeholder;
const limit = m.limit;
let input = '';
const target = key;
value = this.state[target] || '';
if (
m.restricted_page &&
m.restricted_page === this.props.location
) {
return false;
}
// If no array key found
if (!m.key) {
return false;
}
// for checkbox selection
if (
m.depend_checkbox &&
this.state[m.depend_checkbox] &&
this.state[m.depend_checkbox].length === 0
) {
return false;
}
// for checkbox selection
if (
m.not_depend_checkbox &&
this.state[m.not_depend_checkbox] &&
this.state[m.not_depend_checkbox].length > 0
) {
return false;
}
if (m.depend && !this.state[m.depend]) {
return false;
}
if (type === 'text' || 'url' || 'password' || 'email' || 'number') {
input = (
<div className="mvx-settings-basic-input-class">
<input
{...props}
className="mvx-setting-form-input"
type={type}
key={key}
id={m.id}
placeholder={placeholder}
name={name}
value={value}
onChange={(e) => {
this.onChange(e, target);
}}
/>
{m.desc ? (
<p
className="mvx-settings-metabox-description"
dangerouslySetInnerHTML={{ __html: m.desc }}
></p>
) : (
''
)}
</div>
);
}
if (type === 'color') {
input = (
<div className="mvx-settings-color-picker-parent-class">
<input
{...props}
className="mvx-setting-color-picker"
type={type}
key={key}
id={m.id}
name={name}
value={value}
onChange={(e) => {
this.onChange(e, target);
}}
/>
{m.desc ? (
<p
className="mvx-settings-metabox-description"
dangerouslySetInnerHTML={{ __html: m.desc }}
></p>
) : (
''
)}
</div>
);
}
if (type === 'blocktext') {
input = (
<div className="mvx-blocktext-class">
{m.blocktext ? (
<p
className="mvx-settings-metabox-description-code"
dangerouslySetInnerHTML={{
__html: m.blocktext,
}}
></p>
) : (
''
)}
</div>
);
}
if (type === 'textarea') {
input = (
<div className="mvx-setting-from-textarea">
<textarea
{...props}
className={m.class ? m.class : 'mvx-form-input'}
key={key}
maxLength={limit}
placeholder={placeholder}
name={name}
value={value}
rows="4"
cols="50"
onChange={(e) => {
this.onChange(e, target);
}}
/>
{m.desc ? (
<p
className="mvx-settings-metabox-description"
dangerouslySetInnerHTML={{ __html: m.desc }}
></p>
) : (
''
)}
</div>
);
}
if (type === 'select') {
const options_data = [];
const defaultselect = [];
input = m.options.map((o, index) => {
if (o.selected) {
defaultselect[index] = {
value: o.value,
label: o.label,
index,
};
}
options_data[index] = {
value: o.value,
label: o.label,
index,
};
});
input = (
<div className="mvx-form-select-field-wrapper">
<Select
className={key}
value={value ? value : ''}
options={options_data}
onChange={(e) => {
this.onChange(
e,
m.key,
'single',
type,
options_data
);
}}
></Select>
{m.desc ? (
<p
className="mvx-settings-metabox-description"
dangerouslySetInnerHTML={{ __html: m.desc }}
></p>
) : (
''
)}
</div>
);
}
if (type === 'mailchimp_select') {
const options_data = [];
const defaultselect = [];
var selected_val = value;
input = this.state.datamclist.map((o, index) => {
if (o.selected) {
defaultselect[index] = {
value: o.value,
label: o.label,
index,
};
}
options_data[index] = {
value: o.value,
label: o.label,
index,
};
});
input = (
<div className="mvx-form-select-field-wrapper">
<Select
className={key}
value={selected_val ? selected_val : ''}
options={options_data}
onChange={(e) => {
this.onChange(
e,
m.key,
'single',
type,
options_data
);
}}
></Select>
{m.desc ? (
<p
className="mvx-settings-metabox-description"
dangerouslySetInnerHTML={{ __html: m.desc }}
></p>
) : (
''
)}
</div>
);
}
if (type === 'button') {
input = (
<div className="mvx-button">
<input
className="btn default-btn"
type="button"
value="Connect to Mailchimp"
onClick={(e) =>
this.handle_get_mailchimp_list()
}
/>
{m.desc ? (
<p
className="mvx-settings-metabox-description"
dangerouslySetInnerHTML={{
__html: m.desc,
}}
></p>
) : (
''
)}
</div>
);
}
if (type === 'text_api') {
input = (
<div className="mvx-settings-basic-input-class">
<input
{...props}
className="mvx-setting-form-input"
type={type}
key={key}
id={m.id}
placeholder={placeholder}
name={name}
value={value}
onChange={(e) => {
this.onChange(e, target, 'single', type,);
}}
/>
{m.desc ? (
<p
className="mvx-settings-metabox-description"
dangerouslySetInnerHTML={{ __html: m.desc }}
></p>
) : (
''
)}
</div>
);
}
if (type === 'checkbox') {
input = (
<div
className={
m.right_content
? 'mvx-checkbox-list-side-by-side'
: m.parent_class
? 'mvx-checkbox-list-side-by-side'
: ''
}
>
{m.select_deselect ? (
<div
className="mvx-select-deselect-trigger"
onClick={(e) => {
this.onSelectDeselectChange(e, m);
}}
>
Select / Deselect All
</div>
) : (
''
)}
{m.options.map((o) => {
//let checked = o.value === value;
let checked = false;
if (value && value.length > 0) {
checked =
value.indexOf(o.value) > -1 ? true : false;
}
return (
<div
className={
m.right_content
? 'mvx-toggle-checkbox-header'
: m.parent_class
? m.parent_class
: ''
}
>
<React.Fragment key={'cfr' + o.key}>
{m.right_content ? (
<p
className="mvx-settings-metabox-description"
dangerouslySetInnerHTML={{
__html: o.label,
}}
></p>
) : (
''
)}
<div className="mvx-toggle-checkbox-content">
<input
{...props}
className={m.class}
type={type}
id={`mvx-toggle-switch-${o.key}`}
key={o.key}
name={o.name}
checked={checked}
value={o.value}
onChange={(e) => {
this.onChange(
e,
m.key,
'multiple'
);
}}
/>
<label
htmlFor={`mvx-toggle-switch-${o.key}`}
></label>
</div>
{m.right_content ? (
''
) : (
<p
className="mvx-settings-metabox-description"
dangerouslySetInnerHTML={{
__html: o.label,
}}
></p>
)}
{o.hints ? (
<span className="dashicons dashicons-info">
<div className="mvx-hover-tooltip">
{o.hints}
</div>
</span>
) : (
''
)}
</React.Fragment>
</div>
);
})}
{m.desc ? (
<p
className="mvx-settings-metabox-description"
dangerouslySetInnerHTML={{ __html: m.desc }}
></p>
) : (
''
)}
</div>
);
}
return m.type === 'section' || m.label === 'no_label' ? (
input
) : (
<div key={'g' + key} className="mvx-form-group">
<label
className="mvx-settings-form-label"
key={'l' + key}
htmlFor={key}
>
<p dangerouslySetInnerHTML={{ __html: m.label }}></p>
</label>
<div className="mvx-settings-input-content">{input}</div>
</div>
);
});
return formUI;
};
render() {
const prop_submitbutton =
this.props.submitbutton && this.props.submitbutton === 'false'
? ''
: 'true';
return (
<div className="mvx-dynamic-fields-wrapper">
{this.state.errordisplay ? (
<div className="mvx-notic-display-title">
<i className="mvx-woo-stock-alert icon-success-notification"></i>
{this.state.errordisplay}
</div>
) : (
''
)}
<form
className="mvx-dynamic-form"
onSubmit={(e) => {
this.onSubmit(e);
}}
>
{this.renderForm()}
</form>
</div>
);
}
}

View File

@@ -0,0 +1,21 @@
/* global stockalertappLocalizer */
import React, { Component } from 'react';
class Banner extends Component {
render() {
return (
<div className="mvx-sidebar">
<div className="mvx-banner-right">
<div className="mvx-logo-right">
<a href="https://multivendorx.com/contact-us/">
<img
src={ stockalertappLocalizer.banner_img }
alt="right-banner"
/>
</a>
</div>
</div>
</div>
);
}
}
export default Banner;

View File

@@ -0,0 +1,86 @@
import React, { Component } from 'react';
import { render } from 'react-dom';
import { BrowserRouter as Router, useLocation } from 'react-router-dom';
import MvxTab from './tabs';
import Subscriber from './subscriber';
class StockAlert_Backend_Endpoints_Load extends Component {
constructor(props) {
super(props);
this.state = {};
this.Stockalert_backend_endpoint_load = this.Stockalert_backend_endpoint_load.bind(this);
}
useQuery() {
return new URLSearchParams(useLocation().hash);
}
Stockalert_backend_endpoint_load() {
// For active submneu pages
const $ = jQuery;
const menuRoot = $( '#toplevel_page_' + 'woo-stock-alert-setting' );
const currentUrl = window.location.href;
const currentPath = currentUrl.substr(
currentUrl.indexOf( 'admin.php' )
);
menuRoot.on( 'click', 'a', function () {
const self = $( this );
$( 'ul.wp-submenu li', menuRoot ).removeClass( 'current' );
if ( self.hasClass( 'wp-has-submenu' ) ) {
$( 'li.wp-first-item', menuRoot ).addClass( 'current' );
} else {
self.parents( 'li' ).addClass( 'current' );
}
} );
$( 'ul.wp-submenu a', menuRoot ).each( function ( index, el ) {
if ( $( el ).attr( 'href' ) === currentPath ) {
$( el ).parent().addClass( 'current' );
} else {
$( el ).parent().removeClass( 'current' );
// if user enter page=catalog
if (
$( el ).parent().hasClass( 'wp-first-item' ) &&
currentPath === 'admin.php?page=woo-stock-alert-setting'
) {
$( el ).parent().addClass( 'current' );
}
}
} );
const location = this.useQuery();
if (
location.get('tab') &&
location.get('tab') === 'settings'
) {
return <MvxTab
model='stock_alert-settings'
query_name={location.get('tab')}
subtab={location.get('subtab')}
funtion_name={this}
/>;
} else if(
location.get('tab') &&
location.get('tab') === 'subscriber-list'
) {
return <Subscriber/>;
} else {
return <MvxTab
model='stock_alert-settings'
query_name='settings'
subtab='general'
funtion_name={this}
/>;
}
}
render() {
return (
<Router>
<this.Stockalert_backend_endpoint_load />
</Router>
);
}
}
export default StockAlert_Backend_Endpoints_Load;

View File

@@ -0,0 +1,506 @@
/*stockalertstockalertappLocalizer*/
import React, { Component } from 'react';
import { BrowserRouter as Router, Link, useLocation } from 'react-router-dom';
import Select from 'react-select';
import axios from 'axios';
import { CSVLink } from 'react-csv';
import DataTable from 'react-data-table-component';
import PuffLoader from 'react-spinners/PuffLoader';
import { css } from '@emotion/react';
import DateRangePicker from 'rsuite/DateRangePicker';
const override = css`
display: block;
margin: 0 auto;
border-color: red;
`;
class Subscriber extends Component {
constructor(props) {
super(props);
this.state = {
subscriber_loading: false,
subscription_list_status_all: false,
all_subscriber_list: [],
data_subscriber: [],
data_unsubscriber: [],
data_email_sent_subscriber: [],
data_trash_subscriber: [],
datasubscriber: [],
columns_subscriber_list: [],
date_range: ''
};
this.onSubChange = this.onSubChange.bind(this);
this.handle_subscription_live_search = this.handle_subscription_live_search.bind(this);
this.handlesubscriptionsearch = this.handlesubscriptionsearch.bind(this);
this.handleupdatesub = this.handleupdatesub.bind(this);
}
handleupdatesub(e) {
this.setState({
date_range: e,
});
axios
.get(
`${stockalertappLocalizer.apiUrl}/mvx_stockalert_pro/v1/show_subscribe_from_status_list`,
{
params: { date_range: e },
}
).then((response) => {
this.setState({
datasubscriber: response.data,
});
});
}
onSubChange(e, name) {
}
handlesubscriptionsearch(e, status) {
if (status === 'searchproduct') {
if (e) {
axios
.get(
`${stockalertappLocalizer.apiUrl}/mvx_stockalert_pro/v1/search_subscribe_by_product`,
{
params: { product: e.value, date_range: this.state.date_range },
}
)
.then((response) => {
this.setState({
datasubscriber: response.data,
});
});
} else {
axios
.get(
`${stockalertappLocalizer.apiUrl}/mvx_stockalert_pro/v1/show_subscribe_from_status_list`,
{
params: { date_range: this.state.date_range },
}
).then((response) => {
this.setState({
datasubscriber: response.data,
});
});
}
}
}
handle_subscription_live_search(e) {
if (e.target.value) {
axios
.get(
`${stockalertappLocalizer.apiUrl}/mvx_stockalert_pro/v1/search_specific_subscribe`,
{
params: { email_id: e.target.value },
}
)
.then((response) => {
this.setState({
datasubscriber: response.data,
});
});
} else {
axios
.get(
`${stockalertappLocalizer.apiUrl}/mvx_stockalert_pro/v1/show_subscribe_from_status_list`,
{
params: { date_range: this.state.date_range },
}
).then((response) => {
this.setState({
datasubscriber: response.data,
});
});
}
}
handle_subscription_status_check(e, type) {
if (type === 'subscribe') {
this.setState({
subscription_list_status_all: false,
subscription_list_status_subscription: true,
subscription_list_status_unsubscription: false,
subscription_list_status_mail_sent: false,
subscription_list_status_trush: false,
});
// subscribe status
axios
.get(
`${stockalertappLocalizer.apiUrl}/mvx_stockalert_pro/v1/show_subscribe_from_status_list`,
{
params: { subscription_status: 'woo_subscribed' },
}
)
.then((response) => {
this.setState({
datasubscriber: response.data
});
});
}
if (type === 'unsubscribe') {
// unsubscribe status
this.setState({
subscription_list_status_all: false,
subscription_list_status_subscription: false,
subscription_list_status_unsubscription: true,
subscription_list_status_mail_sent: false,
subscription_list_status_trush: false,
});
axios
.get(
`${stockalertappLocalizer.apiUrl}/mvx_stockalert_pro/v1/show_subscribe_from_status_list`,
{
params: { subscription_status: 'woo_unsubscribed' },
}
)
.then((response) => {
this.setState({
datasubscriber: response.data,
});
});
}
if (type === 'mail_sent') {
// refunded status
this.setState({
subscription_list_status_all: false,
subscription_list_status_subscription: false,
subscription_list_status_unsubscription: false,
subscription_list_status_mail_sent: true,
subscription_list_status_trush: false,
});
axios
.get(
`${stockalertappLocalizer.apiUrl}/mvx_stockalert_pro/v1/show_subscribe_from_status_list`,
{
params: { subscription_status: 'woo_mailsent' },
}
)
.then((response) => {
console.log(response.data);
this.setState({
datasubscriber: response.data,
});
});
}
if (type === 'all') {
this.setState({
commission_list_status_all: true,
commission_list_status_paid: false,
commission_list_status_unpaid: false,
commission_list_status_trash: false,
commission_list_status_refunded: false,
});
axios
.get(
`${stockalertappLocalizer.apiUrl}/mvx_stockalert_pro/v1/show_subscribe_from_status_list`,
{
params: { date_range: this.state.date_range },
}
).then((response) => {
this.setState({
datasubscriber: response.data,
});
});
}
}
common_funtions = (e) => {
// subscribe status
axios
.get(
`${stockalertappLocalizer.apiUrl}/mvx_stockalert_pro/v1/no_of_subscribe_list`,
{
params: { subscribtion_status: 'woo_subscribed', date_range: this.state.date_range },
}
)
.then((response) => {
this.setState({
data_subscriber: response.data,
});
});
// unsubscribe status
axios
.get(
`${stockalertappLocalizer.apiUrl}/mvx_stockalert_pro/v1/no_of_subscribe_list`,
{
params: { subscribtion_status: 'woo_unsubscribed', date_range: this.state.date_range },
}
)
.then((response) => {
this.setState({
data_unsubscriber: response.data,
});
});
// mail sent status
axios
.get(
`${stockalertappLocalizer.apiUrl}/mvx_stockalert_pro/v1/no_of_subscribe_list`,
{
params: { subscribtion_status: 'woo_mailsent', date_range: this.state.date_range },
}
)
.then((response) => {
this.setState({
data_email_sent_subscriber: response.data,
});
});
// trash status
axios
.get(
`${stockalertappLocalizer.apiUrl}/mvx_stockalert_pro/v1/no_of_subscribe_list`,
{
params: { subscribtion_status: 'trash', date_range: this.state.date_range },
}
)
.then((response) => {
this.setState({
data_trash_subscriber: response.data,
});
});
};
componentDidMount() {
this.common_funtions('');
axios
.get(
`${stockalertappLocalizer.apiUrl}/mvx_stockalert_pro/v1/show_subscribe_from_status_list`,
{
params: { date_range: this.state.date_range },
}
).then((response) => {
this.setState({
datasubscriber: response.data,
all_subscriber_list: response.data,
subscriber_loading: true,
});
});
stockalertappLocalizer.columns_subscriber.map((data_sub, index_sub) => {
let data_selector_sub = '';
let set_for_dynamic_column_sub = '';
data_selector_sub = data_sub.selector_choice;
data_sub.selector = (row) => (
<div
dangerouslySetInnerHTML={{
__html: row[data_selector_sub],
}}
></div>
);
this.state.columns_subscriber_list[index_sub] =
data_sub;
set_for_dynamic_column_sub =
this.state.columns_subscriber_list;
this.state.columns_subscriber_list =
set_for_dynamic_column_sub;
});
}
render() {
return (
<div className="mvx-subscriber-list">
<div className="mvx-container">
<div className="mvx-middle-container-wrapper">
<div className="mvx-page-title">
<p>
Subscriber list
</p>
<div className="pull-right">
<CSVLink
data={this.state.datasubscriber}
headers={stockalertappLocalizer.columns_subscriber_list}
filename={'Subscribers.csv'}
className="mvx-btn btn-purple"
>
<i className="mvx-font icon-download"></i>
{
stockalertappLocalizer.download_csv
}
</CSVLink>
</div>
</div>
<div className="mvx-search-and-multistatus-wrap">
<ul className="mvx-multistatus-ul">
<li className={`mvx-multistatus-item ${this.state.subscription_list_status_all ? 'status-active' : ''}`}>
<div
className="mvx-multistatus-check-all status-active"
onClick={(e) =>
this.handle_subscription_status_check(
e,
'all'
)
}
>
{
stockalertappLocalizer
.subscription_page_string.all
}{' '}
(
{
this.state
.all_subscriber_list
.length
}
)
</div>
</li>
<li className="mvx-multistatus-item mvx-divider"></li>
<li className={`mvx-multistatus-item ${this.state.subscription_list_status_subscription ? 'status-active' : ''}`}>
<div
className="mvx-multistatus-check-subscribe"
onClick={(e) =>
this.handle_subscription_status_check(
e,
'subscribe'
)
}
>
{
stockalertappLocalizer
.subscription_page_string.subscribe
}{' '}
(
{
this.state.data_subscriber
}
)
</div>
</li>
<li className="mvx-multistatus-item mvx-divider"></li>
<li className={`mvx-multistatus-item ${this.state.subscription_list_status_unsubscription ? 'status-active' : ''}`}>
<div
className="mvx-multistatus-check-unpaid"
onClick={(e) =>
this.handle_subscription_status_check(
e,
'unsubscribe'
)
}
>
{
stockalertappLocalizer
.subscription_page_string
.unsubscribe
}{' '}
(
{
this.state
.data_unsubscriber
}
)
</div>
</li>
<li className="mvx-multistatus-item mvx-divider"></li>
<li className={`mvx-multistatus-item ${this.state.subscription_list_status_mail_sent ? 'status-active' : ''}`}>
<div
className="mvx-multistatus-check-unpaid"
onClick={(e) =>
this.handle_subscription_status_check(
e,
'mail_sent'
)
}
>
{
stockalertappLocalizer
.subscription_page_string
.mail_sent
}{' '}
(
{
this.state
.data_email_sent_subscriber
}
)
</div>
</li>
</ul>
<div className="mvx-header-search-section">
<label>
<i className="mvx-font icon-search"></i>
</label>
<input
type="text"
placeholder={
stockalertappLocalizer
.subscription_page_string
.search
}
onChange={
this.handle_subscription_live_search
}
/>
</div>
</div>
<div className="mvx-wrap-bulk-all-date">
<Select
placeholder={
stockalertappLocalizer.subscription_page_string
.show_product
}
options={stockalertappLocalizer.subscription_page_string.product_select}
isClearable={true}
className="mvx-wrap-bulk-action"
onChange={(e) =>
this.handlesubscriptionsearch(
e,
'searchproduct'
)
}
/>
<DateRangePicker
onChange={(e) => this.handleupdatesub(e)}
/>
</div>
{this.state.columns_subscriber_list &&
this.state.columns_subscriber_list.length > 0 &&
this.state.subscriber_loading ? (
<div className="mvx-backend-datatable-wrapper">
<DataTable
columns={
this.state.columns_subscriber_list
}
data={this.state.datasubscriber}
selectableRows
// onSelectedRowsChange={
// this.handleSelectRowsChange
// }
pagination
/>
</div>
) : (
<PuffLoader
css={override}
color={'#cd0000'}
size={200}
loading={true}
/>
)}
</div>
</div>
</div>
);
}
}
export default Subscriber;

View File

@@ -0,0 +1,159 @@
/* global stockalertappLocalizer */
import React, { Component } from 'react';
import { BrowserRouter as Router, Link } from 'react-router-dom';
import axios from 'axios';
import BannerSection from './banner';
import DynamicForm from './DynamicForm';
import PuffLoader from 'react-spinners/PuffLoader';
import { css } from '@emotion/react';
const override = css`
display: block;
margin: 0 auto;
border-color: red;
`;
export default class TabSection extends Component {
state = {};
constructor(props) {
super(props);
this.state = {
fetch_admin_tabs: [],
current: {},
current_url: '',
};
console.log(this.props.subtab);
}
renderTab = () => {
const horizontally = this.props.horizontally;
const query_name = this.props.query_name;
if (this.props.subtab !== this.state.current_url) {
axios({
url: `${stockalertappLocalizer.apiUrl}/mvx_stockalert/v1/fetch_admin_tabs`,
}).then((response) => {
this.setState({
fetch_admin_tabs: response.data ? response.data[this.props.model] : [],
current_url: this.props.subtab
});
});
}
const model = this.state.fetch_admin_tabs ? this.state.fetch_admin_tabs : [];
const TabUI = Object.entries(model).length > 0 ? Object.entries(model).map((m, index) => {
return this.props.subtab === m[0] ? (
<div className="mvx-tab-description-start">
<div className="mvx-tab-name">{m[1].tablabel}</div>
<p>{m[1].description}</p>
</div>
) : (
''
);
}) : '';
const TabUIContent = (
<div className={`mvx-general-wrapper mvx-${this.props.subtab}`}>
<div className="mvx-container mvx-tab-banner-wrap">
<div
className={`mvx-middle-container-wrapper ${
horizontally
? 'mvx-horizontal-tabs'
: 'mvx-vertical-tabs'
}`}
>
{this.props.tab_description &&
this.props.tab_description === 'no'
? ''
: TabUI}
<div className="mvx-middle-child-container">
{this.props.no_tabs ? (
''
) : (
<div className="mvx-current-tab-lists">
{Object.entries(model).length > 0 ? Object.entries(model).map((m, index) => {
return m[1].link ? (
<a className={m[1].class} href={m[1].link}>
{m[1].icon ? (
<i
className={`stock-alert ${m[1].icon}`}
></i>
) : (
''
)}
{m[1].tablabel}
</a>
) : (
<Link
className={
this.props.subtab ===
m[0]
? 'active-current-tab'
: ''
}
to={
`?page=woo-stock-alert-setting#&tab=${query_name}&subtab=${m[0]}`
}
>
{m[1].icon ? (
<i
className={`stock-alert ${m[1].icon}`}
></i>
) : (
''
)}
{m[1].tablabel}
</Link>
);
}) : ''}
</div>
)}
<div className="mvx-tab-content">
{
model && Object.entries(model).length > 0 && this.props.subtab === this.state.current_url ? Object.entries(model).map((m, index) => (
m[0] === this.props.subtab && m[1].modulename && m[1].modulename.length > 0 ?
<DynamicForm
key={`dynamic-form-${m[0]}`}
title={m[1].tablabel}
defaultValues={this.state.current}
model={
m[1].modulename
}
method="post"
modulename={m[0]}
url={`mvx_stockalert/v1/${m[1].apiurl}`}
submitbutton="false"
/>
: (
''
)
)) :
<PuffLoader
css={override}
color={'#cd0000'}
size={200}
loading={true}
/>
}
</div>
</div>
</div>
{ <BannerSection /> }
</div>
</div>
);
return TabUIContent;
};
render() {
return this.renderTab();
}
}

View File

@@ -0,0 +1,9 @@
import { render } from '@wordpress/element';
import StockAlert from "./admin/stockalert";
/**
* Import the stylesheet for the plugin.
*/
import './style/main.scss';
// Render the App component into the DOM
render(<StockAlert />, document.getElementById('mvx-admin-stockalert'));

View File

@@ -0,0 +1,16 @@
<?xml version="1.0" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd" >
<svg xmlns="http://www.w3.org/2000/svg">
<metadata>Generated by IcoMoon</metadata>
<defs>
<font id="mvx-woo-stockalert" horiz-adv-x="1024">
<font-face units-per-em="1024" ascent="960" descent="-64" />
<missing-glyph horiz-adv-x="1024" />
<glyph unicode="&#x20;" horiz-adv-x="512" d="" />
<glyph unicode="&#xe900;" glyph-name="form-customization" d="M163.2 956.8c172.8 0 348.8 0 521.6 0 3.2 0 3.2 0 6.4-3.2 92.8-12.8 160-89.6 160-182.4 0-86.4 0-169.6 0-256 0-28.8-19.2-44.8-44.8-48-16 0-32 0-48-3.2-172.8-25.6-288-198.4-246.4-368 6.4-32 22.4-64 38.4-92.8 19.2-28.8 6.4-57.6-25.6-67.2 0 0-3.2 0-3.2-3.2-118.4 0-240 0-358.4 0-12.8 3.2-25.6 6.4-35.2 9.6-76.8 28.8-128 99.2-128 179.2 0 144 0 284.8 0 428.8 0 76.8 0 153.6 0 230.4 3.2 76.8 41.6 131.2 112 163.2 16 6.4 35.2 9.6 51.2 12.8zM371.2 601.6c57.6 0 112 0 169.6 0 32 0 51.2 25.6 44.8 54.4-3.2 19.2-22.4 32-44.8 32-67.2 0-134.4 0-201.6 0-48 0-92.8 0-140.8 0-22.4 0-38.4-9.6-41.6-28.8-9.6-28.8 9.6-57.6 44.8-57.6 54.4-3.2 112 0 169.6 0zM320 460.8c-38.4 0-80 0-118.4 0-16 0-28.8-6.4-38.4-19.2-19.2-28.8 0-64 35.2-64 83.2 0 163.2 0 246.4 0 6.4 0 12.8 3.2 19.2 6.4 16 9.6 25.6 28.8 19.2 51.2-3.2 16-22.4 28.8-41.6 28.8-41.6-3.2-83.2-3.2-121.6-3.2zM284.8 156.8c28.8 0 57.6 0 86.4 0 25.6 0 44.8 19.2 44.8 41.6 0 25.6-16 44.8-41.6 44.8-57.6 0-118.4 0-176 0-19.2 0-35.2-12.8-38.4-28.8-9.6-28.8 9.6-57.6 41.6-57.6 25.6 0 54.4 0 83.2 0zM841.6 393.6c-9.6 9.6-16 9.6-25.6 0-70.4-70.4-137.6-137.6-204.8-204.8 0-3.2-3.2-9.6-6.4-12.8 0-3.2 0-3.2-3.2-6.4 0 0 0-3.2 0-6.4s0-3.2 0-6.4l-12.8-76.8c0-3.2 0-6.4 3.2-9.6 3.2 0 3.2-3.2 6.4 0 6.4 0 16 3.2 22.4 3.2 16 3.2 35.2 6.4 51.2 9.6 19.2 3.2 32 9.6 48 25.6 44.8 44.8 89.6 89.6 131.2 131.2 16 16 35.2 35.2 51.2 51.2v0c3.2 3.2 3.2 3.2 6.4 6.4 6.4 6.4 6.4 16 0 19.2-19.2 28.8-44.8 54.4-67.2 76.8z" />
<glyph unicode="&#xe901;" glyph-name="form-submission" d="M163.2 956.8c172.8 0 348.8 0 521.6 0 3.2 0 3.2 0 6.4-3.2 92.8-12.8 160-89.6 160-182.4 0-86.4 0-169.6 0-256 0-28.8-19.2-44.8-44.8-48-16 0-32 0-48-3.2-172.8-25.6-288-198.4-246.4-368 6.4-32 22.4-64 38.4-92.8 19.2-28.8 6.4-57.6-25.6-67.2 0 0-3.2 0-3.2-3.2-118.4 0-240 0-358.4 0-12.8 3.2-25.6 6.4-35.2 9.6-76.8 28.8-128 99.2-128 179.2 0 144 0 284.8 0 428.8 0 76.8 0 153.6 0 230.4 3.2 76.8 41.6 131.2 112 163.2 16 6.4 35.2 9.6 51.2 12.8zM371.2 601.6c57.6 0 112 0 169.6 0 32 0 51.2 25.6 44.8 54.4-3.2 19.2-22.4 32-44.8 32-67.2 0-134.4 0-201.6 0-48 0-92.8 0-140.8 0-22.4 0-38.4-9.6-41.6-28.8-9.6-28.8 9.6-57.6 44.8-57.6 54.4-3.2 112 0 169.6 0zM320 460.8c-38.4 0-80 0-118.4 0-16 0-28.8-6.4-38.4-19.2-19.2-28.8 0-64 35.2-64 83.2 0 163.2 0 246.4 0 6.4 0 12.8 3.2 19.2 6.4 16 9.6 25.6 28.8 19.2 51.2-3.2 16-22.4 28.8-41.6 28.8-41.6-3.2-83.2-3.2-121.6-3.2zM284.8 156.8c28.8 0 57.6 0 86.4 0 25.6 0 44.8 19.2 44.8 41.6 0 25.6-16 44.8-41.6 44.8-57.6 0-118.4 0-176 0-19.2 0-35.2-12.8-38.4-28.8-9.6-28.8 9.6-57.6 41.6-57.6 25.6 0 54.4 0 83.2 0zM1020.8 230.4c-9.6 51.2-35.2 96-73.6 131.2-32 28.8-70.4 48-115.2 54.4-6.4 0-9.6 0-16 3.2-3.2 0-6.4 0-6.4 0h-28.8c-3.2 0-6.4 0-6.4 0-6.4 0-12.8 0-16-3.2-48-9.6-89.6-28.8-124.8-64s-54.4-76.8-64-124.8c0-6.4 0-9.6-3.2-16 0-3.2 0-3.2 0-6.4v-28.8c0-3.2 0-6.4 0-9.6 0-6.4 0-12.8 3.2-19.2 9.6-51.2 35.2-96 73.6-131.2 35.2-28.8 73.6-48 121.6-54.4 3.2 0 6.4 0 12.8 0 3.2 0 3.2 0 6.4 0h28.8c3.2 0 6.4 0 6.4 0 6.4 0 12.8 0 16 3.2 67.2 12.8 121.6 48 156.8 108.8 19.2 28.8 28.8 64 32 99.2 0 0 0 3.2 0 3.2s0 0 0 0v28.8c0 3.2 0 6.4 0 6.4-3.2 6.4-3.2 12.8-3.2 19.2zM921.6 236.8c0 0-3.2-3.2-3.2-3.2v0c-41.6-41.6-83.2-83.2-124.8-124.8-6.4-6.4-12.8-9.6-22.4-9.6-6.4 0-12.8 3.2-19.2 9.6l-16 16c-16 16-28.8 28.8-44.8 44.8-6.4 6.4-9.6 16-6.4 25.6s9.6 16 19.2 19.2c9.6 3.2 19.2 0 28.8-6.4 12.8-12.8 22.4-22.4 35.2-35.2l9.6-9.6c16 16 35.2 35.2 51.2 51.2 19.2 19.2 38.4 38.4 54.4 57.6 6.4 6.4 16 9.6 25.6 9.6 9.6-3.2 16-9.6 19.2-16 0-12.8-3.2-22.4-6.4-28.8z" />
<glyph unicode="&#xe902;" glyph-name="general" d="M1024 729.6c0 19.2-3.2 35.2-6.4 54.4-22.4 64-60.8 112-118.4 147.2-22.4 12.8-44.8 22.4-70.4 28.8-16 0-28.8-3.2-41.6 0-185.6 0-368 0-550.4 0-3.2 0-3.2 0-6.4 0-19.2-3.2-38.4-3.2-54.4-9.6-48-16-86.4-44.8-118.4-80-28.8-35.2-51.2-73.6-54.4-118.4-3.2-9.6-3.2-19.2-3.2-28.8 0-185.6 0-368 0-553.6 0-3.2 0-3.2 0-6.4 3.2-19.2 3.2-38.4 9.6-54.4 16-44.8 44.8-86.4 80-118.4 35.2-28.8 73.6-51.2 118.4-54.4 9.6 0 19.2 0 25.6-3.2 182.4 0 368 0 550.4 0 3.2 3.2 3.2 0 6.4 0 19.2 3.2 38.4 3.2 57.6 9.6 48 16 86.4 44.8 118.4 83.2 28.8 35.2 48 70.4 54.4 115.2 0 9.6 0 19.2 3.2 28.8 0 182.4 0 368 0 550.4-3.2 3.2 0 6.4 0 9.6zM777.6 313.6c-12.8-35.2-38.4-57.6-76.8-60.8-12.8-3.2-25.6 0-35.2 3.2-6.4 3.2-9.6 0-16-3.2-12.8-9.6-25.6-16-38.4-22.4-6.4-3.2-9.6-6.4-9.6-12.8-12.8-41.6-48-70.4-89.6-70.4s-76.8 28.8-89.6 70.4c-3.2 6.4-6.4 9.6-9.6 12.8-12.8 6.4-25.6 12.8-35.2 22.4-6.4 6.4-12.8 6.4-19.2 3.2-60.8-16-115.2 28.8-115.2 92.8 0 19.2 9.6 41.6 28.8 60.8 6.4 6.4 6.4 9.6 6.4 16 0 12.8 0 25.6 0 38.4 0 9.6 0 16-9.6 22.4-25.6 25.6-35.2 67.2-19.2 99.2 16 35.2 51.2 54.4 86.4 54.4 9.6 0 16-3.2 22.4-3.2 6.4-3.2 9.6 0 16 3.2 12.8 9.6 25.6 16 38.4 22.4 6.4 3.2 6.4 6.4 9.6 12.8 12.8 44.8 48 70.4 89.6 70.4s76.8-28.8 89.6-70.4c3.2-6.4 3.2-9.6 9.6-12.8 12.8-6.4 25.6-12.8 38.4-22.4 6.4-3.2 9.6-3.2 16-3.2 44.8 12.8 83.2-6.4 105.6-41.6s16-80-16-112c-3.2-3.2-6.4-9.6-6.4-16 0-16 0-28.8 0-44.8 0-6.4 0-9.6 6.4-16 25.6-22.4 35.2-54.4 22.4-92.8zM512 556.8c-57.6 0-108.8-48-108.8-108.8 0-57.6 48-108.8 108.8-108.8 57.6 0 108.8 48 108.8 108.8s-48 108.8-108.8 108.8zM512 384c-35.2 0-64 28.8-64 64s28.8 64 64 64c35.2 0 64-28.8 64-64s-28.8-64-64-64z" />
<glyph unicode="&#xe903;" glyph-name="live-preview" d="M764.8 672c48 12.8 99.2 28.8 147.2 41.6 16 3.2 28.8 9.6 44.8 12.8 35.2 9.6 67.2-12.8 67.2-48 0-153.6 0-304 0-457.6 0-38.4-32-60.8-67.2-51.2-60.8 19.2-121.6 35.2-182.4 54.4-9.6 3.2-9.6 6.4-9.6 12.8 3.2 12.8 3.2 25.6 3.2 38.4 0 115.2 0 230.4 0 345.6 0 16-3.2 32-3.2 51.2zM716.8 204.8v486.4c0 92.8-76.8 169.6-169.6 169.6h-377.6c-92.8 0-169.6-76.8-169.6-169.6v-483.2c0-92.8 76.8-169.6 169.6-169.6h377.6c92.8-3.2 169.6 73.6 169.6 166.4z" />
<glyph unicode="&#xe904;" glyph-name="email-setting" d="M60.8 614.4c32-28.8 70.4-57.6 105.6-83.2 44.8-35.2 92.8-67.2 140.8-96 3.2-3.2 6.4-6.4 12.8-6.4 41.6-25.6 86.4-51.2 134.4-67.2 32-12.8 64-16 99.2-3.2 57.6 19.2 108.8 51.2 160 83.2 22.4 9.6 41.6 25.6 60.8 38.4 44.8 32 89.6 60.8 131.2 96 25.6 22.4 54.4 41.6 80 67.2 25.6 28.8 41.6 57.6 35.2 99.2-9.6 48-32 80-73.6 99.2-35.2 16-76.8 22.4-115.2 22.4-201.6 0-406.4 0-608 0-28.8 0-57.6 0-86.4-3.2-41.6-12.8-80-25.6-105.6-57.6-25.6-28.8-35.2-64-28.8-102.4 3.2-41.6 32-64 57.6-86.4zM1024 544c-12.8-12.8-22.4-22.4-32-28.8-25.6-22.4-51.2-41.6-76.8-64-28.8-22.4-60.8-44.8-89.6-64-70.4-44.8-140.8-89.6-217.6-121.6-44.8-19.2-92.8-28.8-144-16-44.8 12.8-86.4 28.8-128 51.2-70.4 35.2-134.4 80-198.4 124.8-32 25.6-67.2 51.2-96 80-12.8 12.8-25.6 25.6-41.6 38.4 0-41.6 0-80 0-121.6 0-60.8 0-121.6 0-185.6 0-16 3.2-28.8 6.4-44.8 22.4-92.8 105.6-153.6 201.6-153.6 201.6 0 406.4 0 608 0 12.8 0 22.4 0 35.2 3.2 54.4 9.6 96 35.2 131.2 76.8 25.6 32 38.4 64 41.6 102.4 3.2 73.6 0 147.2 0 220.8 0 35.2 0 67.2 0 102.4z" />
<glyph unicode="&#xe905;" glyph-name="mailchimp-setting" d="M643.2-64c-19.2 0-41.6 0-60.8 0-3.2 0-6.4 0-6.4 3.2-28.8 6.4-60.8 9.6-89.6 16-108.8 32-188.8 96-240 198.4-3.2 6.4-6.4 12.8-16 12.8-6.4 0-9.6 0-16 3.2-73.6 16-153.6 92.8-118.4 204.8 3.2 6.4 0 9.6-3.2 12.8-9.6 6.4-16 12.8-22.4 19.2-22.4 19.2-35.2 44.8-35.2 73.6 0 38.4 9.6 70.4 25.6 102.4 35.2 76.8 86.4 144 144 208 48 51.2 102.4 99.2 163.2 134.4 32 19.2 64 32 102.4 38.4 9.6 0 19.2 0 28.8 0 28.8-3.2 48-19.2 67.2-41.6 9.6-9.6 19.2-16 25.6-25.6 3.2-3.2 6.4-3.2 12.8-3.2 19.2 9.6 38.4 16 60.8 22.4 38.4 12.8 83.2 19.2 128 9.6 54.4-12.8 80-51.2 70.4-105.6-6.4-38.4-28.8-70.4-51.2-102.4-6.4-9.6-16-16-22.4-25.6 22.4-25.6 38.4-51.2 41.6-86.4 3.2-28.8 3.2-60.8 6.4-92.8 0-9.6 3.2-12.8 9.6-12.8 25.6-6.4 48-12.8 70.4-28.8 28.8-19.2 44.8-54.4 32-83.2-9.6-22.4-6.4-38.4 0-57.6 3.2-6.4 6.4-12.8 12.8-16s12.8-9.6 19.2-16c6.4-9.6 9.6-22.4 9.6-32 3.2-38.4-6.4-73.6-22.4-108.8-54.4-118.4-147.2-182.4-272-208-16-9.6-35.2-9.6-54.4-12.8zM908.8 246.4c-9.6-16-25.6-28.8-41.6-38.4-54.4-38.4-118.4-54.4-182.4-54.4-35.2 0-67.2 3.2-99.2 22.4-19.2 9.6-32 25.6-35.2 48-6.4 32 16 76.8 64 64 6.4 0 9.6 0 16 0 80-6.4 156.8 6.4 230.4 44.8 19.2 9.6 35.2 22.4 48 38.4 19.2 25.6 12.8 51.2-12.8 67.2-6.4 3.2-16 6.4-22.4 9.6-16 6.4-28.8 9.6-44.8 12.8-16 6.4-22.4 9.6-22.4 28.8 0 22.4 0 48-3.2 70.4-3.2 19.2-6.4 38.4-12.8 57.6-9.6 22.4-28.8 28.8-51.2 22.4-9.6-3.2-16-9.6-22.4-12.8-25.6-22.4-51.2-28.8-83.2-28.8-19.2 0-35.2 3.2-54.4 3.2-44.8 3.2-83.2-22.4-99.2-64-19.2-44.8-9.6-86.4 19.2-124.8 9.6-12.8 19.2-22.4 28.8-35.2s9.6-16 0-28.8c-70.4-73.6-76.8-240 70.4-297.6 99.2-38.4 192-16 275.2 48 48 35.2 76.8 83.2 86.4 144 3.2 22.4-3.2 32-25.6 35.2-6.4 19.2-9.6 35.2-16 54.4-6.4-3.2-6.4-6.4-9.6-6.4-3.2-3.2-6.4-3.2-9.6-6.4-83.2-54.4-176-70.4-275.2-57.6-6.4 0-16 0-22.4 0-9.6 0-16-6.4-19.2-19.2 51.2-19.2 105.6-19.2 160-19.2-54.4-22.4-108.8-16-163.2-3.2 0-3.2 0-3.2 0-6.4 6.4-16 19.2-25.6 35.2-32 22.4-6.4 44.8-9.6 64-12.8 54.4-3.2 105.6 9.6 153.6 32 25.6 19.2 51.2 32 76.8 44.8zM556.8 870.4c-9.6 9.6-22.4 22.4-28.8 32-16 22.4-38.4 25.6-64 19.2-35.2-6.4-64-19.2-92.8-38.4-102.4-64-185.6-150.4-249.6-256-22.4-38.4-44.8-76.8-51.2-121.6-9.6-54.4 3.2-67.2 41.6-96 19.2 25.6 48 44.8 80 51.2 3.2 0 6.4 6.4 6.4 9.6 19.2 51.2 44.8 99.2 73.6 144 51.2 80 121.6 140.8 198.4 195.2 28.8 22.4 57.6 41.6 86.4 60.8zM316.8 304c-3.2 16-3.2 35.2-9.6 54.4-12.8 41.6-48 70.4-86.4 70.4-41.6 0-80-25.6-96-67.2-22.4-67.2 22.4-140.8 92.8-156.8 44.8-9.6 80 12.8 89.6 57.6 6.4 9.6 6.4 25.6 9.6 41.6zM521.6 774.4c-25.6-6.4-115.2-80-128-105.6 96 64 198.4 86.4 310.4 64-28.8 19.2-60.8 25.6-96 28.8 6.4 9.6 12.8 16 22.4 22.4-44.8-3.2-80-19.2-115.2-38.4 0 0 0 0-3.2 3.2 0 6.4 6.4 16 9.6 25.6zM764.8 476.8c-9.6-3.2-12.8 3.2-16 9.6-6.4 16-9.6 32-9.6 51.2 0 6.4 3.2 12.8 12.8 16 9.6 0 12.8-3.2 16-9.6 9.6-16 12.8-35.2 12.8-54.4-3.2-9.6-3.2-16-16-12.8zM652.8 451.2c-6.4 0-9.6 3.2-12.8 3.2-25.6 12.8-54.4 12.8-80 3.2-6.4-3.2-9.6 0-16 0 3.2 3.2 6.4 9.6 9.6 12.8 25.6 22.4 64 22.4 89.6 0 3.2-3.2 9.6-9.6 9.6-19.2zM646.4 432c-22.4-3.2-44.8-3.2-64-6.4 0 9.6 6.4 16 25.6 19.2s35.2-3.2 38.4-12.8zM713.6 428.8c12.8 0 22.4-9.6 22.4-19.2 0-6.4-6.4-9.6-12.8-9.6-9.6 0-22.4 9.6-22.4 16 3.2 9.6 9.6 12.8 12.8 12.8zM784 435.2c0-9.6-6.4-19.2-12.8-19.2s-12.8 9.6-12.8 19.2c0 9.6 6.4 19.2 12.8 19.2 9.6-3.2 12.8-9.6 12.8-19.2zM163.2 329.6c3.2 38.4 32 64 64 54.4 28.8-6.4 44.8-35.2 35.2-64-3.2-9.6-6.4-16-9.6-25.6-6.4-19.2 0-25.6 19.2-25.6 3.2 0 6.4 0 6.4-3.2s0-6.4-3.2-6.4c-9.6-9.6-32-9.6-38.4 6.4-6.4 9.6-6.4 22.4-3.2 35.2 0 6.4 3.2 12.8 6.4 19.2 3.2 16-3.2 28.8-16 32-12.8 6.4-28.8 0-35.2-12.8-3.2-3.2-3.2-9.6-6.4-12.8s-6.4-6.4-9.6-12.8c-6.4 9.6-9.6 12.8-9.6 16z" />
</font></defs></svg>

After

Width:  |  Height:  |  Size: 10 KiB

File diff suppressed because it is too large Load Diff