Skip to content

Commit

Permalink
initial code
Browse files Browse the repository at this point in the history
  • Loading branch information
Sowmith112 committed Apr 10, 2024
1 parent 9176970 commit ff38793
Show file tree
Hide file tree
Showing 41 changed files with 17,908 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ server.get('Show', cache.applyPromotionSensitiveCache, consentTracking.consent,
var productType = showProductPageHelperResult.product.productType;
if (!showProductPageHelperResult.product.online && productType !== 'set' && productType !== 'bundle') {
res.setStatusCode(404);
res.render('error/notFound');
res.render('error/notFound');
} else {
var pageLookupResult = productHelper.getPageDesignerProductPage(showProductPageHelperResult.product);

Expand Down
1 change: 1 addition & 0 deletions cartridges/plugin_instorepickup
Submodule plugin_instorepickup added at e9705f
1 change: 1 addition & 0 deletions cartridges/sfra_demo
Submodule sfra_demo added at 902ff1
4 changes: 4 additions & 0 deletions cartridges/sfra_training/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"root": true,
"extends": "airbnb-base/legacy"
}
6 changes: 6 additions & 0 deletions cartridges/sfra_training/.stylelintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "stylelint-config-standard",
"plugins": [
"stylelint-scss"
]
}
17 changes: 17 additions & 0 deletions cartridges/sfra_training/cartridges/sfra_training/.project
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

View workflow job for this annotation

GitHub Actions / deploy-build / build

'$' is not defined

Check warning on line 5 in cartridges/sfra_training/cartridges/sfra_training/cartridge/client/default/js/newsletter.js

View workflow job for this annotation

GitHub Actions / deploy-build / build

Unexpected unnamed function
processInclude(require('./newsletter/newsletter'));

Check failure on line 6 in cartridges/sfra_training/cartridges/sfra_training/cartridge/client/default/js/newsletter.js

View workflow job for this annotation

GitHub Actions / deploy-build / build

Expected indentation of 2 spaces but found 4

Check failure on line 6 in cartridges/sfra_training/cartridges/sfra_training/cartridge/client/default/js/newsletter.js

View workflow job for this annotation

GitHub Actions / deploy-build / build

Unexpected require()
});

Check failure on line 7 in cartridges/sfra_training/cartridges/sfra_training/cartridge/client/default/js/newsletter.js

View workflow job for this annotation

GitHub Actions / deploy-build / build

Newline required at end of file but not found
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

View workflow job for this annotation

GitHub Actions / deploy-build / build

Expected indentation of 2 spaces but found 4

Check warning on line 6 in cartridges/sfra_training/cartridges/sfra_training/cartridge/client/default/js/newsletter/newsletter.js

View workflow job for this annotation

GitHub Actions / deploy-build / build

Unexpected unnamed method 'submitNewsletter'
$('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

View workflow job for this annotation

GitHub Actions / deploy-build / build

Expected indentation of 4 spaces but found 8

Check failure on line 7 in cartridges/sfra_training/cartridges/sfra_training/cartridge/client/default/js/newsletter/newsletter.js

View workflow job for this annotation

GitHub Actions / deploy-build / build

'$' is not defined

Check warning on line 7 in cartridges/sfra_training/cartridges/sfra_training/cartridge/client/default/js/newsletter/newsletter.js

View workflow job for this annotation

GitHub Actions / deploy-build / build

Unexpected unnamed function
var $form = $(this);

Check failure on line 8 in cartridges/sfra_training/cartridges/sfra_training/cartridge/client/default/js/newsletter/newsletter.js

View workflow job for this annotation

GitHub Actions / deploy-build / build

Expected indentation of 6 spaces but found 12

Check failure on line 8 in cartridges/sfra_training/cartridges/sfra_training/cartridge/client/default/js/newsletter/newsletter.js

View workflow job for this annotation

GitHub Actions / deploy-build / build

'$' is not defined
e.preventDefault();

Check failure on line 9 in cartridges/sfra_training/cartridges/sfra_training/cartridge/client/default/js/newsletter/newsletter.js

View workflow job for this annotation

GitHub Actions / deploy-build / build

Expected indentation of 6 spaces but found 12
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) {

Check warning on line 18 in cartridges/sfra_training/cartridges/sfra_training/cartridge/client/default/js/newsletter/newsletter.js

View workflow job for this annotation

GitHub Actions / deploy-build / build

Unexpected unnamed method 'success'
$form.spinner().stop();
if (!data.success) {
formValidation($form, data);
} else {
window.location.href = data.redirectUrl;
}
},
error: function (err) {

Check warning on line 26 in cartridges/sfra_training/cartridges/sfra_training/cartridge/client/default/js/newsletter/newsletter.js

View workflow job for this annotation

GitHub Actions / deploy-build / build

Unexpected unnamed method 'error'
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) {

Check warning on line 7 in cartridges/sfra_training/cartridges/sfra_training/cartridge/controllers/Basket.js

View workflow job for this annotation

GitHub Actions / deploy-build / build

Unexpected unnamed function
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) {

Check warning on line 6 in cartridges/sfra_training/cartridges/sfra_training/cartridge/controllers/Cart.js

View workflow job for this annotation

GitHub Actions / deploy-build / build

Unexpected unnamed function
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) {

Check warning on line 6 in cartridges/sfra_training/cartridges/sfra_training/cartridge/controllers/Hello.js

View workflow job for this annotation

GitHub Actions / deploy-build / build

Unexpected unnamed function
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) {

Check warning on line 26 in cartridges/sfra_training/cartridges/sfra_training/cartridge/controllers/Home.js

View workflow job for this annotation

GitHub Actions / deploy-build / build

Unexpected unnamed function
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) {

Check warning on line 43 in cartridges/sfra_training/cartridges/sfra_training/cartridge/controllers/Home.js

View workflow job for this annotation

GitHub Actions / deploy-build / build

Unexpected unnamed function
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>
Loading

0 comments on commit ff38793

Please sign in to comment.