Skip to content

Commit

Permalink
Merge pull request #79 from val92130/develop
Browse files Browse the repository at this point in the history
2.9.2
  • Loading branch information
Valentin Chatelain authored Nov 7, 2017
2 parents c5c1dda + 1d6b72d commit 56f3275
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 17 deletions.
2 changes: 1 addition & 1 deletion bot/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"manifest_version": 2,
"name": "Supreme Auto-Checkout bot",
"description": "Supreme Open-Source add to cart bot",
"version": "2.9.1",
"version": "2.9.2",
"background": {
"scripts": ["background.js"]
},
Expand Down
15 changes: 2 additions & 13 deletions bot/src/app/components/shops/supreme/pages/Billing.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ const Billing = props => {
floatingLabelText="Email"
hintText="Email"
style={Styles.fields.text}
validate={[Validators.required, Validators.email]}
validate={[Validators.email]}
/>
</div>

Expand All @@ -74,7 +74,6 @@ const Billing = props => {
floatingLabelText="Phone number"
hintText="Phone number"
style={Styles.fields.text}
validate={[Validators.required]}
/>
</div>

Expand All @@ -85,7 +84,6 @@ const Billing = props => {
floatingLabelText="Address"
hintText="Address"
style={Styles.fields.text}
validate={[Validators.required]}
/>
</div>

Expand All @@ -106,7 +104,6 @@ const Billing = props => {
floatingLabelText="City"
hintText="City"
style={Styles.fields.text}
validate={[Validators.required]}
/>
</div>

Expand All @@ -117,7 +114,6 @@ const Billing = props => {
floatingLabelText="Country"
hintText="Country"
style={Styles.fields.text}
validate={[Validators.required]}
>
{
Utils.countries.map(x => <MenuItem key={x.value} value={x.value} primaryText={x.text} />)
Expand All @@ -132,7 +128,6 @@ const Billing = props => {
floatingLabelText="State"
hintText="State"
style={Styles.fields.text}
validate={[Validators.required]}
>
{
getStatesForCountry(country).map(x => <MenuItem key={x.value} value={x.value} primaryText={x.text} />)
Expand All @@ -146,7 +141,6 @@ const Billing = props => {
component={TextField}
floatingLabelText="Zip"
style={Styles.fields.text}
validate={[Validators.required]}
/>
</div>

Expand All @@ -156,7 +150,6 @@ const Billing = props => {
component={SelectField}
floatingLabelText="Credit card type"
style={Styles.fields.text}
validate={[Validators.required]}
>
{
getCreditCardsForCountry(country).map(x =>
Expand All @@ -173,7 +166,6 @@ const Billing = props => {
floatingLabelText="Credit Card Number"
hintText="Credit Card Number"
style={Styles.fields.text}
validate={[Validators.required]}
/>
</div>

Expand All @@ -183,7 +175,6 @@ const Billing = props => {
component={SelectField}
floatingLabelText="Expiry month"
hintText="Expiry month"
validate={[Validators.required]}
style={Styles.fields.text}
>
{
Expand All @@ -202,12 +193,11 @@ const Billing = props => {
floatingLabelText="Expiry year"
hintText="Expiry year"
style={Styles.fields.text}
validate={[Validators.required]}
>
{
Array.apply(null, new Array(10)).map((x, i) => {
const year = new Date().getFullYear() + i;
return <MenuItem key={year} value={year} primaryText={year}/>;
return <MenuItem key={year} value={year} primaryText={year} />;
})
}
</Field>
Expand All @@ -220,7 +210,6 @@ const Billing = props => {
hintText="CCV"
floatingLabelText="CCV"
style={Styles.fields.text}
validate={[Validators.required]}
/>
</div>
<div>
Expand Down
21 changes: 21 additions & 0 deletions bot/src/app/components/shops/supreme/pages/Options.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const defaultValues = {
addToCartDelay: 200,
checkoutDelay: 2000,
showNotifications: false,
disableImages: false,
};

class HelperField extends Component {
Expand Down Expand Up @@ -197,6 +198,26 @@ const Options = props => {
}
/>
</div>

<div>
<HelperField
field={
<Field
name="disableImages"
component={Toggle}
style={{ width: 'auto' }}
/>
}
title="Disable images loading"
helperText={
<div>
<p>
If enabled, images will not be loaded on the Supreme website, this can improve speed.
</p>
</div>
}
/>
</div>
<div>
<HelperField
field={
Expand Down
15 changes: 15 additions & 0 deletions bot/src/app/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,26 @@ async function init() {
};
const store = createStore(rootReducer, savedState, applyMiddleware(...middleware));

let imageSettings = 'allow';
// Save state in localStorage automatically
store.subscribe(async () => {
const state = store.getState();
if (state) {
await StorageService.saveState({ menu: state.menu, profiles: state.profiles, atc: state.atc });
try {
const settings = await StorageService.getCurrentProfileSettings();
const newImageSettings = settings.Supreme.Options.disableImages ? 'block' : 'allow';
if (newImageSettings !== imageSettings) {
chrome.contentSettings.images.set({
primaryPattern: 'http://www.supremenewyork.com/*',
setting: newImageSettings,
});
imageSettings = newImageSettings;
}
} catch(e) {
console.error(e);
console.error('Error while trying to set image settings');
}
}
});

Expand Down
4 changes: 2 additions & 2 deletions bot/src/app/utils/FormValidators.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as Helpers from './Helpers';

export function email(input) {
const re = /^(([^<>()\[\]\\.,;:\s@"]+(\.[^<>()\[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
return re.test(input) ? undefined : 'Please enter a valid email';
return (!input || re.test(input)) ? undefined : 'Please enter a valid email';
}

export function required(value) {
Expand Down Expand Up @@ -33,7 +33,7 @@ export function maxValue(max) {
}

export function fullName(value) {
return !value || value.split(' ').filter(x => x !== "").length < 2 ? 'Please enter a valid full name (firstname + lastname)' : undefined;
return value && value.split(' ').filter(x => x !== '').length < 2 ? 'Please enter a valid full name (firstname + lastname)' : undefined;
}

export function unique(candidates) {
Expand Down
2 changes: 1 addition & 1 deletion bot/src/app/version.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export default '2.9.1';
export default '2.9.2';

0 comments on commit 56f3275

Please sign in to comment.