Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example product page graphql and redux #1

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
reactapp/.env.development
reactapp/src/config.js
*.env.development
*config.js

21 changes: 21 additions & 0 deletions Controller/OrderHistory/Index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?php
/**
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace IntegerNet\ReactApp\Controller\OrderHistory;

use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Framework\Controller\ResultFactory;

class Index extends \Magento\Contact\Controller\Index implements HttpGetActionInterface
{
/**
* @return \Magento\Framework\Controller\ResultInterface
*/
public function execute()
{
return $this->resultFactory->create(ResultFactory::TYPE_PAGE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
namespace IntegerNet\ReactApp\Controller\Index;
namespace IntegerNet\ReactApp\Controller\Product;

use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;
use Magento\Framework\Controller\ResultFactory;
Expand Down
2 changes: 2 additions & 0 deletions react-src/orderHistory/.env
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
MAGENTO_DEPLOY_JS_PATH='../../../view/frontend/web/js/order-history/'
MAGENTO_DEPLOY_CSS_PATH='../../../view/frontend/web/css/order-history/'
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ module.exports = function(webpackEnv) {
// There will be one main bundle, and one file per asynchronous chunk.
// In development, it does not produce real files.
filename: isEnvProduction
? '../../view/frontend/web/js/[name].js'
? process.env.MAGENTO_DEPLOY_JS_PATH + '[name].js'
: isEnvDevelopment && 'static/js/bundle.js',
// TODO: remove this when upgrading to webpack 5
futureEmitAssets: true,
// There are also additional JS chunk files if you use code splitting.
chunkFilename: isEnvProduction
? '../../view/frontend/web/js/[name].chunk.js'
? process.env.MAGENTO_DEPLOY_JS_PATH + '[name].chunk.js'
: isEnvDevelopment && 'static/js/[name].chunk.js',
// We inferred the "public path" (such as / or /my-project) from homepage.
// We use "/" in development.
Expand Down Expand Up @@ -538,8 +538,8 @@ module.exports = function(webpackEnv) {
new MiniCssExtractPlugin({
// Options similar to the same options in webpackOptions.output
// both options are optional
filename: '../../view/frontend/web/css/[name].css',
chunkFilename: '../../view/frontend/web/css/[name].chunk.css',
filename: process.env.MAGENTO_DEPLOY_CSS_PATH + '[name].css',
chunkFilename: process.env.MAGENTO_DEPLOY_CSS_PATH + '[name].chunk.css',
}),
// Generate a manifest file which contains a mapping of all asset filenames
// to their corresponding output file so that tools can pick it up without
Expand Down
161 changes: 105 additions & 56 deletions reactapp/package-lock.json → react-src/orderHistory/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
"file-loader": "3.0.1",
"fs-extra": "7.0.1",
"html-webpack-plugin": "4.0.0-beta.5",
"husky": "^2.3.0",
"identity-obj-proxy": "3.0.0",
"is-wsl": "^1.1.0",
"jest": "24.7.1",
Expand Down Expand Up @@ -56,13 +55,15 @@
"terser-webpack-plugin": "1.2.3",
"throttle-debounce": "^2.1.0",
"ts-pnp": "1.1.2",
"typescript": "^3.6.3",
"url-loader": "1.1.2",
"webpack": "4.29.6",
"webpack-dev-server": "3.2.1",
"webpack-manifest-plugin": "2.0.4",
"workbox-webpack-plugin": "4.2.0"
},
"devDependencies": {
"husky": "^2.7.0",
"prop-types": "^15.7.2"
},
"scripts": {
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
36 changes: 36 additions & 0 deletions react-src/orderHistory/src/config.js.template
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/**
* in development (npm run start) we use the PROXY env value, configured in .env.development
* so make sure that file exists (see .env.development.example)
* If the variable `REACT_APP_PROXY` is not set, it will use the fallback
*
* in production (npm run build) we use base_url from magento, set directly in <head><script>,
* or if that's not found, it will use the hardcoded fallback
*/
const isDevelopment = !!process.env.REACT_APP_PROXY;

const baseUrl = isDevelopment
? '/'
: window.BASE_URL || 'https://magento.test/';

const config = {
baseUrl,
forgotPasswordLink: baseUrl + 'customer/account/forgotpassword/',
loginLink: baseUrl + 'customer/ajax/login/',
logoutLink: baseUrl + 'customer/account/logout/',
orderViewLink: baseUrl + 'sales/order/view/order_id/',
graphqlLink: baseUrl + 'graphql'
};

export default config;

export const orderHistoryQuery = `{
customerOrders{
items{
grand_total,
id,
increment_id,
status,
created_at
}
}
}`;
File renamed without changes.
File renamed without changes.
Loading