-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"root": true, | ||
"extends": "airbnb-base/legacy" | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"extends": "stylelint-config-standard", | ||
"plugins": [ | ||
"stylelint-scss" | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>sfra_training</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>com.demandware.studio.core.beehiveElementBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>com.demandware.studio.core.beehiveNature</nature> | ||
</natures> | ||
</projectDescription> |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
'use strict'; | ||
|
||
var processInclude = require('base/util'); | ||
|
||
$(document).ready(function () { | ||
Check failure on line 5 in cartridges/sfra_training/cartridges/sfra_training/cartridge/client/default/js/newsletter.js GitHub Actions / deploy-build / build
|
||
processInclude(require('./newsletter/newsletter')); | ||
Check failure on line 6 in cartridges/sfra_training/cartridges/sfra_training/cartridge/client/default/js/newsletter.js GitHub Actions / deploy-build / build
|
||
}); | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
'use strict'; | ||
|
||
var formValidation = require('base/components/formValidation'); | ||
|
||
module.exports = { | ||
submitNewsletter: function () { | ||
Check failure on line 6 in cartridges/sfra_training/cartridges/sfra_training/cartridge/client/default/js/newsletter/newsletter.js GitHub Actions / deploy-build / build
|
||
$('form.newsletter-form').submit(function (e) { | ||
Check failure on line 7 in cartridges/sfra_training/cartridges/sfra_training/cartridge/client/default/js/newsletter/newsletter.js GitHub Actions / deploy-build / build
Check failure on line 7 in cartridges/sfra_training/cartridges/sfra_training/cartridge/client/default/js/newsletter/newsletter.js GitHub Actions / deploy-build / build
|
||
var $form = $(this); | ||
Check failure on line 8 in cartridges/sfra_training/cartridges/sfra_training/cartridge/client/default/js/newsletter/newsletter.js GitHub Actions / deploy-build / build
|
||
e.preventDefault(); | ||
var url = $form.attr('action'); | ||
$form.spinner().start(); | ||
$('form.newsletter-form').trigger('newsletter:submit', e); | ||
$.ajax({ | ||
url: url, | ||
type: 'post', | ||
dataType: 'json', | ||
data: $form.serialize(), | ||
success: function (data) { | ||
$form.spinner().stop(); | ||
if (!data.success) { | ||
formValidation($form, data); | ||
} else { | ||
window.location.href = data.redirectUrl; | ||
} | ||
}, | ||
error: function (err) { | ||
if (err.responseJSON.redirectUrl) { | ||
window.location.href = err.responseJSON.redirectUrl; | ||
} | ||
$form.spinner().stop(); | ||
} | ||
}); | ||
return false; | ||
}); | ||
} | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
var server = require('server'); | ||
var BasketMgr = require('dw/order/BasketMgr'); | ||
|
||
|
||
server.get('Show', function (req, res, next) { | ||
var currentBasket = BasketMgr.getCurrentBasket(); | ||
|
||
res.render('basket', { | ||
basket: currentBasket | ||
}); | ||
|
||
next(); | ||
}); | ||
|
||
module.exports = server.exports(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
"use strict"; | ||
|
||
var server = require("server"); | ||
server.extend(module.superModule); | ||
|
||
server.append("Show", function (req, res, next) { | ||
var viewData = res.getViewData(); | ||
var ProductFactory = require("*/cartridge/scripts/factories/product"); | ||
var productListHelper = require("*/cartridge/scripts/helpers/recentProductHelper"); | ||
var type = 100; | ||
var currentCustomer = req.currentCustomer.raw; | ||
var list = productListHelper.getRecentlyViewedProductList(currentCustomer, type); | ||
var allProductDetails= []; | ||
|
||
if (list != null) { | ||
var items = list.items.iterator(); | ||
while (items.hasNext()) { | ||
var product = items.next(); | ||
var pidsObj = { | ||
pid: product.productID | ||
}; | ||
var ProductDetail = ProductFactory.get(pidsObj); | ||
allProductDetails.push(ProductDetail); | ||
} | ||
} | ||
|
||
allProductDetails = allProductDetails.reverse(); | ||
|
||
res.render('cart/cart', { | ||
allProductDetails: allProductDetails | ||
}); | ||
next(); | ||
}); | ||
|
||
module.exports = server.exports(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict'; | ||
|
||
var server = require('server'); | ||
var cache = require('*/cartridge/scripts/middleware/cache'); | ||
|
||
server.get('Start', cache.applyDefaultCache, function (req, res, next) { | ||
var Site = require('dw/system/Site'); | ||
res.render('helloworld', { param1: Site.current.getName }); | ||
next(); | ||
}); | ||
|
||
module.exports = server.exports(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
'use strict'; | ||
|
||
/** | ||
* @namespace Home | ||
*/ | ||
|
||
var server = require('server'); | ||
var cache = require('*/cartridge/scripts/middleware/cache'); | ||
var consentTracking = require('*/cartridge/scripts/middleware/consentTracking'); | ||
var pageMetaData = require('*/cartridge/scripts/middleware/pageMetaData'); | ||
|
||
/** | ||
* Any customization on this endpoint, also requires update for Default-Start endpoint | ||
*/ | ||
/** | ||
* Home-Show : This endpoint is called when a shopper navigates to the home page | ||
* @name Base/Home-Show | ||
* @function | ||
* @memberof Home | ||
* @param {middleware} - consentTracking.consent | ||
* @param {middleware} - cache.applyDefaultCache | ||
* @param {category} - non-sensitive | ||
* @param {renders} - isml | ||
* @param {serverfunction} - get | ||
*/ | ||
server.get('Show', consentTracking.consent, cache.applyDefaultCache, function (req, res, next) { | ||
var Site = require('dw/system/Site'); | ||
var PageMgr = require('dw/experience/PageMgr'); | ||
var pageMetaHelper = require('*/cartridge/scripts/helpers/pageMetaHelper'); | ||
|
||
pageMetaHelper.setPageMetaTags(req.pageMetaData, Site.current); | ||
|
||
var page = PageMgr.getPage('homepage'); | ||
|
||
if (page && page.isVisible()) { | ||
res.page('homepage'); | ||
} else { | ||
res.render('home/homePage'); | ||
} | ||
next(); | ||
}, pageMetaData.computedPageMetaData); | ||
|
||
server.get('ErrorNotFound', function (req, res, next) { | ||
res.setStatusCode(404); | ||
res.render('error/notFound'); | ||
next(); | ||
}); | ||
|
||
module.exports = server.exports(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,90 @@ | ||
'use strict'; | ||
|
||
var server = require('server'); | ||
var URLUtils = require('dw/web/URLUtils'); | ||
|
||
server.get( | ||
'Show', | ||
server.middleware.https, | ||
function (req, res, next) { | ||
var actionUrl = dw.web.URLUtils.url('Newsletter-Handler'); | ||
var newsletterForm = server.forms.getForm('newsletter'); | ||
newsletterForm.clear(); | ||
|
||
res.render('/newsletter/newslettersignup', { | ||
actionUrl: actionUrl, | ||
newsletterForm: newsletterForm | ||
}); | ||
|
||
next(); | ||
} | ||
); | ||
|
||
server.post( | ||
'Handler', | ||
server.middleware.https, | ||
function (req, res, next) { | ||
var newsletterForm = server.forms.getForm('newsletter'); | ||
var continueUrl = dw.web.URLUtils.url('Newsletter-Show'); | ||
|
||
|
||
if (newsletterForm.valid) { | ||
var CustomObjectMgr = require('dw/object/CustomObjectMgr'); | ||
var Transaction = require('dw/system/Transaction'); | ||
|
||
try { | ||
Transaction.wrap(function () { | ||
var co = CustomObjectMgr.createCustomObject('NewsletterSubscription', newsletterForm.email.value); | ||
co.custom.firstName = newsletterForm.fname.value; | ||
co.custom.lastName = newsletterForm.lname.value; | ||
|
||
dw.system.HookMgr.callHook('newsletter.email', 'send', newsletterForm.email.value); | ||
}); | ||
|
||
res.json({ | ||
success: true, | ||
redirectUrl: URLUtils.url('Newsletter-Success').toString() | ||
}); | ||
} catch (e) { | ||
var err = e; | ||
res.setStatusCode(500); | ||
res.json({ | ||
error: true, | ||
redirectUrl: URLUtils.url('Error-Start').toString() | ||
}); | ||
} | ||
} else { | ||
if (newsletterForm.valid) { | ||
// Show the success page | ||
res.json({ | ||
success: true, | ||
redirectUrl: URLUtils.url('Newsletter-Success').toString() | ||
}); | ||
} else { | ||
// Handle server-side validation errors here: this is just an example | ||
res.setStatusCode(500); | ||
res.json({ | ||
error: true, | ||
redirectUrl: URLUtils.url('Error-Start').toString() | ||
}); | ||
} | ||
|
||
next(); | ||
} | ||
} | ||
); | ||
|
||
server.get( | ||
'Success', | ||
server.middleware.https, | ||
function (req, res, next) { | ||
res.render('/newsletter/newslettersuccess', { | ||
continueUrl: URLUtils.url('Newsletter-Show'), | ||
newsletterForm: server.forms.getForm('newsletter') | ||
}); | ||
|
||
next(); | ||
} | ||
); | ||
|
||
module.exports = server.exports(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
"use strict"; | ||
var page = module.superModule; | ||
var server = require("server"); | ||
|
||
server.extend(page); | ||
server.append("Show", function (req, res, next){ | ||
var recentProductHelper= require("*/cartridge/scripts/helpers/recentProductHelper"); | ||
var currentCustomer=req.currentCustomer.raw; | ||
var pid=req.querystring.pid; | ||
var config ={ | ||
qty: 1, | ||
type: 100, | ||
}; | ||
var productList= recentProductHelper.getRecentlyViewedProductList( | ||
currentCustomer, | ||
pid, | ||
config.type | ||
); | ||
var listProducts = productList.items.iterator(); | ||
var URLUtils = require("dw/web/URLUtils"); | ||
res.setViewData({listProducts:listProducts}); | ||
next(); | ||
|
||
}); | ||
module.exports = server.exports(); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0"?> | ||
<form xmlns="http://www.demandware.com/xml/form/2008-04-19" secure="false"> | ||
<field | ||
formid="fname" | ||
label="label.input.firstname.profile" | ||
mandatory="true" | ||
max-length="50" | ||
type="string" /> | ||
|
||
<field | ||
formid="lname" | ||
label="label.input.lastname.profile" | ||
mandatory="true" | ||
max-length="50" | ||
type="string" /> | ||
|
||
<field | ||
formid="email" | ||
label="label.input.email.profile" | ||
mandatory="true" | ||
max-length="50" | ||
regexp="^[\w.%+-]+@[\w.-]+\.[\w]{2,6}$" | ||
type="string" /> | ||
</form> |