Skip to content

Commit

Permalink
OP-557 - upgrade to Sylius 2.0 - changes after code review. update ve…
Browse files Browse the repository at this point in the history
…rsions in build strategy . update link in instruction and sample image
  • Loading branch information
MarcinSzczepanskiBitBag committed Jan 22, 2025
1 parent 97acd07 commit a79d693
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 42 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ jobs:
fail-fast: false
matrix:
php: [ "8.2", "8.3" ]
symfony: [ "^6.4" ]
sylius: [ "~v2.0.0-alpha.2" ]
symfony: [ "^6.4", "^7.1" ]
sylius: [ "~2.0.0" ]
node: [ "20.x" ]
mysql: ["8.0"]

Expand Down
Binary file removed assets/sylius-logo.png
Binary file not shown.
5 changes: 1 addition & 4 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@
"description": "MailChimp plugin for Sylius.",
"license": "MIT",
"require": {
"sylius/sylius": "~2.0",
"php": "^8.2",
"dompdf/dompdf": "^2.0",
"drewm/mailchimp-api": "^2.5.4",
"sylius/grid-bundle": "^1.13.0",
"sylius/sylius": "~2.0",
"sylius/twig-extra": "^0.6",
"sylius/twig-hooks": "^0.6",
"symfony/stimulus-bundle": "^2.12",
Expand Down Expand Up @@ -86,9 +86,6 @@
]
},
"extra": {
"branch-alias": {
"dev-2.0": "2.0-dev"
},
"symfony": {
"require": "^7.1"
}
Expand Down
2 changes: 1 addition & 1 deletion doc/customization.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ $ bin/console debug:container --parameters | grep bitbag
$ composer install
$ cd tests/Application
$ yarn install
$ yarn run gulp
$ yarn encore dev
$ bin/console assets:install public -e test
$ bin/console doctrine:schema:create -e test
$ bin/console server:run 127.0.0.1:8080 -d public -e test
Expand Down
Binary file modified doc/images/mailchimp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 3 additions & 2 deletions doc/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,10 @@ webpack_encore:
### Encore functions
Add encore functions to your templates:
SyliusShopBundle:
SyliusShopBundle `templates/shop/javascripts.html.twig`:
```php
{# @SyliusShopBundle/_scripts.html.twig #}
...
{{ encore_entry_script_tags('bitbag-mail-chimp-shop', null, 'mail-chimp-shop') }}
<script>
document.addEventListener("DOMContentLoaded", function(event) {
Expand Down
48 changes: 24 additions & 24 deletions public/bitbag-mailchimp-plugin-newsletter.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,33 @@ window.joinNewsletter = function joinNewsletter(form) {
method: method,
body: formData
})
.then(async (response) => {
if (!response.ok) {
response = await response.json();
throw(response);
}
.then(async (response) => {
if (!response.ok) {
response = await response.json();
throw(response);
}

return await response.json()
})
.then((data) => {
if (data.hasOwnProperty('message')) {
successElement.innerHTML = data.message;
input.value = '';
}
})
.catch(error => {
var message = 'An unexpected error occurred. Please try again later.';
return await response.json()
})
.then((data) => {
if (data.hasOwnProperty('message')) {
successElement.innerHTML = data.message;
input.value = '';
}
})
.catch(error => {
var message = 'An unexpected error occurred. Please try again later.';

if (error.errors) {
try {
let jsonErrors = JSON.parse(error.errors);
message = '';
message = Object.values(jsonErrors).join(" ");
} catch (e) {}
}
if (error.errors) {
try {
let jsonErrors = JSON.parse(error.errors);
message = '';
message = Object.values(jsonErrors).join(" ");
} catch (e) {}
}

validationElement.textContent = message;
});
validationElement.textContent = message;
});
});
}

14 changes: 5 additions & 9 deletions templates/_subscribe.html.twig
Original file line number Diff line number Diff line change
@@ -1,33 +1,29 @@
<form
action="{{ path('bitbag_sylius_mailchimp_plugin_newsletter_subscribe') }}"
<form action="{{ path('bitbag_sylius_mailchimp_plugin_newsletter_subscribe') }}"
method="POST"
id="footer-newsletter-form"
class="row bb-subscribe"
class="container bb-subscribe"
>
<div class="success-element text-center"></div>
<div class="validation-element text-center"></div>

<div class="col-12 d-flex flex-wrap align-items-center">
<div class="mb-3 flex-grow-1 me-3">
<input
type="text"
<input type="text"
id="newsletter-email"
name="email"
class="form-control"
placeholder="{{ 'bitbag_sylius_mailchimp_plugin.ui.your_email_address'|trans }}"
/>
</div>

<input
type="hidden"
<input type="hidden"
id="newsletter-token"
name="_token"
value="{{ csrf_token('newsletter') }}"
>

<div class="mb-3">
<button
title="{{ 'bitbag_sylius_mailchimp_plugin.ui.subscribe' }}"
<button title="{{ 'bitbag_sylius_mailchimp_plugin.ui.subscribe' }}"
type="submit"
class="btn btn-primary"
>
Expand Down

0 comments on commit a79d693

Please sign in to comment.