Skip to content

Commit

Permalink
feat: add returns management
Browse files Browse the repository at this point in the history
  • Loading branch information
pfferrari committed Oct 20, 2023
1 parent c42b1af commit 1dfb7ac
Show file tree
Hide file tree
Showing 72 changed files with 11,100 additions and 2 deletions.
110 changes: 110 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*

# System
.DS_Store

# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage
*.lcov

# nyc test coverage
.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# TypeScript v1 declaration files
typings/

# TypeScript cache
*.tsbuildinfo

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env
.env.test

# parcel-bundler cache (https://parceljs.org/)
.cache

# Next.js build output
.next

# Nuxt.js build / generate output
.nuxt
dist

# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public

# vuepress build output
.vuepress/dist

# Serverless directories
.serverless/

# FuseBox cache
.fusebox/

# DynamoDB Local files
.dynamodb/

# TernJS port file
.tern-port

# App
packages/*/public/config.local.js
3 changes: 3 additions & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
//registry.npmjs.org/:_authToken=${NPM_READ_TOKEN}
use-node-version=18.15.0
auto-install-peers=true
1 change: 1 addition & 0 deletions .vercelignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.npmrc
10 changes: 10 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
// See http://go.microsoft.com/fwlink/?LinkId=827846 to learn about workspace recommendations.
// Extension identifier format: ${publisher}.${name}. Example: vscode.csharp
// List of extensions which should be recommended for users of this workspace.
"recommendations": [
"dbaeumer.vscode-eslint"
],
// List of extensions recommended by VS Code that should not be recommended for users of this workspace.
"unwantedRecommendations": []
}
17 changes: 17 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
// Enable ESLint
"eslint.validate": [
"javascript",
"javascriptreact",
"typescript",
"typescriptreact"
],
// be sure vscode always uses TS version in local project
"typescript.tsdk": "node_modules/typescript/lib",
// format on save
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": true,
"source.organizeImports": true
}
}
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Commerce Layer

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
2 changes: 0 additions & 2 deletions README.md

This file was deleted.

1 change: 1 addition & 0 deletions README.md
11 changes: 11 additions & 0 deletions lerna.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"version": "0.0.0",
"$schema": "node_modules/lerna/schemas/lerna-schema.json",
"useNx": false,
"npmClient": "pnpm",
"command": {
"version": {
"preid": "stg"
}
}
}
10 changes: 10 additions & 0 deletions netlify.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# https://docs.netlify.com/configure-builds/file-based-configuration/
[build]
command = "pnpm run build"
publish = "packages/app/dist"
[[redirects]]
from = "/*"
to = "/index.html"
status = 200
[template.environment]
PUBLIC_SELF_HOSTED_SLUG = "Your organization slug"
38 changes: 38 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{
"private": true,
"scripts": {
"preinstall": "npx only-allow pnpm",
"dev": "pnpm -r dev",
"build": "pnpm -r build",
"preview:react": "pnpm -r preview",
"lint": "pnpm -r lint",
"lint:fix": "pnpm -r lint:fix",
"test": "pnpm -r test",
"ts:check": "pnpm -r ts:check",
"test:watch": "pnpm -r test:watch",
"dep:upgrade:major": "pnpm -r exec npm-check-updates -u",
"dep:upgrade:minor": "pnpm dep:upgrade:major -t minor",
"dep:self-upgrade:major": "pnpm exec npm-check-updates -u",
"dep:self-upgrade:minor": "pnpm dep:self-upgrade:major -t minor",
"prepare": "husky install"
},
"keywords": [],
"repository": {
"type": "git",
"url": "https://github.com/commercelayer/app-returns"
},
"license": "MIT",
"engines": {
"node": ">=18",
"pnpm": ">=7"
},
"workspaces": [
"packages/*"
],
"devDependencies": {
"husky": "^8.0.3",
"lerna": "^7.2.0",
"lint-staged": "^14.0.1",
"npm-check-updates": "^16.13.3"
}
}
2 changes: 2 additions & 0 deletions packages/app/.env.local.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
PUBLIC_PROJECT_PATH=
PUBLIC_SELF_HOSTED_SLUG=my-organization-slug
15 changes: 15 additions & 0 deletions packages/app/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const path = require('path')

/** @type {import('eslint').Linter.Config} */
module.exports = {
extends: ['@commercelayer/eslint-config-ts-react'],
parser: '@typescript-eslint/parser',
parserOptions: {
project: path.resolve(__dirname, 'tsconfig.json'),
ecmaFeatures: {
jsx: true
},
ecmaVersion: 12,
sourceType: 'module'
}
}
24 changes: 24 additions & 0 deletions packages/app/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
7 changes: 7 additions & 0 deletions packages/app/.lintstagedrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"*.{js,jsx,ts,tsx}": [
"bash -c \"tsc -p ./tsconfig.json --noEmit\"",
"pnpm lint:fix",
"bash -c \"pnpm test\""
]
}
7 changes: 7 additions & 0 deletions packages/app/@typing/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
interface ImportMeta {
env: {
PUBLIC_PROJECT_PATH?: string
DEV: boolean
PUBLIC_SELF_HOSTED_SLUG?: string
}
}
65 changes: 65 additions & 0 deletions packages/app/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# App returns

Commerce Layer application for managing returns.

Any Commerce Layer account comes with a hosted version of this application, as part of the Dashboard hub, and it is automatically enabled for admin users.
An admin can then enable the app for other organization members giving each member full or read-only access.

It's possible to fork this app and add it to your Dashboard hub, in order to customize every part of the code and start using your own and self-hosted version.

## Table of contents

- [Getting started](#getting-started)
- [Running on Windows](#running-on-windows)
- [Help and support](#need-help)
- [License](#license)


## Getting started
You need a local Node.JS (version 18+) environment and some React.JS knowledge to customize the app code.

1. Fork [this repository](https://github.com/commercelayer/app-returns) (you can learn how to do this [here](https://help.github.com/articles/fork-a-repo)).

2. Clone the forked repository like so:

```bash
git clone https://github.com/<your username>/app-returns.git && cd app-returns
```

3. Set your environment by creating a new `/src/app/.env.local` file starting from `/src/app/.env.local.sample` (not required for local development).

4. Install dependencies and run the development server:

```
pnpm install
pnpm dev
```

5. The app will run in development mode at the following address `http://localhost:5173/`.
In order to authenticate the app, you need to add an integration access token as URL query param. Example: `http://localhost:5173/?accessToken=<integration-token-for-local-dev>`.
Integration access token is only required (and will work only) for development mode. In production mode the Commerce Layer Dashboard hub will generate a valid access token, based on the current user.

6. Modify the app to satisfy your requirements.
All our Dashboard apps are built using a shared component library [@commercelayer/app-elements](https://github.com/commercelayer/app-elements).
You can browse the [official documentation](https://github.com/commercelayer/app-elements) to discover more about this topic.

7. Deploy the forked repository to your preferred hosting service. You can deploy with one click below:

[<img src="https://www.netlify.com/img/deploy/button.svg" alt="Deploy to Netlify" height="35">](https://app.netlify.com/start/deploy?repository=https://github.com/commercelayer/app-returns#PUBLIC_SELF_HOSTED_SLUG) [<img src="https://vercel.com/button" alt="Deploy to Vercel" height="35">](https://vercel.com/new/clone?repository-url=https://github.com/commercelayer/app-returns&build-command=pnpm%20build&output-directory=packages%2Fapp%2Fdist&env=PUBLIC_SELF_HOSTED_SLUG&envDescription=your%20organization%20slug)

8. Complete the configuration in the Dashboard hub by setting your app URL.

## Running on Windows
[Read more](https://github.com/commercelayer/.github/blob/main/PNPM_ON_WINDOWS.md)

## Need help?

1. Join [Commerce Layer's Slack community](https://slack.commercelayer.app).

2. Create an [issue](https://github.com/commercelayer/app-returns/issues) in this repository.

3. Ping us [on Twitter](https://twitter.com/commercelayer).

## License

This repository is published under the [MIT](LICENSE) license
9 changes: 9 additions & 0 deletions packages/app/global.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export {}

declare global {
interface Window {
clAppConfig: {
domain: string
}
}
}
24 changes: 24 additions & 0 deletions packages/app/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Returns | Commerce Layer</title>
<link
rel="icon"
type="image/png"
href="https://data.commercelayer.app/assets/images/favicons/favicon-32x32.png"
/>
<link rel="preconnect" href="https://fonts.gstatic.com" />
<link
href="https://fonts.googleapis.com/css2?family=Manrope:wght@400;500;600;700;800&display=swap"
rel="stylesheet"
/>
</head>
<body>
<div id="root"></div>
<script src="/config.local.js"></script>
<script src="/config.js"></script>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

0 comments on commit 1dfb7ac

Please sign in to comment.