parent
4de9f79382
commit
3ff84f691c
|
@ -1,12 +1,12 @@
|
||||||
// LIBRARIES
|
// LIBRARIES
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { Button, Popover } from 'antd';
|
import { Button, Popover, Dropdown, Menu } from 'antd';
|
||||||
import { Form, Field } from 'formik';
|
import { Form, Field } from 'formik';
|
||||||
import { connect } from 'react-redux';
|
import { connect } from 'react-redux';
|
||||||
|
|
||||||
// COMPONENTS
|
// COMPONENTS
|
||||||
import HeaderForm from "components/Forms/HeaderForm"
|
import HeaderForm from "components/Forms/HeaderForm"
|
||||||
import { Inputs, UploadImage, InputNumberAntD,
|
import { Inputs, Select, UploadImage, InputNumberAntD,
|
||||||
InputMaskNumber, InputTextArea } from 'components/Forms';
|
InputMaskNumber, InputTextArea } from 'components/Forms';
|
||||||
|
|
||||||
// HELPER FUNCTIONS
|
// HELPER FUNCTIONS
|
||||||
|
@ -41,7 +41,11 @@ function CreateSystemPreferencesForm(props) {
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
handleFileUpload,
|
handleFileUpload,
|
||||||
onRemoveImage,
|
onRemoveImage,
|
||||||
syncStratuscast
|
syncStratuscast,
|
||||||
|
actionAndroidTypeOptions,
|
||||||
|
actionAndroidTypeDefaultValue,
|
||||||
|
actionIosTypeOptions,
|
||||||
|
actionIosTypeDefaultValue,
|
||||||
} = props;
|
} = props;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
@ -147,6 +151,94 @@ function CreateSystemPreferencesForm(props) {
|
||||||
rows={4}
|
rows={4}
|
||||||
component={InputTextArea}
|
component={InputTextArea}
|
||||||
/>
|
/>
|
||||||
|
<div style={styles.borderDivision}></div>
|
||||||
|
<h2 style={{margin: '25px 35px'}}>Android Version Update</h2>
|
||||||
|
<Field
|
||||||
|
onCountText
|
||||||
|
charsperpage={20}
|
||||||
|
maxLength="20"
|
||||||
|
style={{marginBottom: '10px'}}
|
||||||
|
name="android_version"
|
||||||
|
type="text"
|
||||||
|
icon=""
|
||||||
|
layout={formItemLayout}
|
||||||
|
label="Android Version"
|
||||||
|
placeholder="Android Version"
|
||||||
|
rows={1}
|
||||||
|
component={Inputs}
|
||||||
|
/>
|
||||||
|
<Field
|
||||||
|
onCountText
|
||||||
|
charsperpage={100}
|
||||||
|
maxLength="100"
|
||||||
|
style={{marginBottom: '10px'}}
|
||||||
|
name="android_update_message"
|
||||||
|
type="text"
|
||||||
|
icon=""
|
||||||
|
layout={formItemLayout}
|
||||||
|
label="Version Update Message"
|
||||||
|
placeholder="Android Version"
|
||||||
|
rows={4}
|
||||||
|
component={InputTextArea}
|
||||||
|
/>
|
||||||
|
<div style={{marginTop:'20px'}}></div>
|
||||||
|
<Field
|
||||||
|
name="android_action"
|
||||||
|
type="select"
|
||||||
|
icon=""
|
||||||
|
defaultValue={actionAndroidTypeDefaultValue && (actionAndroidTypeDefaultValue)}
|
||||||
|
layout={formItemLayout}
|
||||||
|
label="Version Action"
|
||||||
|
placeholder="Select Version Action"
|
||||||
|
mode="single"
|
||||||
|
optionsList={actionAndroidTypeOptions}
|
||||||
|
component={Select}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<div style={styles.borderDivision}></div>
|
||||||
|
<h2 style={{margin: '25px 35px'}}>IOS Version Update</h2>
|
||||||
|
<Field
|
||||||
|
onCountText
|
||||||
|
charsperpage={20}
|
||||||
|
maxLength="20"
|
||||||
|
style={{marginBottom: '10px'}}
|
||||||
|
name="ios_version"
|
||||||
|
type="text"
|
||||||
|
icon=""
|
||||||
|
layout={formItemLayout}
|
||||||
|
label="IOS Version"
|
||||||
|
placeholder="IOS Version"
|
||||||
|
rows={1}
|
||||||
|
component={Inputs}
|
||||||
|
/>
|
||||||
|
<Field
|
||||||
|
onCountText
|
||||||
|
charsperpage={100}
|
||||||
|
maxLength="100"
|
||||||
|
style={{marginBottom: '10px'}}
|
||||||
|
name="ios_update_message"
|
||||||
|
type="text"
|
||||||
|
icon=""
|
||||||
|
layout={formItemLayout}
|
||||||
|
label="Version Update Message"
|
||||||
|
placeholder="Android Version"
|
||||||
|
rows={4}
|
||||||
|
component={InputTextArea}
|
||||||
|
/>
|
||||||
|
<div style={{marginTop:'20px'}}></div>
|
||||||
|
<Field
|
||||||
|
name="ios_action"
|
||||||
|
type="select"
|
||||||
|
icon=""
|
||||||
|
defaultValue={actionIosTypeDefaultValue && (actionIosTypeDefaultValue)}
|
||||||
|
layout={formItemLayout}
|
||||||
|
label="Version Action"
|
||||||
|
placeholder="Select Version Action"
|
||||||
|
mode="single"
|
||||||
|
optionsList={actionIosTypeOptions}
|
||||||
|
component={Select}
|
||||||
|
/>
|
||||||
|
|
||||||
<div style={styles.borderDivision}></div>
|
<div style={styles.borderDivision}></div>
|
||||||
<h2 style={{margin: '25px 35px'}}>Update Details</h2>
|
<h2 style={{margin: '25px 35px'}}>Update Details</h2>
|
||||||
|
|
||||||
|
|
|
@ -23,16 +23,88 @@ class CreateSystemPreferences extends Component {
|
||||||
loading: false,
|
loading: false,
|
||||||
mounted: false,
|
mounted: false,
|
||||||
systemPreference: null,
|
systemPreference: null,
|
||||||
fileUpload: null
|
fileUpload: null,
|
||||||
|
actionAndroidTypeOptions: [{label:"Update",value:"0"},{label:"Force Update",value:"1"},{label:"Silent Update",value:"2"}],
|
||||||
|
actionIosTypeOptions: [{label:"Update",value:"0"},{label:"Force Update",value:"1"},{label:"Silent Update",value:"2"}]
|
||||||
}
|
}
|
||||||
async componentDidMount() {
|
async componentDidMount() {
|
||||||
console.log(process.env.REACT_APP_API_SYNC, 'ito si sync')
|
|
||||||
const { match } = this.props;
|
const { match } = this.props;
|
||||||
|
let actionAndroidTypeDefaultValue = []
|
||||||
|
let actionAndroidTypeDefaultKeyValue = []
|
||||||
|
let actionIosTypeDefaultValue = []
|
||||||
|
let actionIosTypeDefaultKeyValue = []
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let response = await API_UNI_OIL.get(`systemPreference`)
|
let response = await API_UNI_OIL.get(`systemPreference`)
|
||||||
|
|
||||||
|
let actionAndroidtype = []
|
||||||
|
let actionIostype = []
|
||||||
|
|
||||||
|
if(response.data.data.android_action) {
|
||||||
|
actionAndroidtype.push(response.data.data.android_action)
|
||||||
|
|
||||||
|
if(response.data.data.android_action == 0){
|
||||||
|
actionAndroidTypeDefaultValue.push(
|
||||||
|
"Update"
|
||||||
|
)
|
||||||
|
actionAndroidTypeDefaultKeyValue.push(
|
||||||
|
"0"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else if(response.data.data.android_action == 1){
|
||||||
|
actionAndroidTypeDefaultValue.push(
|
||||||
|
"Force Update"
|
||||||
|
)
|
||||||
|
actionAndroidTypeDefaultKeyValue.push(
|
||||||
|
"1"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else if(response.data.data.android_action == 2){
|
||||||
|
actionAndroidTypeDefaultValue.push(
|
||||||
|
"Silent Update"
|
||||||
|
)
|
||||||
|
actionAndroidTypeDefaultKeyValue.push(
|
||||||
|
"2"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(response.data.data.ios_action) {
|
||||||
|
actionIostype.push(response.data.data.ios_action)
|
||||||
|
|
||||||
|
if(response.data.data.ios_action == 0){
|
||||||
|
actionIosTypeDefaultValue.push(
|
||||||
|
"Update"
|
||||||
|
)
|
||||||
|
actionIosTypeDefaultKeyValue.push(
|
||||||
|
"0"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else if(response.data.data.ios_action == 1){
|
||||||
|
actionIosTypeDefaultValue.push(
|
||||||
|
"Force Update"
|
||||||
|
)
|
||||||
|
actionIosTypeDefaultKeyValue.push(
|
||||||
|
"1"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
else if(response.data.data.ios_action == 2){
|
||||||
|
actionIosTypeDefaultValue.push(
|
||||||
|
"Silent Update"
|
||||||
|
)
|
||||||
|
actionIosTypeDefaultKeyValue.push(
|
||||||
|
"2"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
this.setState({
|
this.setState({
|
||||||
systemPreference: {...response.data.data},
|
systemPreference: {...response.data.data},
|
||||||
|
actionAndroidTypeDefaultValue,
|
||||||
|
actionAndroidTypeDefaultKeyValue,
|
||||||
|
actionIosTypeDefaultValue,
|
||||||
|
actionIosTypeDefaultKeyValue,
|
||||||
mounted: true
|
mounted: true
|
||||||
})
|
})
|
||||||
} catch ({response: error}) {
|
} catch ({response: error}) {
|
||||||
|
@ -76,6 +148,12 @@ class CreateSystemPreferences extends Component {
|
||||||
values.contact_details && (formData.append('contact_details', values.contact_details));
|
values.contact_details && (formData.append('contact_details', values.contact_details));
|
||||||
newNumber && (formData.append('contact_number_mobile', newNumber ));
|
newNumber && (formData.append('contact_number_mobile', newNumber ));
|
||||||
formData.append('information_guide_details', values.information_guide_details && values.information_guide_details);
|
formData.append('information_guide_details', values.information_guide_details && values.information_guide_details);
|
||||||
|
formData.append('android_version', values.android_version && values.android_version);
|
||||||
|
formData.append('android_update_message', values.android_update_message && values.android_update_message);
|
||||||
|
formData.append('android_action', values.android_action && values.android_action);
|
||||||
|
formData.append('ios_version', values.ios_version && values.ios_version);
|
||||||
|
formData.append('ios_update_message', values.ios_update_message && values.ios_update_message);
|
||||||
|
formData.append('ios_action', values.ios_action && values.ios_action);
|
||||||
|
|
||||||
let response = await API_UNI_OIL.post('systemPreference', formData , headers)
|
let response = await API_UNI_OIL.post('systemPreference', formData , headers)
|
||||||
|
|
||||||
|
@ -211,7 +289,8 @@ class CreateSystemPreferences extends Component {
|
||||||
|
|
||||||
if(!this.state.mounted) return null;
|
if(!this.state.mounted) return null;
|
||||||
|
|
||||||
const { systemPreference, loading } = this.state
|
const { systemPreference, loading, actionAndroidTypeDefaultValue, actionAndroidTypeDefaultKeyValue, actionAndroidTypeOptions,
|
||||||
|
actionIosTypeDefaultValue, actionIosTypeDefaultKeyValue, actionIosTypeOptions } = this.state
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div style={{ border:'1px solid #E6ECF5' , paddingBottom: '10px'}}>
|
<div style={{ border:'1px solid #E6ECF5' , paddingBottom: '10px'}}>
|
||||||
|
@ -231,7 +310,13 @@ class CreateSystemPreferences extends Component {
|
||||||
contact_email_address_mobile: systemPreference.contact_email_address_mobile || '',
|
contact_email_address_mobile: systemPreference.contact_email_address_mobile || '',
|
||||||
contact_number_mobile: systemPreference.contact_number_mobile || '',
|
contact_number_mobile: systemPreference.contact_number_mobile || '',
|
||||||
contact_details: systemPreference.contact_details || '',
|
contact_details: systemPreference.contact_details || '',
|
||||||
information_guide_details: systemPreference.information_guide_details || ''
|
information_guide_details: systemPreference.information_guide_details || '',
|
||||||
|
android_version: systemPreference.android_version || '',
|
||||||
|
android_update_message: systemPreference.android_update_message || '',
|
||||||
|
android_action: actionAndroidTypeDefaultKeyValue || '',
|
||||||
|
ios_version: systemPreference.ios_version || '',
|
||||||
|
ios_update_message: systemPreference.ios_update_message || '',
|
||||||
|
ios_action: actionIosTypeDefaultKeyValue || '',
|
||||||
}}
|
}}
|
||||||
ref={node => (this.form = node)}
|
ref={node => (this.form = node)}
|
||||||
enableReinitialize={true}
|
enableReinitialize={true}
|
||||||
|
@ -241,7 +326,11 @@ class CreateSystemPreferences extends Component {
|
||||||
<CreateSystemPreferencesForm
|
<CreateSystemPreferencesForm
|
||||||
{...props}
|
{...props}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
|
actionAndroidTypeOptions={actionAndroidTypeOptions}
|
||||||
|
actionIosTypeOptions={actionIosTypeOptions}
|
||||||
handleFileUpload={this.handleFileUpload}
|
handleFileUpload={this.handleFileUpload}
|
||||||
|
actionAndroidTypeDefaultValue={actionAndroidTypeDefaultValue}
|
||||||
|
actionIosTypeDefaultValue={actionIosTypeDefaultValue}
|
||||||
syncStratuscast={this.syncStratuscast}
|
syncStratuscast={this.syncStratuscast}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue