parent
4de9f79382
commit
3ff84f691c
|
@ -1,12 +1,12 @@
|
|||
// LIBRARIES
|
||||
import React from 'react';
|
||||
import { Button, Popover } from 'antd';
|
||||
import { Button, Popover, Dropdown, Menu } from 'antd';
|
||||
import { Form, Field } from 'formik';
|
||||
import { connect } from 'react-redux';
|
||||
|
||||
// COMPONENTS
|
||||
import HeaderForm from "components/Forms/HeaderForm"
|
||||
import { Inputs, UploadImage, InputNumberAntD,
|
||||
import { Inputs, Select, UploadImage, InputNumberAntD,
|
||||
InputMaskNumber, InputTextArea } from 'components/Forms';
|
||||
|
||||
// HELPER FUNCTIONS
|
||||
|
@ -41,7 +41,11 @@ function CreateSystemPreferencesForm(props) {
|
|||
handleSubmit,
|
||||
handleFileUpload,
|
||||
onRemoveImage,
|
||||
syncStratuscast
|
||||
syncStratuscast,
|
||||
actionAndroidTypeOptions,
|
||||
actionAndroidTypeDefaultValue,
|
||||
actionIosTypeOptions,
|
||||
actionIosTypeDefaultValue,
|
||||
} = props;
|
||||
|
||||
return (
|
||||
|
@ -147,6 +151,94 @@ function CreateSystemPreferencesForm(props) {
|
|||
rows={4}
|
||||
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>
|
||||
<h2 style={{margin: '25px 35px'}}>Update Details</h2>
|
||||
|
||||
|
|
|
@ -23,16 +23,88 @@ class CreateSystemPreferences extends Component {
|
|||
loading: false,
|
||||
mounted: false,
|
||||
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() {
|
||||
console.log(process.env.REACT_APP_API_SYNC, 'ito si sync')
|
||||
const { match } = this.props;
|
||||
let actionAndroidTypeDefaultValue = []
|
||||
let actionAndroidTypeDefaultKeyValue = []
|
||||
let actionIosTypeDefaultValue = []
|
||||
let actionIosTypeDefaultKeyValue = []
|
||||
|
||||
try {
|
||||
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({
|
||||
systemPreference: {...response.data.data},
|
||||
actionAndroidTypeDefaultValue,
|
||||
actionAndroidTypeDefaultKeyValue,
|
||||
actionIosTypeDefaultValue,
|
||||
actionIosTypeDefaultKeyValue,
|
||||
mounted: true
|
||||
})
|
||||
} catch ({response: error}) {
|
||||
|
@ -76,6 +148,12 @@ class CreateSystemPreferences extends Component {
|
|||
values.contact_details && (formData.append('contact_details', values.contact_details));
|
||||
newNumber && (formData.append('contact_number_mobile', newNumber ));
|
||||
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)
|
||||
|
||||
|
@ -211,7 +289,8 @@ class CreateSystemPreferences extends Component {
|
|||
|
||||
if(!this.state.mounted) return null;
|
||||
|
||||
const { systemPreference, loading } = this.state
|
||||
const { systemPreference, loading, actionAndroidTypeDefaultValue, actionAndroidTypeDefaultKeyValue, actionAndroidTypeOptions,
|
||||
actionIosTypeDefaultValue, actionIosTypeDefaultKeyValue, actionIosTypeOptions } = this.state
|
||||
|
||||
return (
|
||||
<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_number_mobile: systemPreference.contact_number_mobile || '',
|
||||
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)}
|
||||
enableReinitialize={true}
|
||||
|
@ -241,7 +326,11 @@ class CreateSystemPreferences extends Component {
|
|||
<CreateSystemPreferencesForm
|
||||
{...props}
|
||||
loading={loading}
|
||||
actionAndroidTypeOptions={actionAndroidTypeOptions}
|
||||
actionIosTypeOptions={actionIosTypeOptions}
|
||||
handleFileUpload={this.handleFileUpload}
|
||||
actionAndroidTypeDefaultValue={actionAndroidTypeDefaultValue}
|
||||
actionIosTypeDefaultValue={actionIosTypeDefaultValue}
|
||||
syncStratuscast={this.syncStratuscast}
|
||||
/>
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue