Merge pull request #4461 from joaojmendes/SalesOrdersApp
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"extends": [
|
||||
"development"
|
||||
],
|
||||
"hints": {
|
||||
"no-inline-styles": "off"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,29 @@
|
|||
{
|
||||
"name": "SPFx 1.18.0",
|
||||
"image": "docker.io/m365pnp/spfx:1.18.0",
|
||||
"settings": {},
|
||||
"extensions": [
|
||||
"editorconfig.editorconfig",
|
||||
"dbaeumer.vscode-eslint"
|
||||
],
|
||||
"forwardPorts": [
|
||||
4321,
|
||||
35729
|
||||
],
|
||||
"portsAttributes": {
|
||||
"4321": {
|
||||
"protocol": "https",
|
||||
"label": "Manifest",
|
||||
"onAutoForward": "silent",
|
||||
"requireLocalPort": true
|
||||
},
|
||||
"35729": {
|
||||
"protocol": "https",
|
||||
"label": "LiveReload",
|
||||
"onAutoForward": "silent",
|
||||
"requireLocalPort": true
|
||||
}
|
||||
},
|
||||
"postCreateCommand": "bash .devcontainer/spfx-startup.sh",
|
||||
"remoteUser": "node"
|
||||
}
|
|
@ -0,0 +1,33 @@
|
|||
echo
|
||||
echo -e "\e[1;94mInstalling Node dependencies\e[0m"
|
||||
npm install
|
||||
|
||||
## commands to create dev certificate and copy it to the root folder of the project
|
||||
echo
|
||||
echo -e "\e[1;94mGenerating dev certificate\e[0m"
|
||||
gulp trust-dev-cert
|
||||
|
||||
# Convert the generated PEM certificate to a CER certificate
|
||||
openssl x509 -inform PEM -in ~/.rushstack/rushstack-serve.pem -outform DER -out ./spfx-dev-cert.cer
|
||||
|
||||
# Copy the PEM ecrtificate for non-Windows hosts
|
||||
cp ~/.rushstack/rushstack-serve.pem ./spfx-dev-cert.pem
|
||||
|
||||
## add *.cer to .gitignore to prevent certificates from being saved in repo
|
||||
if ! grep -Fxq '*.cer' ./.gitignore
|
||||
then
|
||||
echo "# .CER Certificates" >> .gitignore
|
||||
echo "*.cer" >> .gitignore
|
||||
fi
|
||||
|
||||
## add *.pem to .gitignore to prevent certificates from being saved in repo
|
||||
if ! grep -Fxq '*.pem' ./.gitignore
|
||||
then
|
||||
echo "# .PEM Certificates" >> .gitignore
|
||||
echo "*.pem" >> .gitignore
|
||||
fi
|
||||
|
||||
echo
|
||||
echo -e "\e[1;92mReady!\e[0m"
|
||||
|
||||
echo -e "\n\e[1;94m**********\nOptional: if you plan on using gulp serve, don't forget to add the container certificate to your local machine. Please visit https://aka.ms/spfx-devcontainer for more information\n**********"
|
|
@ -0,0 +1,20 @@
|
|||
# TeamsFx files
|
||||
env/.env.*.user
|
||||
env/.env.local
|
||||
.DS_Store
|
||||
build
|
||||
appPackage/build
|
||||
|
||||
# dependencies
|
||||
/node_modules
|
||||
|
||||
# testing
|
||||
/coverage
|
||||
|
||||
# production
|
||||
/build
|
||||
|
||||
# misc
|
||||
.DS_Store
|
||||
.env
|
||||
.deployment
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"extends": [
|
||||
"development"
|
||||
],
|
||||
"hints": {
|
||||
"no-inline-styles": "off"
|
||||
}
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
v18.18.0
|
|
@ -0,0 +1,88 @@
|
|||
# Sales Orders Web Part
|
||||
|
||||
## Summary
|
||||
|
||||
This Sample show how to use Microsoft Graph Connector that use DB2 Database and display Sales Orders in a list.
|
||||
|
||||
![react-sales-orders](./assets/salesOrders.gif)
|
||||
![react-sales-orders](./assets/teams01.png)
|
||||
![react-sales-orders](./assets/salesOrders02.png)
|
||||
|
||||
## Compatibility
|
||||
|
||||
| :warning: Important |
|
||||
|:---------------------------|
|
||||
| Every SPFx version is only compatible with specific version(s) of Node.js. In order to be able to build this sample, please ensure that the version of Node on your workstation matches one of the versions listed in this section. This sample will not work on a different version of Node.|
|
||||
|Refer to <https://aka.ms/spfx-matrix> for more information on SPFx compatibility. |
|
||||
|
||||
![SPFx 1.18.1](https://img.shields.io/badge/SPFx-1.18.1-green.svg)
|
||||
![Node.js v18 | v16](https://img.shields.io/badge/Node.js-v18%20|%20v16-green.svg)
|
||||
![SharePoint Online](https://img.shields.io/badge/SharePoint-Online-yellow.svg)
|
||||
![Workbench Hosted: Does not work with local workbench](https://img.shields.io/badge/Workbench-Hosted-yellow.svg "Does not work with local workbench")
|
||||
![Compatible with Remote Containers](https://img.shields.io/badge/Remote%20Containers-Compatible-green.svg)
|
||||
|
||||
## Applies to
|
||||
|
||||
* [SharePoint Framework](https://learn.microsoft.com/sharepoint/dev/spfx/sharepoint-framework-overview)
|
||||
* [Microsoft 365 tenant](https://learn.microsoft.com/sharepoint/dev/spfx/set-up-your-development-environment)
|
||||
|
||||
## Prerequisites
|
||||
|
||||
> This Sample required the Microsoft Graph Connector [nodejs-javascript-IBMDB2](https://github.com/pnp/graph-connectors-samples/tree/main/samples/nodejs-javascript-IBMDB2) to be installed in your tenant. Please see for more information. [graph-connectors-samples](https://github.com/pnp/graph-connectors-samples)
|
||||
|
||||
> * Please approve the required Microsoft Graph Permissions required (ExternalItem.Read.All).
|
||||
|
||||
## Contributors
|
||||
|
||||
* [João Mendes](https://github.com/joaojmendes)
|
||||
|
||||
## Version history
|
||||
|
||||
Version|Date|Comments
|
||||
-------|----|--------
|
||||
1.0.0|November 6, 2023|Initial release
|
||||
|
||||
|
||||
## Minimal Path to Awesome
|
||||
|
||||
The project was created with Visual Studio Teams Toolkit.
|
||||
This Application was developed and is optimized to use as FullPage Application
|
||||
|
||||
* Clone this repository
|
||||
* Navigate to `src` folder
|
||||
* in the command line run:
|
||||
* `npm install`
|
||||
* `gulp build`
|
||||
* `gulp bundle --ship`
|
||||
* `gulp package-solution --ship`
|
||||
* Add and Deploy Package to AppCatalog
|
||||
|
||||
## References
|
||||
|
||||
* [Getting started with SharePoint Framework](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/set-up-your-developer-tenant)
|
||||
* [Building for Microsoft teams](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/build-for-teams-overview)
|
||||
* [Use Microsoft Graph in your solution](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/web-parts/get-started/using-microsoft-graph-apis)
|
||||
* [Publish SharePoint Framework applications to the Marketplace](https://docs.microsoft.com/en-us/sharepoint/dev/spfx/publish-to-marketplace-overview)
|
||||
* [Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) - Guidance, tooling, samples and open-source controls for your Microsoft 365 development
|
||||
|
||||
## Help
|
||||
|
||||
We do not support samples, but this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues.
|
||||
|
||||
If you're having issues building the solution, please run [spfx doctor](https://pnp.github.io/cli-microsoft365/cmd/spfx/spfx-doctor/) from within the solution folder to diagnose incompatibility issues with your environment.
|
||||
|
||||
You can try looking at [issues related to this sample](https://github.com/pnp/sp-dev-fx-webparts/issues?q=label%3A%22sample%3A%20react-sales-orders%22) to see if anybody else is having the same issues.
|
||||
|
||||
You can also try looking at [discussions related to this sample](https://github.com/pnp/sp-dev-fx-webparts/discussions?discussions_q=react-sales-orders) and see what the community is saying.
|
||||
|
||||
If you encounter any issues using this sample, [create a new issue](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Abug-suspected%2Csample%3A%20react-sales-orders&template=bug-report.yml&sample=react-sales-orders&authors=@joaojmendes&title=react-sales-orders%20-%20).
|
||||
|
||||
For questions regarding this sample, [create a new question](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Aquestion%2Csample%3A%20react-sales-orders&template=question.yml&sample=react-sales-orders&authors=@joaojmendes&title=react-sales-orders%20-%20).
|
||||
|
||||
Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/sp-dev-fx-webparts/issues/new?assignees=&labels=Needs%3A+Triage+%3Amag%3A%2Ctype%3Aenhancement%2Csample%3A%20react-sales-orders&template=suggestion.yml&sample=react-sales-orders&authors=@joaojmendes&title=react-sales-orders%20-%20).
|
||||
|
||||
## Disclaimer
|
||||
|
||||
**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**
|
||||
|
||||
<img src="https://m365-visitor-stats.azurewebsites.net/sp-dev-fx-webparts/samples/react-sales-orders" />
|
After Width: | Height: | Size: 1.0 KiB |
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.16/MicrosoftTeams.schema.json",
|
||||
"manifestVersion": "1.16",
|
||||
"packageName": "com.microsoft.teams.extension",
|
||||
"id": "${{TEAMS_APP_ID}}",
|
||||
"version": "1.0.0",
|
||||
"developer": {
|
||||
"name": "SPFx + Teams Dev",
|
||||
"websiteUrl": "https://products.office.com/en-us/sharepoint/collaboration",
|
||||
"privacyUrl": "https://privacy.microsoft.com/en-us/privacystatement",
|
||||
"termsOfUseUrl": "https://www.microsoft.com/en-us/servicesagreement"
|
||||
},
|
||||
"name": {
|
||||
"short": "salesorders-${{TEAMSFX_ENV}}",
|
||||
"full": "Full name for salesorders"
|
||||
},
|
||||
"description": {
|
||||
"short": "Short description of salesorders",
|
||||
"full": "Full description of salesorders"
|
||||
},
|
||||
"icons": {
|
||||
"color": "color.png",
|
||||
"outline": "outline.png"
|
||||
},
|
||||
"accentColor": "#004578",
|
||||
"staticTabs": [
|
||||
{
|
||||
"entityId": "750d6853-1282-450a-b080-37aef954d745",
|
||||
"name": "salesorders",
|
||||
"contentUrl": "https://{teamSiteDomain}/_layouts/15/TeamsLogon.aspx?SPFX=true&dest=/_layouts/15/teamshostedapp.aspx%3Fteams%26personal%26componentId=750d6853-1282-450a-b080-37aef954d745%26forceLocale={locale}",
|
||||
"websiteUrl": "https://products.office.com/en-us/sharepoint/collaboration",
|
||||
"scopes": [
|
||||
"personal"
|
||||
]
|
||||
}
|
||||
],
|
||||
"configurableTabs": [
|
||||
{
|
||||
"configurationUrl": "https://{teamSiteDomain}{teamSitePath}/_layouts/15/TeamsLogon.aspx?SPFX=true&dest={teamSitePath}/_layouts/15/teamshostedapp.aspx%3FopenPropertyPane=true%26teams%26componentId=750d6853-1282-450a-b080-37aef954d745%26forceLocale={locale}",
|
||||
"canUpdateConfiguration": true,
|
||||
"scopes": [
|
||||
"team"
|
||||
]
|
||||
}
|
||||
],
|
||||
"permissions": [
|
||||
"identity",
|
||||
"messageTeamMembers"
|
||||
],
|
||||
"validDomains": [
|
||||
"*.login.microsoftonline.com",
|
||||
"*.sharepoint.com",
|
||||
"*.sharepoint-df.com",
|
||||
"spoppe-a.akamaihd.net",
|
||||
"spoprod-a.akamaihd.net",
|
||||
"resourceseng.blob.core.windows.net",
|
||||
"msft.spoppe.com"
|
||||
],
|
||||
"webApplicationInfo": {
|
||||
"resource": "https://{teamSiteDomain}",
|
||||
"id": "00000003-0000-0ff1-ce00-000000000000"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,63 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.16/MicrosoftTeams.schema.json",
|
||||
"manifestVersion": "1.16",
|
||||
"packageName": "com.microsoft.teams.extension",
|
||||
"id": "${{TEAMS_APP_ID}}",
|
||||
"version": "1.0.0",
|
||||
"developer": {
|
||||
"name": "SPFx + Teams Dev",
|
||||
"websiteUrl": "https://products.office.com/en-us/sharepoint/collaboration",
|
||||
"privacyUrl": "https://privacy.microsoft.com/en-us/privacystatement",
|
||||
"termsOfUseUrl": "https://www.microsoft.com/en-us/servicesagreement"
|
||||
},
|
||||
"name": {
|
||||
"short": "salesorders-${{TEAMSFX_ENV}}",
|
||||
"full": "Full name for salesorders"
|
||||
},
|
||||
"description": {
|
||||
"short": "Short description of salesorders",
|
||||
"full": "Full description of salesorders"
|
||||
},
|
||||
"icons": {
|
||||
"color": "color.png",
|
||||
"outline": "outline.png"
|
||||
},
|
||||
"accentColor": "#004578",
|
||||
"staticTabs": [
|
||||
{
|
||||
"entityId": "750d6853-1282-450a-b080-37aef954d745",
|
||||
"name": "salesorders",
|
||||
"contentUrl": "https://{teamSiteDomain}/_layouts/15/TeamsLogon.aspx?SPFX=true&dest={teamSitePath}/_layouts/15/TeamsWorkBench.aspx%3FcomponentId=750d6853-1282-450a-b080-37aef954d745%26teams%26personal%26forceLocale={locale}%26loadSPFX%3Dtrue%26debugManifestsFile%3Dhttps%3A%2F%2Flocalhost%3A4321%2Ftemp%2Fmanifests.js",
|
||||
"websiteUrl": "https://products.office.com/en-us/sharepoint/collaboration",
|
||||
"scopes": [
|
||||
"personal"
|
||||
]
|
||||
}
|
||||
],
|
||||
"configurableTabs": [
|
||||
{
|
||||
"configurationUrl": "https://{teamSiteDomain}{teamSitePath}/_layouts/15/TeamsLogon.aspx?SPFX=true&dest={teamSitePath}/_layouts/15/TeamsWorkBench.aspx%3FcomponentId=750d6853-1282-450a-b080-37aef954d745%26openPropertyPane=true%26teams%26forceLocale={locale}%26loadSPFX%3Dtrue%26debugManifestsFile%3Dhttps%3A%2F%2Flocalhost%3A4321%2Ftemp%2Fmanifests.js",
|
||||
"canUpdateConfiguration": true,
|
||||
"scopes": [
|
||||
"team"
|
||||
]
|
||||
}
|
||||
],
|
||||
"permissions": [
|
||||
"identity",
|
||||
"messageTeamMembers"
|
||||
],
|
||||
"validDomains": [
|
||||
"*.login.microsoftonline.com",
|
||||
"*.sharepoint.com",
|
||||
"*.sharepoint-df.com",
|
||||
"spoppe-a.akamaihd.net",
|
||||
"spoprod-a.akamaihd.net",
|
||||
"resourceseng.blob.core.windows.net",
|
||||
"msft.spoppe.com"
|
||||
],
|
||||
"webApplicationInfo": {
|
||||
"resource": "https://{teamSiteDomain}",
|
||||
"id": "00000003-0000-0ff1-ce00-000000000000"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 249 B |
After Width: | Height: | Size: 6.2 MiB |
After Width: | Height: | Size: 1.2 MiB |
After Width: | Height: | Size: 1.2 MiB |
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
"name": "pnp-sp-dev-spfx-web-parts-react-sales-orders",
|
||||
"source": "pnp",
|
||||
"title": "Sales Orders",
|
||||
"shortDescription": "Shows how how to use Microsoft Graph Connector that use DB2 Database and display Sales Orders in a list.",
|
||||
"url": "https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-sales-orders",
|
||||
"downloadUrl": "https://pnp.github.io/download-partial/?url=https://github.com/pnp/sp-dev-fx-webparts/tree/main/samples/react-sales-orders",
|
||||
"longDescription": [
|
||||
"This Sample show how to use Microsoft Graph Connector that use DB2 Database and display Sales Orders in a list."
|
||||
],
|
||||
"creationDateTime": "2023-11-06",
|
||||
"updateDateTime": "2023-11-06",
|
||||
"products": [
|
||||
"SharePoint"
|
||||
],
|
||||
"metadata": [
|
||||
{
|
||||
"key": "CLIENT-SIDE-DEV",
|
||||
"value": "React"
|
||||
},
|
||||
{
|
||||
"key": "SPFX-VERSION",
|
||||
"value": "1.18.0"
|
||||
}
|
||||
],
|
||||
"thumbnails": [
|
||||
{
|
||||
"name": "salesOrders.gif",
|
||||
"type": "image",
|
||||
"order": 100,
|
||||
"url": "https://github.com/pnp/sp-dev-fx-webparts/raw/main/samples/react-sales-orders/assets/salesOrders.gif",
|
||||
"alt": "Web Part Preview"
|
||||
},
|
||||
{
|
||||
"name": "salesOrders01.png",
|
||||
"type": "image",
|
||||
"order": 101,
|
||||
"url": "https://github.com/pnp/sp-dev-fx-webparts/raw/main/samples/react-sales-orders/assets/salesOrders01.png",
|
||||
"alt": "Web Part Preview"
|
||||
},
|
||||
{
|
||||
"name": "salesOrders02.png",
|
||||
"type": "image",
|
||||
"order": 102,
|
||||
"url": "https://github.com/pnp/sp-dev-fx-webparts/raw/main/samples/react-sales-orders/assets/salesOrders02.png",
|
||||
"alt": "Web Part Preview"
|
||||
},
|
||||
{
|
||||
"name": "teams01.png",
|
||||
"type": "image",
|
||||
"order": 103,
|
||||
"url": "https://github.com/pnp/sp-dev-fx-webparts/raw/main/samples/react-sales-orders/assets/teams01.png",
|
||||
"alt": "Web Part Preview"
|
||||
}
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"gitHubAccount": "YOUR-GITHUB-ACCOUNT",
|
||||
"pictureUrl": "https://github.com/YOUR-GITHUB-ACCOUNT.png",
|
||||
"name": "YOUR-NAME"
|
||||
}
|
||||
],
|
||||
"references": [
|
||||
{
|
||||
"name": "Build your first SharePoint client-side web part",
|
||||
"description": "Client-side web parts are client-side components that run in the context of a SharePoint page. Client-side web parts can be deployed to SharePoint environments that support the SharePoint Framework. You can also use modern JavaScript web frameworks, tools, and libraries to build them.",
|
||||
"url": "https://docs.microsoft.com/sharepoint/dev/spfx/web-parts/get-started/build-a-hello-world-web-part"
|
||||
}
|
||||
]
|
||||
}
|
After Width: | Height: | Size: 1.1 MiB |
|
@ -0,0 +1,7 @@
|
|||
# Built-in environment variables
|
||||
TEAMSFX_ENV=dev
|
||||
|
||||
# Generated during provision, you can also add your own variables.
|
||||
TEAMS_APP_ID=
|
||||
|
||||
# Secrets. Keys prefixed with `SECRET_` will be masked in Teams Toolkit logs.
|
|
@ -0,0 +1,17 @@
|
|||
{
|
||||
"name": "teamsfx-template-spfx-tab",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"engines": {
|
||||
"node": "16"
|
||||
},
|
||||
"author": "",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@microsoft/teamsfx-cli": "1.*"
|
||||
},
|
||||
"license": "MIT"
|
||||
|
||||
}
|
|
@ -0,0 +1,352 @@
|
|||
require('@rushstack/eslint-config/patch/modern-module-resolution');
|
||||
module.exports = {
|
||||
extends: ['@microsoft/eslint-config-spfx/lib/profiles/react'],
|
||||
parserOptions: { tsconfigRootDir: __dirname },
|
||||
overrides: [
|
||||
{
|
||||
files: ['*.ts', '*.tsx'],
|
||||
parser: '@typescript-eslint/parser',
|
||||
'parserOptions': {
|
||||
'project': './tsconfig.json',
|
||||
'ecmaVersion': 2018,
|
||||
'sourceType': 'module'
|
||||
},
|
||||
rules: {
|
||||
// Prevent usage of the JavaScript null value, while allowing code to access existing APIs that may require null. https://www.npmjs.com/package/@rushstack/eslint-plugin
|
||||
'@rushstack/no-new-null': 1,
|
||||
// Require Jest module mocking APIs to be called before any other statements in their code block. https://www.npmjs.com/package/@rushstack/eslint-plugin
|
||||
'@rushstack/hoist-jest-mock': 1,
|
||||
// Require regular expressions to be constructed from string constants rather than dynamically building strings at runtime. https://www.npmjs.com/package/@rushstack/eslint-plugin-security
|
||||
'@rushstack/security/no-unsafe-regexp': 1,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/adjacent-overload-signatures': 1,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
//
|
||||
// CONFIGURATION: By default, these are banned: String, Boolean, Number, Object, Symbol
|
||||
'@typescript-eslint/ban-types': [
|
||||
1,
|
||||
{
|
||||
'extendDefaults': false,
|
||||
'types': {
|
||||
'String': {
|
||||
'message': 'Use \'string\' instead',
|
||||
'fixWith': 'string'
|
||||
},
|
||||
'Boolean': {
|
||||
'message': 'Use \'boolean\' instead',
|
||||
'fixWith': 'boolean'
|
||||
},
|
||||
'Number': {
|
||||
'message': 'Use \'number\' instead',
|
||||
'fixWith': 'number'
|
||||
},
|
||||
'Object': {
|
||||
'message': 'Use \'object\' instead, or else define a proper TypeScript type:'
|
||||
},
|
||||
'Symbol': {
|
||||
'message': 'Use \'symbol\' instead',
|
||||
'fixWith': 'symbol'
|
||||
},
|
||||
'Function': {
|
||||
'message': 'The \'Function\' type accepts any function-like value.\nIt provides no type safety when calling the function, which can be a common source of bugs.\nIt also accepts things like class declarations, which will throw at runtime as they will not be called with \'new\'.\nIf you are expecting the function to accept certain arguments, you should explicitly define the function shape.'
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
// RATIONALE: Code is more readable when the type of every variable is immediately obvious.
|
||||
// Even if the compiler may be able to infer a type, this inference will be unavailable
|
||||
// to a person who is reviewing a GitHub diff. This rule makes writing code harder,
|
||||
// but writing code is a much less important activity than reading it.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/explicit-function-return-type': [
|
||||
1,
|
||||
{
|
||||
'allowExpressions': true,
|
||||
'allowTypedFunctionExpressions': true,
|
||||
'allowHigherOrderFunctions': false
|
||||
}
|
||||
],
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
// Rationale to disable: although this is a recommended rule, it is up to dev to select coding style.
|
||||
// Set to 1 (warning) or 2 (error) to enable.
|
||||
'@typescript-eslint/explicit-member-accessibility': 0,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-array-constructor': 1,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
//
|
||||
// RATIONALE: The "any" keyword disables static type checking, the main benefit of using TypeScript.
|
||||
// This rule should be suppressed only in very special cases such as JSON.stringify()
|
||||
// where the type really can be anything. Even if the type is flexible, another type
|
||||
// may be more appropriate such as "unknown", "{}", or "Record<k,V>".
|
||||
'@typescript-eslint/no-explicit-any': 1,
|
||||
// RATIONALE: The #1 rule of promises is that every promise chain must be terminated by a catch()
|
||||
// handler. Thus wherever a Promise arises, the code must either append a catch handler,
|
||||
// or else return the object to a caller (who assumes this responsibility). Unterminated
|
||||
// promise chains are a serious issue. Besides causing errors to be silently ignored,
|
||||
// they can also cause a NodeJS process to terminate unexpectedly.
|
||||
'@typescript-eslint/no-floating-promises': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'@typescript-eslint/no-for-in-array': 2,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-misused-new': 2,
|
||||
// RATIONALE: The "namespace" keyword is not recommended for organizing code because JavaScript lacks
|
||||
// a "using" statement to traverse namespaces. Nested namespaces prevent certain bundler
|
||||
// optimizations. If you are declaring loose functions/variables, it's better to make them
|
||||
// static members of a class, since classes support property getters and their private
|
||||
// members are accessible by unit tests. Also, the exercise of choosing a meaningful
|
||||
// class name tends to produce more discoverable APIs: for example, search+replacing
|
||||
// the function "reverse()" is likely to return many false matches, whereas if we always
|
||||
// write "Text.reverse()" is more unique. For large scale organization, it's recommended
|
||||
// to decompose your code into separate NPM packages, which ensures that component
|
||||
// dependencies are tracked more conscientiously.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-namespace': [
|
||||
1,
|
||||
{
|
||||
'allowDeclarations': false,
|
||||
'allowDefinitionFiles': false
|
||||
}
|
||||
],
|
||||
// RATIONALE: Parameter properties provide a shorthand such as "constructor(public title: string)"
|
||||
// that avoids the effort of declaring "title" as a field. This TypeScript feature makes
|
||||
// code easier to write, but arguably sacrifices readability: In the notes for
|
||||
// "@typescript-eslint/member-ordering" we pointed out that fields are central to
|
||||
// a class's design, so we wouldn't want to bury them in a constructor signature
|
||||
// just to save some typing.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
// Set to 1 (warning) or 2 (error) to enable the rule
|
||||
'@typescript-eslint/parameter-properties': 0,
|
||||
// RATIONALE: When left in shipping code, unused variables often indicate a mistake. Dead code
|
||||
// may impact performance.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-unused-vars': [
|
||||
1,
|
||||
{
|
||||
'vars': 'all',
|
||||
// Unused function arguments often indicate a mistake in JavaScript code. However in TypeScript code,
|
||||
// the compiler catches most of those mistakes, and unused arguments are fairly common for type signatures
|
||||
// that are overriding a base class method or implementing an interface.
|
||||
'args': 'none'
|
||||
}
|
||||
],
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/no-use-before-define': [
|
||||
2,
|
||||
{
|
||||
'functions': false,
|
||||
'classes': true,
|
||||
'variables': true,
|
||||
'enums': true,
|
||||
'typedefs': true
|
||||
}
|
||||
],
|
||||
// Disallows require statements except in import statements.
|
||||
// In other words, the use of forms such as var foo = require("foo") are banned. Instead use ES6 style imports or import foo = require("foo") imports.
|
||||
'@typescript-eslint/no-var-requires': 'error',
|
||||
// RATIONALE: The "module" keyword is deprecated except when describing legacy libraries.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'@typescript-eslint/prefer-namespace-keyword': 1,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
// Rationale to disable: it's up to developer to decide if he wants to add type annotations
|
||||
// Set to 1 (warning) or 2 (error) to enable the rule
|
||||
'@typescript-eslint/no-inferrable-types': 0,
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
// Rationale to disable: declaration of empty interfaces may be helpful for generic types scenarios
|
||||
'@typescript-eslint/no-empty-interface': 0,
|
||||
// RATIONALE: This rule warns if setters are defined without getters, which is probably a mistake.
|
||||
'accessor-pairs': 1,
|
||||
// RATIONALE: In TypeScript, if you write x["y"] instead of x.y, it disables type checking.
|
||||
'dot-notation': [
|
||||
1,
|
||||
{
|
||||
'allowPattern': '^_'
|
||||
}
|
||||
],
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
'eqeqeq': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'for-direction': 1,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'guard-for-in': 2,
|
||||
// RATIONALE: If you have more than 2,000 lines in a single source file, it's probably time
|
||||
// to split up your code.
|
||||
'max-lines': ['warn', { max: 2000 }],
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-async-promise-executor': 2,
|
||||
// RATIONALE: Deprecated language feature.
|
||||
'no-caller': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-compare-neg-zero': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-cond-assign': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-constant-condition': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-control-regex': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-debugger': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-delete-var': 2,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-duplicate-case': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-empty': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-empty-character-class': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-empty-pattern': 1,
|
||||
// RATIONALE: Eval is a security concern and a performance concern.
|
||||
'no-eval': 1,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-ex-assign': 2,
|
||||
// RATIONALE: System types are global and should not be tampered with in a scalable code base.
|
||||
// If two different libraries (or two versions of the same library) both try to modify
|
||||
// a type, only one of them can win. Polyfills are acceptable because they implement
|
||||
// a standardized interoperable contract, but polyfills are generally coded in plain
|
||||
// JavaScript.
|
||||
'no-extend-native': 1,
|
||||
// Disallow unnecessary labels
|
||||
'no-extra-label': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-fallthrough': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-func-assign': 1,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-implied-eval': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-invalid-regexp': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-label-var': 2,
|
||||
// RATIONALE: Eliminates redundant code.
|
||||
'no-lone-blocks': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-misleading-character-class': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-multi-str': 2,
|
||||
// RATIONALE: It's generally a bad practice to call "new Thing()" without assigning the result to
|
||||
// a variable. Either it's part of an awkward expression like "(new Thing()).doSomething()",
|
||||
// or else implies that the constructor is doing nontrivial computations, which is often
|
||||
// a poor class design.
|
||||
'no-new': 1,
|
||||
// RATIONALE: Obsolete language feature that is deprecated.
|
||||
'no-new-func': 2,
|
||||
// RATIONALE: Obsolete language feature that is deprecated.
|
||||
'no-new-object': 2,
|
||||
// RATIONALE: Obsolete notation.
|
||||
'no-new-wrappers': 1,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-octal': 2,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
'no-octal-escape': 2,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-regex-spaces': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-return-assign': 2,
|
||||
// RATIONALE: Security risk.
|
||||
'no-script-url': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-self-assign': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-self-compare': 2,
|
||||
// RATIONALE: This avoids statements such as "while (a = next(), a && a.length);" that use
|
||||
// commas to create compound expressions. In general code is more readable if each
|
||||
// step is split onto a separate line. This also makes it easier to set breakpoints
|
||||
// in the debugger.
|
||||
'no-sequences': 1,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-shadow-restricted-names': 2,
|
||||
// RATIONALE: Obsolete language feature that is deprecated.
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-sparse-arrays': 2,
|
||||
// RATIONALE: Although in theory JavaScript allows any possible data type to be thrown as an exception,
|
||||
// such flexibility adds pointless complexity, by requiring every catch block to test
|
||||
// the type of the object that it receives. Whereas if catch blocks can always assume
|
||||
// that their object implements the "Error" contract, then the code is simpler, and
|
||||
// we generally get useful additional information like a call stack.
|
||||
'no-throw-literal': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-unmodified-loop-condition': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-unsafe-finally': 2,
|
||||
// RATIONALE: Catches a common coding mistake.
|
||||
'no-unused-expressions': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-unused-labels': 1,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-useless-catch': 1,
|
||||
// RATIONALE: Avoids a potential performance problem.
|
||||
'no-useless-concat': 1,
|
||||
// RATIONALE: The "var" keyword is deprecated because of its confusing "hoisting" behavior.
|
||||
// Always use "let" or "const" instead.
|
||||
//
|
||||
// STANDARDIZED BY: @typescript-eslint\eslint-plugin\dist\configs\recommended.json
|
||||
'no-var': 2,
|
||||
// RATIONALE: Generally not needed in modern code.
|
||||
'no-void': 1,
|
||||
// RATIONALE: Obsolete language feature that is deprecated.
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'no-with': 2,
|
||||
// RATIONALE: Makes logic easier to understand, since constants always have a known value
|
||||
// @typescript-eslint\eslint-plugin\dist\configs\eslint-recommended.js
|
||||
'prefer-const': 1,
|
||||
// RATIONALE: Catches a common coding mistake where "resolve" and "reject" are confused.
|
||||
'promise/param-names': 2,
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'require-atomic-updates': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'require-yield': 1,
|
||||
// "Use strict" is redundant when using the TypeScript compiler.
|
||||
'strict': [
|
||||
2,
|
||||
'never'
|
||||
],
|
||||
// RATIONALE: Catches code that is likely to be incorrect
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
'use-isnan': 2,
|
||||
// STANDARDIZED BY: eslint\conf\eslint-recommended.js
|
||||
// Set to 1 (warning) or 2 (error) to enable.
|
||||
// Rationale to disable: !!{}
|
||||
'no-extra-boolean-cast': 0,
|
||||
// ====================================================================
|
||||
// @microsoft/eslint-plugin-spfx
|
||||
// ====================================================================
|
||||
'@microsoft/spfx/import-requires-chunk-name': 1,
|
||||
'@microsoft/spfx/no-require-ensure': 2,
|
||||
'@microsoft/spfx/pair-react-dom-render-unmount': 1
|
||||
}
|
||||
},
|
||||
{
|
||||
// For unit tests, we can be a little bit less strict. The settings below revise the
|
||||
// defaults specified in the extended configurations, as well as above.
|
||||
files: [
|
||||
// Test files
|
||||
'*.test.ts',
|
||||
'*.test.tsx',
|
||||
'*.spec.ts',
|
||||
'*.spec.tsx',
|
||||
|
||||
// Facebook convention
|
||||
'**/__mocks__/*.ts',
|
||||
'**/__mocks__/*.tsx',
|
||||
'**/__tests__/*.ts',
|
||||
'**/__tests__/*.tsx',
|
||||
|
||||
// Microsoft convention
|
||||
'**/test/*.ts',
|
||||
'**/test/*.tsx'
|
||||
],
|
||||
rules: {}
|
||||
}
|
||||
]
|
||||
};
|
|
@ -0,0 +1,34 @@
|
|||
# Logs
|
||||
logs
|
||||
*.log
|
||||
npm-debug.log*
|
||||
|
||||
# Dependency directories
|
||||
node_modules
|
||||
|
||||
# Build generated files
|
||||
dist
|
||||
lib
|
||||
release
|
||||
solution
|
||||
temp
|
||||
*.sppkg
|
||||
.heft
|
||||
|
||||
# Coverage directory used by tools like istanbul
|
||||
coverage
|
||||
|
||||
# OSX
|
||||
.DS_Store
|
||||
|
||||
# Visual Studio files
|
||||
.ntvs_analysis.dat
|
||||
.vs
|
||||
bin
|
||||
obj
|
||||
|
||||
# Resx Generated Code
|
||||
*.resx.ts
|
||||
|
||||
# Styles Generated Code
|
||||
*.scss.ts
|
|
@ -0,0 +1,16 @@
|
|||
!dist
|
||||
config
|
||||
|
||||
gulpfile.js
|
||||
|
||||
release
|
||||
src
|
||||
temp
|
||||
|
||||
tsconfig.json
|
||||
tslint.json
|
||||
|
||||
*.log
|
||||
|
||||
.yo-rc.json
|
||||
.vscode
|
|
@ -0,0 +1,24 @@
|
|||
{
|
||||
"@microsoft/generator-sharepoint": {
|
||||
"whichFolder": "subdir",
|
||||
"solutionName": "salesorders",
|
||||
"environment": "spo",
|
||||
"skipFeatureDeployment": true,
|
||||
"isDomainIsolated": false,
|
||||
"componentType": "webpart",
|
||||
"template": "react",
|
||||
"componentName": "salesorders",
|
||||
"plusBeta": false,
|
||||
"isCreatingSolution": true,
|
||||
"nodeVersion": "16.18.1",
|
||||
"sdksVersions": {
|
||||
"@microsoft/microsoft-graph-client": "3.0.2",
|
||||
"@microsoft/teams-js": "2.12.0"
|
||||
},
|
||||
"version": "1.18.0",
|
||||
"libraryName": "salesorders",
|
||||
"libraryId": "d0835894-052b-4728-8fa7-721ad33d4605",
|
||||
"packageManager": "npm",
|
||||
"solutionShortDescription": "salesorders description"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/config.2.0.schema.json",
|
||||
"version": "2.0",
|
||||
"bundles": {
|
||||
"salesorders-web-part": {
|
||||
"components": [
|
||||
{
|
||||
"entrypoint": "./lib/webparts/salesorders/SalesordersWebPart.js",
|
||||
"manifest": "./src/webparts/salesorders/SalesordersWebPart.manifest.json"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
"externals": {},
|
||||
"localizedResources": {
|
||||
"SalesordersWebPartStrings": "lib/webparts/salesorders/loc/{locale}.js"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/deploy-azure-storage.schema.json",
|
||||
"workingDir": "./release/assets/",
|
||||
"account": "<!-- STORAGE ACCOUNT NAME -->",
|
||||
"container": "salesorders",
|
||||
"accessKey": "<!-- ACCESS KEY -->"
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/package-solution.schema.json",
|
||||
"solution": {
|
||||
"name": "salesorders-client-side-solution",
|
||||
"id": "d0835894-052b-4728-8fa7-721ad33d4605",
|
||||
"version": "1.0.0.0",
|
||||
"includeClientSideAssets": true,
|
||||
"skipFeatureDeployment": true,
|
||||
"isDomainIsolated": false,
|
||||
"webApiPermissionRequests": [
|
||||
{
|
||||
"resource": "Microsoft Graph",
|
||||
"scope": "ExternalItem.Read.All"
|
||||
}
|
||||
],
|
||||
"developer": {
|
||||
"name": "",
|
||||
"websiteUrl": "",
|
||||
"privacyUrl": "",
|
||||
"termsOfUseUrl": "",
|
||||
"mpnId": "Undefined-1.18.0"
|
||||
},
|
||||
"metadata": {
|
||||
"shortDescription": {
|
||||
"default": "Sales Orders"
|
||||
},
|
||||
"longDescription": {
|
||||
"default": "Sales Orders"
|
||||
},
|
||||
"screenshotPaths": [],
|
||||
"videoUrl": "",
|
||||
"categories": []
|
||||
},
|
||||
"features": [
|
||||
{
|
||||
"title": "salesorders app",
|
||||
"description": "The feature that activates elements of the salesorders solution.",
|
||||
"id": "534d165b-de00-4e80-b8b4-7056027e256a",
|
||||
"version": "1.0.0.0"
|
||||
}
|
||||
]
|
||||
},
|
||||
"paths": {
|
||||
"zippedPackage": "solution/salesorders.sppkg"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/core-build/sass.schema.json"
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/spfx-serve.schema.json",
|
||||
"port": 4321,
|
||||
"https": true,
|
||||
"initialPage": "https://{tenantDomain}/_layouts/workbench.aspx"
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx-build/write-manifests.schema.json",
|
||||
"cdnBasePath": "<!-- PATH TO CDN -->"
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
'use strict';
|
||||
|
||||
const build = require('@microsoft/sp-build-web');
|
||||
|
||||
build.addSuppression(`Warning - [sass] The local CSS class 'ms-Grid' is not camelCase and will not be type-safe.`);
|
||||
|
||||
var getTasks = build.rig.getTasks;
|
||||
build.rig.getTasks = function () {
|
||||
var result = getTasks.call(build.rig);
|
||||
|
||||
result.set('serve', result.get('serve-deprecated'));
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
build.initialize(require('gulp'));
|
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
"name": "salesorders",
|
||||
"version": "1.0.0",
|
||||
"private": true,
|
||||
"engines": {
|
||||
"node": ">=16.13.0 <17.0.0 || >=18.17.1 <19.0.0"
|
||||
},
|
||||
"main": "lib/index.js",
|
||||
"scripts": {
|
||||
"build": "gulp bundle",
|
||||
"clean": "gulp clean",
|
||||
"test": "gulp test"
|
||||
},
|
||||
"dependencies": {
|
||||
"@fluentui/react": "^8.106.4",
|
||||
"@fluentui/react-components": "^9.37.3",
|
||||
"@fluentui/react-search-preview": "^0.1.30",
|
||||
"@iconify/react": "^4.1.1",
|
||||
"@microsoft/microsoft-graph-types": "^2.38.0",
|
||||
"@microsoft/sp-component-base": "1.18.0",
|
||||
"@microsoft/sp-core-library": "1.18.0",
|
||||
"@microsoft/sp-lodash-subset": "1.18.0",
|
||||
"@microsoft/sp-office-ui-fabric-core": "1.18.0",
|
||||
"@microsoft/sp-property-pane": "1.18.0",
|
||||
"@microsoft/sp-webpart-base": "1.18.0",
|
||||
"date-fns": "^2.30.0",
|
||||
"jotai": "^2.5.0",
|
||||
"react": "17.0.1",
|
||||
"react-dom": "17.0.1",
|
||||
"tslib": "2.3.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@microsoft/eslint-config-spfx": "1.18.0",
|
||||
"@microsoft/eslint-plugin-spfx": "1.18.0",
|
||||
"@microsoft/rush-stack-compiler-4.7": "0.1.0",
|
||||
"@microsoft/sp-build-web": "1.18.0",
|
||||
"@microsoft/sp-module-interfaces": "1.18.0",
|
||||
"@rushstack/eslint-config": "2.5.1",
|
||||
"@types/react": "17.0.45",
|
||||
"@types/react-dom": "17.0.17",
|
||||
"@types/webpack-env": "~1.15.2",
|
||||
"ajv": "^6.12.5",
|
||||
"eslint": "8.7.0",
|
||||
"eslint-plugin-react-hooks": "4.3.0",
|
||||
"gulp": "4.0.2",
|
||||
"typescript": "4.7.4"
|
||||
}
|
||||
}
|
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 12 KiB |
|
@ -0,0 +1,5 @@
|
|||
import { atom } from 'jotai';
|
||||
|
||||
import { IAppGlobalState } from '../models/IAppGlobalState';
|
||||
|
||||
export const appGlobalStateAtom = atom<IAppGlobalState>({} as IAppGlobalState);
|
|
@ -0,0 +1,14 @@
|
|||
import { Theme } from '@fluentui/react-components';
|
||||
import { BaseComponentContext } from '@microsoft/sp-component-base';
|
||||
|
||||
import { EAppHostName } from '../constants/EAppHostname';
|
||||
|
||||
export interface ISalesordersProps {
|
||||
title: string;
|
||||
isDarkTheme: boolean;
|
||||
hasTeamsContext: boolean;
|
||||
theme: Theme | undefined;
|
||||
themeString: string;
|
||||
context: BaseComponentContext
|
||||
appHostName: EAppHostName;
|
||||
}
|
|
@ -0,0 +1,34 @@
|
|||
@import '~@fluentui/react/dist/sass/References.scss';
|
||||
|
||||
.salesorders {
|
||||
overflow: hidden;
|
||||
padding: 1em;
|
||||
color: "[theme:bodyText, default: #323130]";
|
||||
color: var(--bodyText);
|
||||
&.teams {
|
||||
font-family: $ms-font-family-fallbacks;
|
||||
}
|
||||
}
|
||||
|
||||
.welcome {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.welcomeImage {
|
||||
width: 100%;
|
||||
max-width: 420px;
|
||||
}
|
||||
|
||||
.links {
|
||||
a {
|
||||
text-decoration: none;
|
||||
color: "[theme:link, default:#03787c]";
|
||||
color: var(--link); // note: CSS Custom Properties support is limited to modern browsers only
|
||||
|
||||
&:hover {
|
||||
text-decoration: underline;
|
||||
color: "[theme:linkHovered, default: #014446]";
|
||||
color: var(--linkHovered); // note: CSS Custom Properties support is limited to modern browsers only
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import { Provider } from 'jotai';
|
||||
|
||||
import {
|
||||
FluentProvider,
|
||||
teamsDarkTheme,
|
||||
teamsHighContrastTheme,
|
||||
teamsLightTheme,
|
||||
tokens,
|
||||
} from '@fluentui/react-components';
|
||||
|
||||
import { ISalesordersProps } from './ISalesordersProps';
|
||||
import { SalesordersControl } from './SalesordersControls';
|
||||
|
||||
export const Salesorders: React.FunctionComponent<ISalesordersProps> = (props: React.PropsWithChildren<ISalesordersProps>) => {
|
||||
const { themeString , } = props;
|
||||
return (
|
||||
<>
|
||||
<FluentProvider
|
||||
theme={
|
||||
themeString === "dark"
|
||||
? teamsDarkTheme
|
||||
: themeString === "contrast"
|
||||
? teamsHighContrastTheme
|
||||
: {
|
||||
...teamsLightTheme,
|
||||
colorNeutralBackground3: "#eeeeee",
|
||||
}
|
||||
}
|
||||
style={{ background: tokens.colorNeutralBackground3 }}
|
||||
>
|
||||
<Provider>
|
||||
<SalesordersControl {...props} />
|
||||
</Provider>
|
||||
</FluentProvider>
|
||||
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,206 @@
|
|||
/* eslint-disable no-debugger */
|
||||
/* eslint-disable @typescript-eslint/no-floating-promises */
|
||||
import * as React from 'react';
|
||||
|
||||
import { useAtom } from 'jotai';
|
||||
|
||||
import {
|
||||
Button,
|
||||
InputOnChangeData,
|
||||
Spinner,
|
||||
Title3,
|
||||
tokens,
|
||||
} from '@fluentui/react-components';
|
||||
import { SearchBox } from '@fluentui/react-search-preview';
|
||||
import { Icon } from '@iconify/react';
|
||||
|
||||
import { appGlobalStateAtom } from '../atoms/appGlobalStateAtom';
|
||||
import { EMessageType } from '../constants/EMessageTypes';
|
||||
import { useGraphAPI } from '../hooks/useGraphAPI';
|
||||
import { ICustomer } from '../models/ICustomer';
|
||||
import { IMenuItem } from '../models/IMenuItem';
|
||||
import { IOrder } from '../models/IOrder';
|
||||
import { ShowMessage } from '../showMessage/ShowMessage';
|
||||
import { CompanyInfo } from './companyInfo/CompanyInfo';
|
||||
import { CustomersGrid } from './customersGrid/CustomersGrid';
|
||||
import { ISalesordersProps } from './ISalesordersProps';
|
||||
import { Left } from './left/Left';
|
||||
import { Menu } from './menu/Menu';
|
||||
import { NoOrders } from './noOrders/NoOrders';
|
||||
import { OrdersGrid } from './ordersGrid/OrdersGrid';
|
||||
import { Right } from './right/Right';
|
||||
import { StatusOrdersInfo } from './statusOrdersInfo/StatusOrdersInfo';
|
||||
import { useSalesordersStyles } from './useSalesordersStyles';
|
||||
|
||||
export const SalesordersControl: React.FunctionComponent<ISalesordersProps> = (
|
||||
props: React.PropsWithChildren<ISalesordersProps>
|
||||
) => {
|
||||
const { context, hasTeamsContext } = props;
|
||||
const [appglobalState, setAppglobalState] = useAtom(appGlobalStateAtom);
|
||||
const styles = useSalesordersStyles();
|
||||
const divContainer = React.useRef<HTMLDivElement>(null);
|
||||
const [selectedItem, setSelectedItem] = React.useState<IMenuItem>({
|
||||
id: 1,
|
||||
title: "Orders",
|
||||
description: "Manage orders",
|
||||
icon: "map:grocery-or-supermarket",
|
||||
});
|
||||
const { searchOrders, getCustomers } = useGraphAPI(context);
|
||||
const [orders, setOrders] = React.useState<IOrder[]>([]);
|
||||
const [searchText, setSearchText] = React.useState<string>("");
|
||||
const [isLoading, setIsLoading] = React.useState<boolean>(false);
|
||||
const [customers, setCustomers] = React.useState<ICustomer[]>([]);
|
||||
const [error, setError] = React.useState<Error>((undefined as unknown) as Error);
|
||||
|
||||
|
||||
React.useEffect(() => {
|
||||
setAppglobalState({ ...appglobalState, ...props });
|
||||
// bug,gridtemplateareas is not reconized as CSS property
|
||||
if (divContainer.current) {
|
||||
const height = !hasTeamsContext ? "calc(100vh - 147px)" : "100vh";
|
||||
divContainer.current.setAttribute("style", `grid-template-areas: 'left right right right'; height: ${height}`);
|
||||
}
|
||||
setIsLoading(true);
|
||||
}, [props]);
|
||||
|
||||
React.useEffect(() => {
|
||||
(async () => {
|
||||
try {
|
||||
switch (selectedItem.id) {
|
||||
case 1:
|
||||
setOrders(await searchOrders(searchText));
|
||||
break;
|
||||
case 2:
|
||||
setCustomers(await getCustomers(searchText));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} catch (error) {
|
||||
debugger;
|
||||
setError(error);
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
/* const customers = await getCustomers(searchText);
|
||||
setCustomers(customers);
|
||||
setOrders(orders ); */
|
||||
/* setIsLoading(false); */
|
||||
})();
|
||||
}, [searchText, selectedItem, props, searchOrders, getCustomers]);
|
||||
|
||||
const totalOrders = React.useMemo(() => {
|
||||
return orders.length;
|
||||
}, [orders]);
|
||||
|
||||
const totalDelivered = React.useMemo(() => {
|
||||
return orders.filter((order) => order.status === "Shipped").length;
|
||||
}, [orders]);
|
||||
|
||||
const totalPeding = React.useMemo(() => {
|
||||
return orders.filter((order) => order.status === "New").length;
|
||||
}, [orders]);
|
||||
|
||||
const totalProcessing = React.useMemo(() => {
|
||||
return orders.filter((order) => order.status === "In-Process").length;
|
||||
}, [orders]);
|
||||
|
||||
const Header = React.useCallback((props: { title: string }): JSX.Element => {
|
||||
const { title } = props;
|
||||
return (
|
||||
<>
|
||||
<Title3>{title}</Title3>
|
||||
</>
|
||||
);
|
||||
}, []);
|
||||
|
||||
const hasOrders = React.useMemo(() => {
|
||||
return orders.length > 0;
|
||||
}, [orders]);
|
||||
|
||||
const renderSelectedContent = React.useCallback(() => {
|
||||
switch (selectedItem.id) {
|
||||
case 1:
|
||||
return (
|
||||
<>
|
||||
<StatusOrdersInfo
|
||||
totalOrders={totalOrders}
|
||||
totalDelivered={totalDelivered}
|
||||
pendingOrders={totalPeding}
|
||||
processingOrders={totalProcessing}
|
||||
/>
|
||||
|
||||
<OrdersGrid items={orders} />
|
||||
</>
|
||||
);
|
||||
case 2:
|
||||
return <CustomersGrid items={customers} />;
|
||||
default:
|
||||
return <div>Orders</div>;
|
||||
}
|
||||
}, [orders, selectedItem, customers, totalOrders, totalDelivered, totalPeding, totalProcessing]);
|
||||
|
||||
const title = React.useMemo(() => {
|
||||
switch (selectedItem.id) {
|
||||
case 1:
|
||||
return "Sales Orders";
|
||||
case 2:
|
||||
return "Customers";
|
||||
default:
|
||||
return "Sales Orders";
|
||||
}
|
||||
}, [selectedItem]);
|
||||
|
||||
const hasError = React.useMemo(() => {
|
||||
return !error ? false : true;
|
||||
}, [error]);
|
||||
|
||||
const RenderRightContent = React.useCallback(() => {
|
||||
if (hasError) {
|
||||
return <ShowMessage isShow={hasError} messageType={EMessageType.ERROR} message={error.message} />;
|
||||
}
|
||||
if (isLoading) {
|
||||
return (
|
||||
<div style={{ paddingTop: 60 }}>
|
||||
<Spinner />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return <>{!hasOrders ? <NoOrders /> : renderSelectedContent()}</>;
|
||||
}, [ hasError, error, isLoading, hasOrders, renderSelectedContent]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<main className={styles.mainContainer} style={{ height: !hasTeamsContext ? "calc(100vh - 147px)" : "100vh"}}>
|
||||
<div className={styles.contentContainer} ref={divContainer}>
|
||||
<Left>
|
||||
<CompanyInfo />
|
||||
<Menu currentItem={selectedItem as IMenuItem} onItemClick={(item) => setSelectedItem(item)} />
|
||||
</Left>
|
||||
<Right>
|
||||
<div className={styles.headerAndSearchContainer}>
|
||||
<Header title={title} />
|
||||
<SearchBox
|
||||
placeholder="Search by order number, customer name..."
|
||||
style={{ fontSize: tokens.fontSizeBase200, width: 300 }}
|
||||
onChange={(ev: React.ChangeEvent<HTMLInputElement>, data: InputOnChangeData) => {
|
||||
if (data.value.trim().length > 2) {
|
||||
setSearchText(data.value);
|
||||
}
|
||||
}}
|
||||
dismiss={
|
||||
<Button
|
||||
onClick={() => setSearchText("")}
|
||||
appearance="transparent"
|
||||
icon={<Icon icon="fluent:dismiss-20-regular" />}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<RenderRightContent />
|
||||
</Right>
|
||||
</div>
|
||||
</main>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,22 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import { Subtitle1 } from '@fluentui/react-components';
|
||||
import { Icon } from '@iconify/react';
|
||||
|
||||
import { useCompanyInfoStyles } from './useCompanyInfoStyles';
|
||||
|
||||
export interface ICompanyInfoProps {}
|
||||
|
||||
export const CompanyInfo: React.FunctionComponent<ICompanyInfoProps> = (
|
||||
props: React.PropsWithChildren<ICompanyInfoProps>
|
||||
) => {
|
||||
const styles = useCompanyInfoStyles();
|
||||
return (
|
||||
<>
|
||||
<div className={styles.infoContainer}>
|
||||
<Icon icon="mdi:company" width={36} height={36} />
|
||||
<Subtitle1 className={styles.headerTitle}>{"My Company"}</Subtitle1>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,29 @@
|
|||
import {
|
||||
makeStyles,
|
||||
shorthands,
|
||||
} from '@fluentui/react-components';
|
||||
|
||||
export const useCompanyInfoStyles = makeStyles({
|
||||
|
||||
infoContainer: {
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
justifyContent: "start",
|
||||
alignItems: "center",
|
||||
columnGap: "20px",
|
||||
paddingTop: "20px",
|
||||
paddingBottom: "80px",
|
||||
|
||||
},
|
||||
headerTitle: {
|
||||
display: "-webkit-box",
|
||||
"-webkit-line-clamp": "1",
|
||||
"-webkit-box-orient": "vertical",
|
||||
...shorthands.overflow("hidden"),
|
||||
textAlign: "start",
|
||||
textOverflow: "ellipsis",
|
||||
},
|
||||
itemDescription: {
|
||||
paddingLeft: "45px",
|
||||
},
|
||||
});
|
|
@ -0,0 +1,270 @@
|
|||
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
||||
import * as React from 'react';
|
||||
|
||||
import { useAtomValue } from 'jotai';
|
||||
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
createTableColumn,
|
||||
DataGrid,
|
||||
DataGridBody,
|
||||
DataGridCell,
|
||||
DataGridHeader,
|
||||
DataGridHeaderCell,
|
||||
DataGridProps,
|
||||
DataGridRow,
|
||||
Link,
|
||||
TableCellLayout,
|
||||
TableColumnDefinition,
|
||||
tokens,
|
||||
} from '@fluentui/react-components';
|
||||
|
||||
import { appGlobalStateAtom } from '../../atoms/appGlobalStateAtom';
|
||||
import { ICustomer } from '../../models/ICustomer';
|
||||
import { useCustomerGridStyles } from './useCustomerGridStyles';
|
||||
|
||||
const columns: TableColumnDefinition<ICustomer>[] = [
|
||||
createTableColumn<ICustomer>({
|
||||
columnId: "code",
|
||||
compare: (a, b) => {
|
||||
return a.customerCode < b.customerCode ? -1 : 1;
|
||||
},
|
||||
renderHeaderCell: () => {
|
||||
return <span style={{ fontWeight: 700 }}>Id</span>;
|
||||
},
|
||||
renderCell: (item) => {
|
||||
return <TableCellLayout truncate>{item.customerCode}</TableCellLayout>;
|
||||
},
|
||||
}),
|
||||
createTableColumn<ICustomer>({
|
||||
columnId: "customer",
|
||||
compare: (a, b) => {
|
||||
return a.customerName.localeCompare(b.customerName);
|
||||
},
|
||||
renderHeaderCell: () => {
|
||||
return <span style={{ fontWeight: 700 }}>Customer</span>;
|
||||
},
|
||||
renderCell: (item) => {
|
||||
return (
|
||||
<TableCellLayout appearance="primary" truncate media={<Avatar name={item.customerName} color="colorful" />}>
|
||||
{item.customerName}
|
||||
</TableCellLayout>
|
||||
);
|
||||
},
|
||||
}),
|
||||
createTableColumn<ICustomer>({
|
||||
columnId: "state",
|
||||
compare: (a, b) => {
|
||||
return a.customerState.localeCompare(b.customerState);
|
||||
},
|
||||
renderHeaderCell: () => {
|
||||
return <span style={{ fontWeight: 600 }}>State</span>;
|
||||
},
|
||||
renderCell: (item) => {
|
||||
return <TableCellLayout truncate>{item.customerState}</TableCellLayout>;
|
||||
},
|
||||
}),
|
||||
createTableColumn<ICustomer>({
|
||||
columnId: "country",
|
||||
compare: (a, b) => {
|
||||
return a.customerCountry.localeCompare(b.customerCountry);
|
||||
},
|
||||
renderHeaderCell: () => {
|
||||
return <span style={{ fontWeight: 600 }}>Country</span>;
|
||||
},
|
||||
|
||||
renderCell: (item) => {
|
||||
return <TableCellLayout truncate>{item.customerCountry}</TableCellLayout>;
|
||||
},
|
||||
}),
|
||||
|
||||
createTableColumn<ICustomer>({
|
||||
columnId: "email",
|
||||
compare: (a, b) => {
|
||||
return a.customerEmail.localeCompare(b.customerEmail);
|
||||
},
|
||||
renderHeaderCell: () => {
|
||||
return <span style={{ fontWeight: 700 }}>Email</span>;
|
||||
},
|
||||
renderCell: (item) => {
|
||||
return (
|
||||
<TableCellLayout truncate>
|
||||
<Link href={`mailto:${item.customerEmail}`}>{item.customerEmail} </Link>
|
||||
</TableCellLayout>
|
||||
);
|
||||
},
|
||||
}),
|
||||
createTableColumn<ICustomer>({
|
||||
columnId: "totalOrders",
|
||||
compare: (a, b) => {
|
||||
return a.totalOrders < b.totalOrders ? -1 : 1;
|
||||
},
|
||||
renderHeaderCell: () => {
|
||||
return <span style={{ fontWeight: 700 }}>Total Orders</span>;
|
||||
},
|
||||
renderCell: (item) => {
|
||||
return <TableCellLayout truncate>{item.totalOrders}</TableCellLayout>;
|
||||
},
|
||||
}),
|
||||
createTableColumn<ICustomer>({
|
||||
columnId: "lastOrder",
|
||||
compare: (a, b) => {
|
||||
return a.lastOrder < b.lastOrder ? -1 : 1;
|
||||
},
|
||||
renderHeaderCell: () => {
|
||||
return <span style={{ fontWeight: 700 }}>Last Order</span>;
|
||||
},
|
||||
renderCell: (item) => {
|
||||
return <TableCellLayout truncate>{item.lastOrder}</TableCellLayout>;
|
||||
},
|
||||
}),
|
||||
createTableColumn<ICustomer>({
|
||||
columnId: "lastOrderDate",
|
||||
compare: (a, b) => {
|
||||
return a.lastOrderDate.localeCompare(b.lastOrderDate);
|
||||
},
|
||||
renderHeaderCell: () => {
|
||||
return <span style={{ fontWeight: 700 }}>Last Order date</span>;
|
||||
},
|
||||
renderCell: (item) => {
|
||||
return <TableCellLayout truncate>{item.lastOrderDate}</TableCellLayout>;
|
||||
},
|
||||
}),
|
||||
createTableColumn<ICustomer>({
|
||||
columnId: "lastOrderTotal",
|
||||
compare: (a, b) => {
|
||||
return a.lastOrderTotal < b.lastOrderTotal ? -1 : 1;
|
||||
},
|
||||
renderHeaderCell: () => {
|
||||
return <span style={{ fontWeight: 700 }}>Last Order Total</span>;
|
||||
},
|
||||
renderCell: (item) => {
|
||||
return (
|
||||
<TableCellLayout truncate>
|
||||
<span style={{ color: tokens.colorBrandForeground1 }}>$ {item.lastOrderTotal}</span>
|
||||
</TableCellLayout>
|
||||
);
|
||||
},
|
||||
}),
|
||||
createTableColumn<ICustomer>({
|
||||
columnId: "status",
|
||||
compare: (a, b) => {
|
||||
return a.lastOrderStatus.localeCompare(b.lastOrderStatus);
|
||||
},
|
||||
renderHeaderCell: () => {
|
||||
return <span style={{ fontWeight: 700 }}>Status</span>;
|
||||
},
|
||||
renderCell: (item) => {
|
||||
const getColor = (status: string) => {
|
||||
switch (status) {
|
||||
case "In-Process":
|
||||
return "severe";
|
||||
case "Shipped":
|
||||
return "success";
|
||||
case "New":
|
||||
return "warning";
|
||||
default:
|
||||
return "brand";
|
||||
}
|
||||
};
|
||||
return (
|
||||
<TableCellLayout
|
||||
truncate
|
||||
media={
|
||||
<Badge appearance="filled" color={getColor(item.lastOrderStatus)}>
|
||||
{item.lastOrderStatus}
|
||||
</Badge>
|
||||
}
|
||||
/>
|
||||
);
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
const columnSizingOptions = {
|
||||
code: {
|
||||
minWidth: 50,
|
||||
defaultWidth: 50,
|
||||
idealWidth: 50,
|
||||
maxWidth: 50,
|
||||
},
|
||||
customer: {
|
||||
defaultWidth: 180,
|
||||
minWidth: 120,
|
||||
idealWidth: 180,
|
||||
},
|
||||
email: {
|
||||
defaultWidth: 180,
|
||||
minWidth: 120,
|
||||
idealWidth: 180,
|
||||
},
|
||||
state: {
|
||||
defaultWidth: 50,
|
||||
minWidth: 50,
|
||||
idealWidth: 50,
|
||||
},
|
||||
country: {
|
||||
defaultWidth: 50,
|
||||
minWidth: 50,
|
||||
idealWidth: 50,
|
||||
},
|
||||
totalOrders: {
|
||||
defaultWidth: 60,
|
||||
minWidth: 60,
|
||||
idealWidth: 60,
|
||||
},
|
||||
};
|
||||
|
||||
interface ICustomersGridProps {
|
||||
items: ICustomer[];
|
||||
}
|
||||
|
||||
export const CustomersGrid: React.FunctionComponent<ICustomersGridProps> = (
|
||||
props: React.PropsWithChildren<ICustomersGridProps>
|
||||
) => {
|
||||
const { items } = props;
|
||||
const appGlobalState = useAtomValue(appGlobalStateAtom);
|
||||
const {hasTeamsContext } = appGlobalState;
|
||||
const [sortState, setSortState] = React.useState<Parameters<NonNullable<DataGridProps["onSortChange"]>>[1]>({
|
||||
sortColumn: "customer",
|
||||
sortDirection: "ascending",
|
||||
});
|
||||
|
||||
|
||||
const onSortChange = React.useCallback((e, nextSortState) => {
|
||||
setSortState(nextSortState);
|
||||
}, []);
|
||||
|
||||
const styles = useCustomerGridStyles();
|
||||
|
||||
return (
|
||||
<div className={styles.gridContainer} style={{height: !hasTeamsContext ? 'calc(100vh - 397px': 'calc(100vh - 240px' }}>
|
||||
<DataGrid
|
||||
items={items}
|
||||
columns={columns}
|
||||
sortable
|
||||
sortState={sortState}
|
||||
onSortChange={onSortChange}
|
||||
resizableColumns
|
||||
columnSizingOptions={columnSizingOptions}
|
||||
size="medium"
|
||||
>
|
||||
<DataGridHeader>
|
||||
<DataGridRow>
|
||||
{({ renderHeaderCell }) => <DataGridHeaderCell>{renderHeaderCell()}</DataGridHeaderCell>}
|
||||
</DataGridRow>
|
||||
</DataGridHeader>
|
||||
<DataGridBody<ICustomer>>
|
||||
{({ item, rowId }) => (
|
||||
<DataGridRow<ICustomer> key={rowId}>
|
||||
{({ renderCell }) => <DataGridCell>{renderCell(item)}</DataGridCell>}
|
||||
</DataGridRow>
|
||||
)}
|
||||
</DataGridBody>
|
||||
</DataGrid>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
|
@ -0,0 +1,52 @@
|
|||
import {
|
||||
makeStyles,
|
||||
shorthands,
|
||||
tokens,
|
||||
} from '@fluentui/react-components';
|
||||
|
||||
export const useCustomerGridStyles = makeStyles({
|
||||
|
||||
gridContainer: {
|
||||
paddingTop: "30px",
|
||||
width: "100%",
|
||||
height: 'calc(100vh - 240px)',
|
||||
backgroundColor: tokens.colorNeutralBackground2,
|
||||
overflowY: "auto",
|
||||
overflowX: "hidden",
|
||||
"scrollbar-color": tokens.colorNeutralBackground1,
|
||||
"scrollbar-width": "thin",
|
||||
"::-webkit-scrollbar-thumb": {
|
||||
backgroundColor: tokens?.colorBrandStroke2,
|
||||
...shorthands.borderRadius("10px"),
|
||||
...shorthands.borderWidth("1px"),
|
||||
},
|
||||
"::-webkit-scrollbar": {
|
||||
height: "10px",
|
||||
width: "7px",
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
titleStyles: {
|
||||
paddingLeft: "20px",
|
||||
paddingRight: "20px",
|
||||
},
|
||||
|
||||
|
||||
emailColumnStyles: {
|
||||
display: "-webkit-box",
|
||||
"-webkit-line-clamp": "1",
|
||||
"-webkit-box-orient": "vertical",
|
||||
...shorthands.overflow("hidden"),
|
||||
textAlign: "start",
|
||||
textOverflow: "ellipsis",
|
||||
},
|
||||
|
||||
divider: {
|
||||
width: "100%",
|
||||
height: "1px",
|
||||
backgroundColor: tokens.colorNeutralStroke1,
|
||||
...shorthands.margin("20px 0px"),
|
||||
},
|
||||
|
||||
});
|
|
@ -0,0 +1,18 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import { BACKGROUND } from '../../constants/constants';
|
||||
import { useLeftStyles } from './useLeftStyles';
|
||||
|
||||
export interface ILeftProps {}
|
||||
|
||||
export const Left: React.FunctionComponent<ILeftProps> = (props: React.PropsWithChildren<ILeftProps>) => {
|
||||
const { children } = props;
|
||||
const styles = useLeftStyles();
|
||||
return (
|
||||
<>
|
||||
<div className={styles.leftContainer} style={{ background: BACKGROUND }}>
|
||||
{children}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,17 @@
|
|||
import {
|
||||
makeStyles,
|
||||
shorthands,
|
||||
} from '@fluentui/react-components';
|
||||
|
||||
export const useLeftStyles = makeStyles({
|
||||
|
||||
|
||||
leftContainer : {
|
||||
...shorthands.gridArea("left"),
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
rowGap: "20px",
|
||||
...shorthands.padding("20px"),
|
||||
},
|
||||
|
||||
});
|
|
@ -0,0 +1,45 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import { IMenuItem } from '../../models/IMenuItem';
|
||||
import { MenuItem } from './MenuItem';
|
||||
import { useMenuStyles } from './useMenuStyles';
|
||||
|
||||
export interface IMenuProps {
|
||||
|
||||
currentItem: IMenuItem;
|
||||
onItemClick: (item: IMenuItem) => void;
|
||||
}
|
||||
|
||||
const menuItems:IMenuItem[] = [
|
||||
{
|
||||
id : 1,
|
||||
title: "Orders",
|
||||
description: "Manage orders",
|
||||
icon: "map:grocery-or-supermarket" ,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
title: "Customers",
|
||||
description: "Manage customers",
|
||||
icon: "mingcute:user-2-line" ,
|
||||
}
|
||||
];
|
||||
|
||||
export const Menu: React.FunctionComponent<IMenuProps> = (props: React.PropsWithChildren<IMenuProps>) => {
|
||||
const { currentItem, onItemClick } = props;
|
||||
const styles = useMenuStyles();
|
||||
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={styles.mainContainer}>
|
||||
{menuItems.map((item, index) => {
|
||||
const isCurrentItem = item.id === currentItem.id;
|
||||
return (
|
||||
<MenuItem key={index} item={item} isCurrentItem={isCurrentItem} onItemClick={() => onItemClick(item)} />
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,50 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import {
|
||||
Body1Strong,
|
||||
Caption1,
|
||||
mergeClasses,
|
||||
tokens,
|
||||
} from '@fluentui/react-components';
|
||||
import { Icon } from '@iconify/react';
|
||||
|
||||
import { IMenuItem } from '../../models/IMenuItem';
|
||||
import { useMenuStyles } from './useMenuStyles';
|
||||
|
||||
export interface IStepItemProps {
|
||||
item: IMenuItem;
|
||||
isCurrentItem: boolean;
|
||||
onItemClick: () => void;
|
||||
}
|
||||
|
||||
export const MenuItem: React.FunctionComponent<IStepItemProps> = (props: React.PropsWithChildren<IStepItemProps>) => {
|
||||
const { item, isCurrentItem, onItemClick } = props;
|
||||
const { icon, title, description } = item;
|
||||
const styles = useMenuStyles();
|
||||
|
||||
const color = isCurrentItem ? tokens.colorBrandForeground1 : tokens.colorNeutralStrokeAccessible;
|
||||
|
||||
|
||||
|
||||
const ItemInfo = (props: { title: string; description: string; icon: JSX.Element; }):JSX.Element => {
|
||||
const { title, description, icon } = props;
|
||||
return (
|
||||
<div className={styles.itemContainer}>
|
||||
<div className={styles.itemTitle}>
|
||||
{icon}
|
||||
<Body1Strong className={styles.headerTitle} style={{ color: color }}>{title}</Body1Strong>
|
||||
</div>
|
||||
<Caption1 className={mergeClasses(styles.headerDescription, styles.itemDescription)}>
|
||||
{description}
|
||||
</Caption1>
|
||||
</div>
|
||||
)
|
||||
};
|
||||
return (
|
||||
<>
|
||||
<div style={{color: color}} className={mergeClasses(styles.menuItem)} onClick={() => onItemClick()}>
|
||||
<ItemInfo title={title} description={description as string} icon={<Icon icon={`${icon}`} width={24} height={24} color={color}/> } />
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,90 @@
|
|||
import {
|
||||
makeStyles,
|
||||
shorthands,
|
||||
tokens,
|
||||
} from '@fluentui/react-components';
|
||||
|
||||
export const useMenuStyles = makeStyles({
|
||||
mainContainer: {
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
justifyContent: "flex-start",
|
||||
rowGap: "30px",
|
||||
width: "100%",
|
||||
backgroundColor: "transparent",
|
||||
overflowY: "auto",
|
||||
overflowX: "hidden",
|
||||
"scrollbar-color": tokens.colorNeutralBackground1,
|
||||
"scrollbar-width": "thin",
|
||||
"::-webkit-scrollbar-thumb": {
|
||||
backgroundColor: tokens?.colorBrandStroke2,
|
||||
...shorthands.borderRadius("10px"),
|
||||
...shorthands.borderWidth("1px"),
|
||||
},
|
||||
"::-webkit-scrollbar": {
|
||||
height: "10px",
|
||||
width: "7px",
|
||||
},
|
||||
},
|
||||
|
||||
gradientOverlay: {
|
||||
position: "absolute",
|
||||
top: "0",
|
||||
left: "0",
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
...shorthands.borderRadius("8px"),
|
||||
},
|
||||
|
||||
headerContainer:{
|
||||
marginLeft: "auto",
|
||||
marginRight: "auto",
|
||||
maxWidth: "1106px",
|
||||
width: '100%',
|
||||
},
|
||||
menuItem:{
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
justifyContent: "start",
|
||||
|
||||
},
|
||||
|
||||
headerTitle: {
|
||||
display: "-webkit-box",
|
||||
"-webkit-line-clamp": "1",
|
||||
"-webkit-box-orient": "vertical",
|
||||
...shorthands.overflow("hidden"),
|
||||
textAlign: "start",
|
||||
textOverflow: "ellipsis",
|
||||
},
|
||||
headerDescription: {
|
||||
...shorthands.overflow("hidden"),
|
||||
display: "-webkit-box",
|
||||
"-webkit-line-clamp": "4",
|
||||
"-webkit-box-orient": "vertical",
|
||||
textAlign: "start",
|
||||
textOverflow: "ellipsis",
|
||||
|
||||
},
|
||||
itemContainer: {
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
justifyContent: "start",
|
||||
alignItems: "start",
|
||||
cursor: "pointer",
|
||||
|
||||
},
|
||||
itemTitle: {
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
justifyContent: "start",
|
||||
alignItems: "start",
|
||||
columnGap: "20px",
|
||||
rowGap: "5px",
|
||||
|
||||
|
||||
},
|
||||
itemDescription: {
|
||||
paddingLeft: "45px",
|
||||
},
|
||||
});
|
|
@ -0,0 +1,23 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import {
|
||||
Body2,
|
||||
tokens,
|
||||
} from '@fluentui/react-components';
|
||||
import { Icon } from '@iconify/react';
|
||||
|
||||
import { useNoOrdersStyles } from './useNoOrdersStyles';
|
||||
|
||||
export interface INoOrdersProps {}
|
||||
|
||||
export const NoOrders: React.FunctionComponent<INoOrdersProps> = (props: React.PropsWithChildren<INoOrdersProps>) => {
|
||||
const styles = useNoOrdersStyles();
|
||||
return (
|
||||
<>
|
||||
<div className={styles.container}>
|
||||
<Icon icon="fluent:cloud-database-20-regular" width={82} height={82} color={tokens.colorBrandForeground1} />
|
||||
<Body2>No orders found</Body2>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,14 @@
|
|||
import { makeStyles } from '@fluentui/react-components';
|
||||
|
||||
export const useNoOrdersStyles = makeStyles({
|
||||
container: {
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
justifyContent: "start",
|
||||
alignItems: "center",
|
||||
columnGap: "20px",
|
||||
rowGap: "20px",
|
||||
paddingTop: "40px",
|
||||
paddingBottom: "80px",
|
||||
},
|
||||
});
|
|
@ -0,0 +1,234 @@
|
|||
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
||||
import * as React from 'react';
|
||||
|
||||
import { useAtomValue } from 'jotai';
|
||||
|
||||
import {
|
||||
Avatar,
|
||||
Badge,
|
||||
createTableColumn,
|
||||
DataGrid,
|
||||
DataGridBody,
|
||||
DataGridCell,
|
||||
DataGridHeader,
|
||||
DataGridHeaderCell,
|
||||
DataGridProps,
|
||||
DataGridRow,
|
||||
Link,
|
||||
TableCellLayout,
|
||||
TableColumnDefinition,
|
||||
tokens,
|
||||
} from '@fluentui/react-components';
|
||||
|
||||
import { appGlobalStateAtom } from '../../atoms/appGlobalStateAtom';
|
||||
import { IOrder } from '../../models/IOrder';
|
||||
import { useOrdersGridStyles } from './useOrdersGridStyles';
|
||||
|
||||
const columns: TableColumnDefinition<IOrder>[] = [
|
||||
createTableColumn<IOrder>({
|
||||
columnId: "customer",
|
||||
compare: (a, b) => {
|
||||
return a.customer.localeCompare(b.customer);
|
||||
},
|
||||
renderHeaderCell: () => {
|
||||
return <span style={{ fontWeight: 700 }}>Customer</span>;
|
||||
},
|
||||
renderCell: (item) => {
|
||||
return (
|
||||
<TableCellLayout appearance="primary" truncate media={<Avatar name={item.customer} color="colorful" />}>
|
||||
{item.customer}
|
||||
</TableCellLayout>
|
||||
);
|
||||
},
|
||||
}),
|
||||
createTableColumn<IOrder>({
|
||||
columnId: "email",
|
||||
compare: (a, b) => {
|
||||
const customerEmailA = a?.custmoerEmail ?? "";
|
||||
const customerEmailB = b?.custmoerEmail ?? "";
|
||||
return customerEmailA.localeCompare(customerEmailB);
|
||||
},
|
||||
renderHeaderCell: () => {
|
||||
return <span style={{ fontWeight: 700 }}>Email</span>;
|
||||
},
|
||||
renderCell: (item) => {
|
||||
return (
|
||||
<TableCellLayout truncate>
|
||||
<Link href={`mailto:${item.custmoerEmail}`}>{item.custmoerEmail} </Link>
|
||||
</TableCellLayout>
|
||||
);
|
||||
},
|
||||
}),
|
||||
createTableColumn<IOrder>({
|
||||
columnId: "city",
|
||||
compare: (a, b) => {
|
||||
return a.city.localeCompare(b.city);
|
||||
},
|
||||
renderHeaderCell: () => {
|
||||
return <span style={{ fontWeight: 600 }}>City</span>;
|
||||
},
|
||||
renderCell: (item) => {
|
||||
return <TableCellLayout truncate>{item.city} </TableCellLayout>;
|
||||
},
|
||||
}),
|
||||
createTableColumn<IOrder>({
|
||||
columnId: "order",
|
||||
compare: (a, b) => {
|
||||
return a.order < b.order ? -1 : 1;
|
||||
},
|
||||
renderHeaderCell: () => {
|
||||
return <span style={{ fontWeight: 600 }}>Order</span>;
|
||||
},
|
||||
|
||||
renderCell: (item) => {
|
||||
return <TableCellLayout truncate>{item.order} </TableCellLayout>;
|
||||
},
|
||||
}),
|
||||
createTableColumn<IOrder>({
|
||||
columnId: "total",
|
||||
compare: (a, b) => {
|
||||
return a.total < b.total ? -1 : 1;
|
||||
},
|
||||
renderHeaderCell: () => {
|
||||
return <span style={{ fontWeight: 700 }}>Total</span>;
|
||||
},
|
||||
renderCell: (item) => {
|
||||
return (
|
||||
<TableCellLayout style={{ color: tokens.colorBrandForeground1, fontWeight: tokens.fontWeightMedium }} truncate>
|
||||
{` $ ${item.total} `}
|
||||
</TableCellLayout>
|
||||
);
|
||||
},
|
||||
}),
|
||||
createTableColumn<IOrder>({
|
||||
columnId: "orderDate",
|
||||
compare: (a, b) => {
|
||||
return a.orderDate.localeCompare(b.orderDate);
|
||||
},
|
||||
renderHeaderCell: () => {
|
||||
return <span style={{ fontWeight: 700 }}>Order Date</span>;
|
||||
},
|
||||
renderCell: (item) => {
|
||||
return <TableCellLayout truncate>{item.orderDate} </TableCellLayout>;
|
||||
},
|
||||
}),
|
||||
createTableColumn<IOrder>({
|
||||
columnId: "status",
|
||||
compare: (a, b) => {
|
||||
return a.status.localeCompare(b.status);
|
||||
},
|
||||
renderHeaderCell: () => {
|
||||
return <span style={{ fontWeight: 700 }}>Status</span>;
|
||||
},
|
||||
renderCell: (item) => {
|
||||
const getColor = (status: string) => {
|
||||
switch (status) {
|
||||
case "In-Process":
|
||||
return "severe";
|
||||
case "Shipped":
|
||||
return "success";
|
||||
case "New":
|
||||
return "warning";
|
||||
default:
|
||||
return "brand";
|
||||
}
|
||||
};
|
||||
return (
|
||||
<TableCellLayout
|
||||
truncate
|
||||
media={
|
||||
<Badge appearance="filled" color={getColor(item.status)}>
|
||||
{item.status}
|
||||
</Badge>
|
||||
}
|
||||
/>
|
||||
);
|
||||
},
|
||||
}),
|
||||
];
|
||||
|
||||
const columnSizingOptions = {
|
||||
customer: {
|
||||
defaultWidth: 180,
|
||||
minWidth: 120,
|
||||
idealWidth: 180,
|
||||
},
|
||||
email: {
|
||||
defaultWidth: 200,
|
||||
minWidth: 180,
|
||||
idealWidth: 200,
|
||||
},
|
||||
city: {
|
||||
defaultWidth: 100,
|
||||
minWidth: 120,
|
||||
idealWidth: 100,
|
||||
},
|
||||
order: {
|
||||
defaultWidth: 70,
|
||||
minWidth: 70,
|
||||
idealWidth: 70,
|
||||
},
|
||||
total: {
|
||||
defaultWidth: 100,
|
||||
minWidth: 100,
|
||||
idealWidth: 100,
|
||||
},
|
||||
orderDate: {
|
||||
defaultWidth: 100,
|
||||
minWidth: 100,
|
||||
idealWidth: 120,
|
||||
},
|
||||
status: {
|
||||
defaultWidth: 120,
|
||||
minWidth: 120,
|
||||
idealWidth: 120,
|
||||
},
|
||||
};
|
||||
|
||||
interface IOrdersGridProps {
|
||||
items: IOrder[];
|
||||
}
|
||||
|
||||
export const OrdersGrid: React.FunctionComponent<IOrdersGridProps> = (
|
||||
props: React.PropsWithChildren<IOrdersGridProps>
|
||||
) => {
|
||||
const { items } = props;
|
||||
const appGlobalState = useAtomValue(appGlobalStateAtom);
|
||||
const {hasTeamsContext } = appGlobalState;
|
||||
const [sortState, setSortState] = React.useState<Parameters<NonNullable<DataGridProps["onSortChange"]>>[1]>({
|
||||
sortColumn: "customer",
|
||||
sortDirection: "ascending",
|
||||
});
|
||||
const onSortChange = React.useCallback((e, nextSortState) => {
|
||||
setSortState(nextSortState);
|
||||
}, []);
|
||||
|
||||
const styles = useOrdersGridStyles();
|
||||
|
||||
return (
|
||||
<div className={styles.gridContainer} style={{height: !hasTeamsContext ? 'calc(100vh - 420px': 'calc(100vh - 240px' }}>
|
||||
<DataGrid
|
||||
items={items}
|
||||
columns={columns}
|
||||
sortable
|
||||
sortState={sortState}
|
||||
onSortChange={onSortChange}
|
||||
columnSizingOptions={columnSizingOptions}
|
||||
resizableColumns
|
||||
>
|
||||
<DataGridHeader>
|
||||
<DataGridRow>
|
||||
{({ renderHeaderCell }) => <DataGridHeaderCell>{renderHeaderCell()}</DataGridHeaderCell>}
|
||||
</DataGridRow>
|
||||
</DataGridHeader>
|
||||
<DataGridBody<IOrder>>
|
||||
{({ item, rowId }) => (
|
||||
<DataGridRow<IOrder> key={rowId}>
|
||||
{({ renderCell }) => <DataGridCell>{renderCell(item)}</DataGridCell>}
|
||||
</DataGridRow>
|
||||
)}
|
||||
</DataGridBody>
|
||||
</DataGrid>
|
||||
</div>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,29 @@
|
|||
import {
|
||||
makeStyles,
|
||||
shorthands,
|
||||
tokens,
|
||||
} from '@fluentui/react-components';
|
||||
|
||||
export const useOrdersGridStyles = makeStyles({
|
||||
gridContainer: {
|
||||
paddingTop: "30px",
|
||||
width: "100%",
|
||||
height: 'calc(100vh - 240px)',
|
||||
backgroundColor: tokens.colorNeutralBackground2,
|
||||
overflowY: "auto",
|
||||
overflowX: "hidden",
|
||||
"scrollbar-color": tokens.colorNeutralBackground1,
|
||||
"scrollbar-width": "thin",
|
||||
"::-webkit-scrollbar-thumb": {
|
||||
backgroundColor: tokens?.colorBrandStroke2,
|
||||
...shorthands.borderRadius("10px"),
|
||||
...shorthands.borderWidth("1px"),
|
||||
},
|
||||
"::-webkit-scrollbar": {
|
||||
height: "10px",
|
||||
width: "7px",
|
||||
},
|
||||
},
|
||||
|
||||
|
||||
});
|
|
@ -0,0 +1,18 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import { useRightStyles } from './useRightStyles';
|
||||
|
||||
export interface ILeftProps {}
|
||||
|
||||
export const Right: React.FunctionComponent<ILeftProps> = (props: React.PropsWithChildren<ILeftProps>) => {
|
||||
const { children } = props;
|
||||
const styles = useRightStyles();
|
||||
return (
|
||||
<>
|
||||
<div
|
||||
className={styles.rightContainer}>
|
||||
{children}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,19 @@
|
|||
import {
|
||||
makeStyles,
|
||||
shorthands,
|
||||
} from '@fluentui/react-components';
|
||||
|
||||
export const useRightStyles = makeStyles({
|
||||
|
||||
|
||||
rightContainer : {
|
||||
...shorthands.gridArea("right"),
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
columnGap: "20px",
|
||||
rowGap: "20px",
|
||||
...shorthands.padding("20px"),
|
||||
|
||||
},
|
||||
|
||||
});
|
|
@ -0,0 +1,53 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import {
|
||||
Body2,
|
||||
Card,
|
||||
CardHeader,
|
||||
Title2,
|
||||
tokens,
|
||||
} from '@fluentui/react-components';
|
||||
|
||||
import { useStatusOrdersInfoStyles } from './useStatusOrdersInfoStyles';
|
||||
|
||||
export interface IStatusOrdersInfoProps {
|
||||
totalOrders: number;
|
||||
totalDelivered: number;
|
||||
pendingOrders: number;
|
||||
processingOrders: number;
|
||||
}
|
||||
|
||||
export const StatusOrdersInfo: React.FunctionComponent<IStatusOrdersInfoProps> = (
|
||||
props: React.PropsWithChildren<IStatusOrdersInfoProps>
|
||||
) => {
|
||||
const styles = useStatusOrdersInfoStyles();
|
||||
const { totalOrders, totalDelivered, pendingOrders, processingOrders } = props;
|
||||
return (
|
||||
<>
|
||||
<div >
|
||||
<Card className={styles.card} appearance="outline">
|
||||
<CardHeader
|
||||
key={1}
|
||||
header={<Title2 style={{ color: tokens.colorPaletteBlueBorderActive }}>{totalOrders}</Title2>}
|
||||
description={<Body2>Total Orders</Body2>}
|
||||
/>
|
||||
<CardHeader
|
||||
key={2}
|
||||
header={<Title2 style={{ color: tokens.colorStatusSuccessForegroundInverted }}>{totalDelivered}</Title2>}
|
||||
description={<Body2>Total Delivered</Body2>}
|
||||
/>
|
||||
<CardHeader
|
||||
key={3}
|
||||
header={<Title2 style={{ color: tokens.colorStatusDangerForegroundInverted }}>{pendingOrders}</Title2>}
|
||||
description={<Body2>Pending Orders</Body2>}
|
||||
/>
|
||||
<CardHeader
|
||||
key={4}
|
||||
header={<Title2 style={{ color: tokens.colorPalettePeachBorderActive }}>{processingOrders}</Title2>}
|
||||
description={<Body2>Processing orders</Body2>}
|
||||
/>
|
||||
</Card>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,53 @@
|
|||
import {
|
||||
makeStyles,
|
||||
shorthands,
|
||||
tokens,
|
||||
} from '@fluentui/react-components';
|
||||
|
||||
export const useStatusOrdersInfoStyles = makeStyles({
|
||||
statusContainer: {
|
||||
position: "relative",
|
||||
width: "100%",
|
||||
display: "grid",
|
||||
gridTemplateColumns: "repeat(auto-fit, minmax(min(100%, 200px), 1fr)",
|
||||
gridColumnGap: "10px",
|
||||
gridRowGap: "10px",
|
||||
justifyContent: "center",
|
||||
paddingLeft: "30px",
|
||||
paddingRight: "30px",
|
||||
},
|
||||
card: {
|
||||
/* backgroundColor: tokens.colorNeutralBackground2, */
|
||||
paddingLeft: "30px",
|
||||
paddingRight: "30px",
|
||||
paddingTop: "20px",
|
||||
paddingBottom: "20px",
|
||||
fontFamily: `${tokens.fontFamilyBase}`,
|
||||
display: "grid",
|
||||
gridTemplateColumns: "repeat(auto-fit,minmax(min(100% ,200px),1fr))",
|
||||
gridColumnGap: "10px",
|
||||
gridRowGap: "10px",
|
||||
...shorthands.gap("20px"),
|
||||
},
|
||||
|
||||
gradientOverlay: {
|
||||
position: "absolute",
|
||||
top: "0",
|
||||
left: "0",
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
|
||||
...shorthands.borderRadius("8px"),
|
||||
},
|
||||
titleStyles: {
|
||||
paddingLeft: "20px",
|
||||
paddingRight: "20px",
|
||||
},
|
||||
|
||||
cardBody: {
|
||||
|
||||
width: "100%",
|
||||
height: "fit-content",
|
||||
...shorthands.borderRadius("16px"),
|
||||
},
|
||||
});
|
|
@ -0,0 +1,68 @@
|
|||
import {
|
||||
makeStyles,
|
||||
shorthands,
|
||||
tokens,
|
||||
} from '@fluentui/react-components';
|
||||
|
||||
export const useSalesordersStyles = makeStyles({
|
||||
mainContainer: {
|
||||
width: "100%",
|
||||
height: "100vh",
|
||||
|
||||
backgroundColor: tokens.colorNeutralBackground2,
|
||||
overflowY: "auto",
|
||||
overflowX: "hidden",
|
||||
},
|
||||
|
||||
contentContainer: {
|
||||
display: "grid",
|
||||
gridTemplateColumns: "min(100%, 300px) 1fr 1fr 1fr",
|
||||
gridTemplateRows: "1fr",
|
||||
height: "100vh",
|
||||
},
|
||||
|
||||
leftContainer : {
|
||||
...shorthands.gridArea("left"),
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
rowGap: "20px",
|
||||
...shorthands.padding("20px"),
|
||||
},
|
||||
rightContainer : {
|
||||
...shorthands.gridArea("right"),
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
rowGap: "20px",
|
||||
...shorthands.padding("20px"),
|
||||
},
|
||||
|
||||
gradientOverlay: {
|
||||
position: "absolute",
|
||||
top: "0",
|
||||
left: "0",
|
||||
width: "100%",
|
||||
height: "100%",
|
||||
...shorthands.borderRadius("8px"),
|
||||
},
|
||||
|
||||
headerContainer:{
|
||||
marginLeft: "auto",
|
||||
marginRight: "auto",
|
||||
maxWidth: "1106px",
|
||||
width: '100%',
|
||||
},
|
||||
imageTop:{
|
||||
width: "100%", height: "300px" ,
|
||||
[ `@media (max-width: 768px)`]: {
|
||||
height: "400px",
|
||||
},
|
||||
},
|
||||
headerAndSearchContainer:{
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
justifyContent: "space-between",
|
||||
rowGap: "20px",
|
||||
...shorthands.padding("20px 0px"),
|
||||
|
||||
} ,
|
||||
});
|
|
@ -0,0 +1,6 @@
|
|||
export enum EAppHostName {
|
||||
SharePoint = "SharePoint",
|
||||
Teams = "Teams",
|
||||
Outlook = "Outlook",
|
||||
Office = "Office",
|
||||
}
|
|
@ -0,0 +1,5 @@
|
|||
export enum EMessageType {
|
||||
INFO = 'info',
|
||||
ERROR = 'error',
|
||||
SUCCESS = 'success',
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
export const BACKGROUND = "linear-gradient(122.54deg, rgba(19, 29, 255, 0.2) 0%, rgba(97, 217, 149, 0.2) 100%)";
|
|
@ -0,0 +1,181 @@
|
|||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
|
||||
import * as React from 'react';
|
||||
|
||||
import { SearchHit } from '@microsoft/microsoft-graph-types';
|
||||
import { BaseComponentContext } from '@microsoft/sp-component-base';
|
||||
import {
|
||||
sortBy,
|
||||
uniqBy,
|
||||
} from '@microsoft/sp-lodash-subset';
|
||||
|
||||
import { ICustomer } from '../models/ICustomer';
|
||||
import { IOrder } from '../models/IOrder';
|
||||
|
||||
interface IuseGraphAPI {
|
||||
searchOrders: (searchText: string) => Promise<any>;
|
||||
getCustomers: (searchText: string) => Promise<ICustomer[] | []>;
|
||||
}
|
||||
|
||||
export const useGraphAPI = (context: BaseComponentContext): IuseGraphAPI => {
|
||||
const graphClient = React.useMemo(async () => {
|
||||
if (!context) return undefined;
|
||||
return await context.msGraphClientFactory.getClient("3");
|
||||
}, [context]);
|
||||
|
||||
const mappingOrders = React.useCallback(
|
||||
(result: SearchHit[]): IOrder[] => {
|
||||
const ordersList: IOrder[] = [];
|
||||
for (const item of result) {
|
||||
const { resource } = item;
|
||||
if (resource) {
|
||||
const { properties } = resource as any;
|
||||
if (properties) {
|
||||
const {
|
||||
id,
|
||||
custcode,
|
||||
custname,
|
||||
email,
|
||||
state,
|
||||
country,
|
||||
orders,
|
||||
orderdates,
|
||||
ordertotals,
|
||||
orderstatus,
|
||||
} = properties as any;
|
||||
|
||||
for (let i = 0; i < orders.length; i++) {
|
||||
const order: IOrder = {
|
||||
customer: custname,
|
||||
city: `${state} ${country}`,
|
||||
order: orders[i],
|
||||
total: ordertotals[i],
|
||||
orderDate: orderdates[i],
|
||||
status: orderstatus[i],
|
||||
customerCode: custcode,
|
||||
custmoerEmail: email,
|
||||
customerState: state,
|
||||
id: id,
|
||||
};
|
||||
ordersList.push(order);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ordersList;
|
||||
},
|
||||
[graphClient]
|
||||
);
|
||||
|
||||
const mappingCustomers = React.useCallback(
|
||||
(result: SearchHit[]): ICustomer[] => {
|
||||
const customersList: ICustomer[] = [];
|
||||
for (const item of result) {
|
||||
const { resource } = item;
|
||||
if (resource) {
|
||||
const { properties } = resource as any;
|
||||
if (properties) {
|
||||
const {
|
||||
custcode,
|
||||
custname,
|
||||
email,
|
||||
state,
|
||||
country,
|
||||
orders,
|
||||
orderdates,
|
||||
ordertotals,
|
||||
orderstatus,
|
||||
} = properties as any;
|
||||
|
||||
const customer: ICustomer = {
|
||||
customerName: custname,
|
||||
customerCode: custcode,
|
||||
customerEmail: email,
|
||||
customerState: state,
|
||||
customerCountry: country,
|
||||
lastOrder: orders[orders.length - 1],
|
||||
totalOrders: orders.length,
|
||||
lastOrderDate: orderdates[orderdates.length - 1],
|
||||
lastOrderTotal: ordertotals[ordertotals.length - 1],
|
||||
lastOrderStatus: orderstatus[orderstatus.length - 1],
|
||||
};
|
||||
customersList.push(customer);
|
||||
}
|
||||
}
|
||||
}
|
||||
return customersList;
|
||||
},
|
||||
[graphClient]
|
||||
);
|
||||
|
||||
const searchOrders = React.useCallback(
|
||||
async (searchText: string): Promise<any> => {
|
||||
if (!graphClient) return undefined;
|
||||
|
||||
const request = {
|
||||
requests: [
|
||||
{
|
||||
entityTypes: ["externalItem"],
|
||||
contentSources: ["/external/connections/ibmdb2lob"],
|
||||
query: {
|
||||
queryString: `${searchText}*`,
|
||||
},
|
||||
from: 0,
|
||||
size: 100,
|
||||
},
|
||||
],
|
||||
};
|
||||
|
||||
try {
|
||||
const response = await (await graphClient)?.api(`search/query`).post(request);
|
||||
|
||||
const result: SearchHit[] = response?.value[0]?.hitsContainers[0]?.hits;
|
||||
if (!result) return [];
|
||||
|
||||
const ordersList = mappingOrders(result);
|
||||
console.log(ordersList);
|
||||
return ordersList;
|
||||
} catch (error) {
|
||||
console.log("[searchOrders] error:", error);
|
||||
throw new Error("Something went wrong when search Orders");
|
||||
}
|
||||
},
|
||||
[graphClient]
|
||||
);
|
||||
|
||||
const getCustomers = React.useCallback(
|
||||
async (searchText: string): Promise<ICustomer[] | []> => {
|
||||
if (!graphClient) return [];
|
||||
const request = {
|
||||
requests: [
|
||||
{
|
||||
entityTypes: ["externalItem"],
|
||||
contentSources: ["/external/connections/ibmdb2lob"],
|
||||
query: {
|
||||
queryString: `${searchText}*`,
|
||||
},
|
||||
from: 0,
|
||||
size: 100,
|
||||
},
|
||||
],
|
||||
};
|
||||
try {
|
||||
const response = await (await graphClient)?.api(`search/query`).post(request);
|
||||
|
||||
const result: SearchHit[] = response?.value[0]?.hitsContainers[0]?.hits;
|
||||
const customersList = mappingCustomers(result);
|
||||
const uniqueCustomers = uniqBy(customersList, "customerCode");
|
||||
return sortBy(uniqueCustomers, "customerName");
|
||||
} catch (error) {
|
||||
console.log("[getCustomers] error:", error);
|
||||
throw new Error("Something went wrong when getting customers");
|
||||
}
|
||||
},
|
||||
[graphClient]
|
||||
);
|
||||
|
||||
return {
|
||||
searchOrders,
|
||||
getCustomers,
|
||||
};
|
||||
};
|
|
@ -0,0 +1,40 @@
|
|||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
|
||||
import addSeconds from 'date-fns/addSeconds';
|
||||
import isAfter from 'date-fns/isAfter';
|
||||
|
||||
/* eslint-disable @typescript-eslint/explicit-function-return-type */
|
||||
interface IStorage {
|
||||
value: unknown;
|
||||
expires?: Date;
|
||||
}
|
||||
|
||||
const DEFAULT_EXPIRED_IN_SECONDS = 60 * 30; // 30 min
|
||||
|
||||
export const useCache = (cacheType: "local" | "session") => {
|
||||
const setCacheValue = (key: string, newValue: unknown, expiredInSeconds?: number) => {
|
||||
const expires = addSeconds(new Date(), expiredInSeconds ?? DEFAULT_EXPIRED_IN_SECONDS);
|
||||
if (cacheType === "session") {
|
||||
sessionStorage.setItem(key, JSON.stringify({ value: newValue, expires: expires.getTime() }));
|
||||
} else {
|
||||
localStorage.setItem(key, JSON.stringify({ value: newValue, expires: expires.getTime() }));
|
||||
}
|
||||
};
|
||||
const getCacheValue = (key: string): any => {
|
||||
let storage: IStorage = {} as IStorage;
|
||||
if (cacheType === "session") {
|
||||
storage = JSON.parse(sessionStorage.getItem(key) || "{}");
|
||||
} else {
|
||||
storage = JSON.parse(localStorage.getItem(key) || "{}");
|
||||
}
|
||||
|
||||
// getting stored value
|
||||
const { value, expires } = storage || ({} as IStorage);
|
||||
if (expires && isAfter(new Date(expires as any), new Date())) {
|
||||
return value;
|
||||
}
|
||||
return undefined;
|
||||
};
|
||||
|
||||
return { getCacheValue, setCacheValue };
|
||||
};
|
|
@ -0,0 +1 @@
|
|||
// A file is required to be in the root of the /src directory by the TypeScript compiler
|
|
@ -0,0 +1,3 @@
|
|||
import { ISalesordersProps } from "../components/ISalesordersProps";
|
||||
export interface IAppGlobalState extends ISalesordersProps{
|
||||
}
|
|
@ -0,0 +1,12 @@
|
|||
export interface ICustomer {
|
||||
customerName: string;
|
||||
customerCode: string;
|
||||
customerEmail: string;
|
||||
customerState: string;
|
||||
customerCountry: string;
|
||||
lastOrder: number
|
||||
totalOrders: number;
|
||||
lastOrderDate: string;
|
||||
lastOrderTotal: number;
|
||||
lastOrderStatus: string;
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
export interface IMenuItem {
|
||||
id:number
|
||||
title: string;
|
||||
description?: string;
|
||||
content?: string;
|
||||
icon?: string;
|
||||
}
|
|
@ -0,0 +1,14 @@
|
|||
|
||||
|
||||
export interface IOrder {
|
||||
id?: string;
|
||||
customer: string;
|
||||
city: string;
|
||||
order: number;
|
||||
total: string;
|
||||
orderDate: string;
|
||||
status: string;
|
||||
customerCode?: number;
|
||||
custmoerEmail?: string;
|
||||
customerState?: string;
|
||||
}
|
|
@ -0,0 +1,10 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import { EMessageType } from '../constants/EMessageTypes';
|
||||
|
||||
export interface IShowMessageProps {
|
||||
isShow: boolean;
|
||||
messageType: EMessageType;
|
||||
message: string | React.ReactNode;
|
||||
children?: React.ReactNode;
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
import * as React from 'react';
|
||||
|
||||
import {
|
||||
Body1,
|
||||
Body1Strong,
|
||||
tokens,
|
||||
} from '@fluentui/react-components';
|
||||
import {
|
||||
CheckmarkCircle32Regular,
|
||||
Info32Regular,
|
||||
} from '@fluentui/react-icons';
|
||||
import { Icon } from '@iconify/react';
|
||||
|
||||
import { EMessageType } from '../constants/EMessageTypes';
|
||||
import { IShowMessageProps } from './IShowMessageProps';
|
||||
import { useShowMessageStyles } from './useShowMessageStyles';
|
||||
|
||||
export const ShowMessage: React.FunctionComponent<IShowMessageProps> = (
|
||||
props: React.PropsWithChildren<IShowMessageProps>
|
||||
) => {
|
||||
const { messageType, children, message, isShow } = props;
|
||||
const styles = useShowMessageStyles();
|
||||
const [renderMessageIcon, setRenderMessageIcon] = React.useState<JSX.Element | null>(null);
|
||||
|
||||
const RenderError = React.useCallback(() => {
|
||||
return (
|
||||
<>
|
||||
<div className={styles.errorContainer}>
|
||||
<div className={styles.errorIcon}>
|
||||
<Icon
|
||||
icon="fluent:error-circle-24-regular"
|
||||
width="32"
|
||||
height="32"
|
||||
color={tokens.colorStatusDangerForeground1}
|
||||
/>
|
||||
</div>
|
||||
<Body1 style={{ width: "100%" }}>{message}</Body1>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
}, [message]);
|
||||
|
||||
React.useEffect(() => {
|
||||
switch (messageType) {
|
||||
case EMessageType.SUCCESS:
|
||||
setRenderMessageIcon(<CheckmarkCircle32Regular primaryFill={tokens.colorStatusSuccessForeground1} />);
|
||||
break;
|
||||
case EMessageType.INFO:
|
||||
setRenderMessageIcon(<Info32Regular primaryFill={tokens.colorStatusWarningForeground1} />);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}, [messageType]);
|
||||
|
||||
if (!isShow) {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
if (messageType === EMessageType.ERROR) {
|
||||
return <RenderError />;
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<div className={styles.root}>
|
||||
{renderMessageIcon}
|
||||
<Body1Strong>{messageType}</Body1Strong>
|
||||
{children}
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
|
@ -0,0 +1,35 @@
|
|||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import {
|
||||
makeStyles,
|
||||
shorthands,
|
||||
tokens,
|
||||
} from '@fluentui/react-components';
|
||||
|
||||
export const useShowMessageStyles = makeStyles({
|
||||
root: {
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
justifyContent: "center",
|
||||
alignItems: "center",
|
||||
...shorthands.padding("10px"),
|
||||
...shorthands.gap("10px"),
|
||||
width: '100%',
|
||||
} ,
|
||||
iconClass: {
|
||||
width: "32px",
|
||||
height: "32px",
|
||||
} as any,
|
||||
errorContainer: {
|
||||
display: "flex",
|
||||
flexDirection: "row",
|
||||
justifyContent: "start",
|
||||
alignItems: "center",
|
||||
...shorthands.gap("10px"),
|
||||
...shorthands.padding("10px"),
|
||||
backgroundColor: tokens.colorStatusDangerBackground1,
|
||||
} ,
|
||||
errorIcon: {
|
||||
width: "32px",
|
||||
height: "32px",
|
||||
} ,
|
||||
});
|
|
@ -0,0 +1,28 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/json-schemas/spfx/client-side-web-part-manifest.schema.json",
|
||||
"id": "750d6853-1282-450a-b080-37aef954d745",
|
||||
"alias": "SalesordersWebPart",
|
||||
"componentType": "WebPart",
|
||||
|
||||
// The "*" signifies that the version should be taken from the package.json
|
||||
"version": "*",
|
||||
"manifestVersion": 2,
|
||||
|
||||
// If true, the component can only be installed on sites where Custom Script is allowed.
|
||||
// Components that allow authors to embed arbitrary script code should set this to true.
|
||||
// https://support.office.com/en-us/article/Turn-scripting-capabilities-on-or-off-1f2c515f-5d7e-448a-9fd7-835da935584f
|
||||
"requiresCustomScript": false,
|
||||
"supportedHosts": ["SharePointWebPart", "TeamsPersonalApp", "TeamsTab", "SharePointFullPage"],
|
||||
"supportsThemeVariants": true,
|
||||
|
||||
"preconfiguredEntries": [{
|
||||
"groupId": "5c03119e-3074-46fd-976b-c60198311f70", // Advanced
|
||||
"group": { "default": "Advanced" },
|
||||
"title": { "default": "salesorders" },
|
||||
"description": { "default": "salesorders description" },
|
||||
"officeFabricIconFontName": "Page",
|
||||
"properties": {
|
||||
"description": "salesorders"
|
||||
}
|
||||
}]
|
||||
}
|
|
@ -0,0 +1,134 @@
|
|||
import * as React from 'react';
|
||||
import * as ReactDom from 'react-dom';
|
||||
|
||||
import * as strings from 'SalesordersWebPartStrings';
|
||||
|
||||
import { Theme } from '@fluentui/react-components';
|
||||
import { IReadonlyTheme } from '@microsoft/sp-component-base';
|
||||
import { Version } from '@microsoft/sp-core-library';
|
||||
import {
|
||||
type IPropertyPaneConfiguration,
|
||||
PropertyPaneTextField,
|
||||
} from '@microsoft/sp-property-pane';
|
||||
import { BaseClientSideWebPart } from '@microsoft/sp-webpart-base';
|
||||
|
||||
import { ISalesordersProps } from '../../components/ISalesordersProps';
|
||||
import { Salesorders } from '../../components/Salesorders';
|
||||
import { EAppHostName } from '../../constants/EAppHostname';
|
||||
|
||||
export interface ISalesordersWebPartProps {
|
||||
title: string;
|
||||
}
|
||||
|
||||
export default class SalesordersWebPart extends BaseClientSideWebPart<ISalesordersWebPartProps> {
|
||||
|
||||
private _isDarkTheme: boolean = false;
|
||||
private _theme: Theme | undefined;
|
||||
private _themeString: string = "";
|
||||
private _appHostName: EAppHostName = EAppHostName.SharePoint;
|
||||
|
||||
private _applyTheme = (theme: string): void => {
|
||||
this.context.domElement.setAttribute("data-theme", theme);
|
||||
document.body.setAttribute("data-theme", theme);
|
||||
if (theme === "dark") {
|
||||
this._themeString = "dark";
|
||||
}
|
||||
if (theme === "default") {
|
||||
this._themeString = "default";
|
||||
}
|
||||
|
||||
if (theme === "contrast") {
|
||||
this._themeString = "contrast";
|
||||
}
|
||||
this.render();
|
||||
};
|
||||
|
||||
protected get disableReactivePropertyChanges(): boolean {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public render(): void {
|
||||
const element: React.ReactElement<ISalesordersProps> = React.createElement(
|
||||
Salesorders,
|
||||
{
|
||||
isDarkTheme: this._isDarkTheme,
|
||||
theme: this._theme,
|
||||
themeString: this._themeString,
|
||||
hasTeamsContext: !!this.context.sdks.microsoftTeams,
|
||||
title: this.properties.title,
|
||||
context: this.context,
|
||||
appHostName: this._appHostName,
|
||||
}
|
||||
);
|
||||
|
||||
ReactDom.render(element, this.domElement);
|
||||
}
|
||||
|
||||
protected async onInit(): Promise<void> {
|
||||
if (this.context.sdks.microsoftTeams) {
|
||||
// in teams ?
|
||||
const teamsContext = await this.context.sdks.microsoftTeams?.teamsJs.app.getContext();
|
||||
switch (teamsContext.app.host.name.toLowerCase()) {
|
||||
case "teams":
|
||||
case "teamsModern":
|
||||
this._appHostName = EAppHostName.Teams;
|
||||
break;
|
||||
case "office":
|
||||
this._appHostName = EAppHostName.Office;
|
||||
break;
|
||||
case "outlook":
|
||||
this._appHostName = EAppHostName.Outlook;
|
||||
break;
|
||||
default:
|
||||
throw new Error(`[contentFlow_onInit]: Err:'Unknown app host name'`);
|
||||
}
|
||||
this._applyTheme(teamsContext.app.theme || "default");
|
||||
this.context.sdks.microsoftTeams.teamsJs.app.registerOnThemeChangeHandler(this._applyTheme);
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
protected onThemeChanged(currentTheme: IReadonlyTheme | undefined): void {
|
||||
if (!currentTheme) {
|
||||
return;
|
||||
}
|
||||
this._theme = currentTheme as Theme;
|
||||
this._isDarkTheme = !!currentTheme.isInverted;
|
||||
}
|
||||
|
||||
|
||||
protected onDispose(): void {
|
||||
ReactDom.unmountComponentAtNode(this.domElement);
|
||||
}
|
||||
|
||||
protected get dataVersion(): Version {
|
||||
return Version.parse('1.0');
|
||||
}
|
||||
|
||||
protected getPropertyPaneConfiguration(): IPropertyPaneConfiguration {
|
||||
return {
|
||||
pages: [
|
||||
{
|
||||
header: {
|
||||
description: strings.PropertyPaneDescription
|
||||
},
|
||||
groups: [
|
||||
{
|
||||
groupName: strings.BasicGroupName,
|
||||
groupFields: [
|
||||
PropertyPaneTextField('title', {
|
||||
label: strings.DescriptionFieldLabel
|
||||
})
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
define([], function() {
|
||||
return {
|
||||
"PropertyPaneDescription": "Description",
|
||||
"BasicGroupName": "Group Name",
|
||||
"DescriptionFieldLabel": "Description Field",
|
||||
"AppLocalEnvironmentSharePoint": "The app is running on your local environment as SharePoint web part",
|
||||
"AppLocalEnvironmentTeams": "The app is running on your local environment as Microsoft Teams app",
|
||||
"AppLocalEnvironmentOffice": "The app is running on your local environment in office.com",
|
||||
"AppLocalEnvironmentOutlook": "The app is running on your local environment in Outlook",
|
||||
"AppSharePointEnvironment": "The app is running on SharePoint page",
|
||||
"AppTeamsTabEnvironment": "The app is running in Microsoft Teams",
|
||||
"AppOfficeEnvironment": "The app is running in office.com",
|
||||
"AppOutlookEnvironment": "The app is running in Outlook",
|
||||
"UnknownEnvironment": "The app is running in an unknown environment"
|
||||
}
|
||||
});
|
|
@ -0,0 +1,19 @@
|
|||
declare interface ISalesordersWebPartStrings {
|
||||
PropertyPaneDescription: string;
|
||||
BasicGroupName: string;
|
||||
DescriptionFieldLabel: string;
|
||||
AppLocalEnvironmentSharePoint: string;
|
||||
AppLocalEnvironmentTeams: string;
|
||||
AppLocalEnvironmentOffice: string;
|
||||
AppLocalEnvironmentOutlook: string;
|
||||
AppSharePointEnvironment: string;
|
||||
AppTeamsTabEnvironment: string;
|
||||
AppOfficeEnvironment: string;
|
||||
AppOutlookEnvironment: string;
|
||||
UnknownEnvironment: string;
|
||||
}
|
||||
|
||||
declare module 'SalesordersWebPartStrings' {
|
||||
const strings: ISalesordersWebPartStrings;
|
||||
export = strings;
|
||||
}
|
After Width: | Height: | Size: 10 KiB |
After Width: | Height: | Size: 249 B |
|
@ -0,0 +1,56 @@
|
|||
{
|
||||
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.14/MicrosoftTeams.schema.json",
|
||||
"manifestVersion": "1.14",
|
||||
"packageName": "Sales Orders",
|
||||
"id": "750d6853-1282-450a-b080-37aef954d745",
|
||||
"version": "1.0.0.0",
|
||||
"developer": {
|
||||
"name": "SPFx + Teams Dev",
|
||||
"websiteUrl": "https://products.office.com/en-us/sharepoint/collaboration",
|
||||
"privacyUrl": "https://privacy.microsoft.com/en-us/privacystatement",
|
||||
"termsOfUseUrl": "https://www.microsoft.com/en-us/servicesagreement"
|
||||
},
|
||||
"name": {
|
||||
"short": "Sales Orders"
|
||||
},
|
||||
"description": {
|
||||
"short": "Sales Orders",
|
||||
"full": "Sales Orders"
|
||||
},
|
||||
"icons": {
|
||||
"outline": "750d6853-1282-450a-b080-37aef954d745_outline.png",
|
||||
"color": "750d6853-1282-450a-b080-37aef954d745_color.png"
|
||||
},
|
||||
"accentColor": "#004578",
|
||||
"configurableTabs": [
|
||||
{
|
||||
"configurationUrl": "https://{teamSiteDomain}{teamSitePath}/_layouts/15/TeamsLogon.aspx?SPFX=true&dest={teamSitePath}/_layouts/15/teamshostedapp.aspx%3FopenPropertyPane=true%26teams%26componentId=750d6853-1282-450a-b080-37aef954d745%26forceLocale={locale}",
|
||||
"canUpdateConfiguration": true,
|
||||
"scopes": [
|
||||
"team"
|
||||
]
|
||||
}
|
||||
],
|
||||
"staticTabs": [
|
||||
{
|
||||
"entityId": "750d6853-1282-450a-b080-37aef954d745",
|
||||
"name": "Sales Orders",
|
||||
"contentUrl": "https://{teamSiteDomain}/_layouts/15/TeamsLogon.aspx?SPFX=true&dest=/_layouts/15/teamshostedapp.aspx%3Fteams%26personal%26componentId=750d6853-1282-450a-b080-37aef954d745%26forceLocale={locale}",
|
||||
"websiteUrl": "https://products.office.com/en-us/sharepoint/collaboration",
|
||||
"scopes": ["personal"]
|
||||
}
|
||||
],
|
||||
"validDomains": [
|
||||
"*.login.microsoftonline.com",
|
||||
"*.sharepoint.com",
|
||||
"*.sharepoint-df.com",
|
||||
"spoppe-a.akamaihd.net",
|
||||
"spoprod-a.akamaihd.net",
|
||||
"resourceseng.blob.core.windows.net",
|
||||
"msft.spoppe.com"
|
||||
],
|
||||
"webApplicationInfo": {
|
||||
"resource": "https://{teamSiteDomain}",
|
||||
"id": "00000003-0000-0ff1-ce00-000000000000"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
{
|
||||
"extends": "./node_modules/@microsoft/rush-stack-compiler-4.7/includes/tsconfig-web.json",
|
||||
"compilerOptions": {
|
||||
"target": "es5",
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"module": "esnext",
|
||||
"moduleResolution": "node",
|
||||
"jsx": "react",
|
||||
"declaration": true,
|
||||
"sourceMap": true,
|
||||
"experimentalDecorators": true,
|
||||
"skipLibCheck": true,
|
||||
"outDir": "lib",
|
||||
"inlineSources": false,
|
||||
"noImplicitAny": true,
|
||||
|
||||
"typeRoots": [
|
||||
"./node_modules/@types",
|
||||
"./node_modules/@microsoft"
|
||||
],
|
||||
"types": [
|
||||
"webpack-env"
|
||||
],
|
||||
"lib": [
|
||||
"es5",
|
||||
"dom",
|
||||
"es2015.collection",
|
||||
"es2015.promise"
|
||||
]
|
||||
},
|
||||
"include": [
|
||||
"src/**/*.ts",
|
||||
"src/**/*.tsx"
|
||||
]
|
||||
}
|
|
@ -0,0 +1,60 @@
|
|||
# yaml-language-server: $schema=https://aka.ms/teams-toolkit/1.0.0/yaml.schema.json
|
||||
# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file
|
||||
# Visit https://aka.ms/teamsfx-actions for details on actions
|
||||
version: 1.0.0
|
||||
|
||||
provision:
|
||||
# Creates a Teams app
|
||||
- uses: teamsApp/create
|
||||
with:
|
||||
# Teams app name
|
||||
name: salesorders-${{TEAMSFX_ENV}}
|
||||
# Write the information of created resources into environment file for
|
||||
# the specified environment variable(s).
|
||||
writeToEnvironmentFile:
|
||||
teamsAppId: TEAMS_APP_ID
|
||||
|
||||
# Validate using manifest schema
|
||||
- uses: teamsApp/validateManifest
|
||||
with:
|
||||
# Path to manifest template
|
||||
manifestPath: ./appPackage/manifest.local.json
|
||||
# Build Teams app package with latest env value
|
||||
- uses: teamsApp/zipAppPackage
|
||||
with:
|
||||
# Path to manifest template
|
||||
manifestPath: ./appPackage/manifest.local.json
|
||||
outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
|
||||
outputJsonPath: ./appPackage/build/manifest.${{TEAMSFX_ENV}}.json
|
||||
# Validate app package using validation rules
|
||||
- uses: teamsApp/validateAppPackage
|
||||
with:
|
||||
# Relative path to this file. This is the path for built zip file.
|
||||
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
|
||||
|
||||
# Apply the Teams app manifest to an existing Teams app in
|
||||
# Teams Developer Portal.
|
||||
# Will use the app id in manifest file to determine which Teams app to update.
|
||||
- uses: teamsApp/update
|
||||
with:
|
||||
# Relative path to this file. This is the path for built zip file.
|
||||
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
|
||||
|
||||
# Extend your Teams app to Outlook and the Microsoft 365 app
|
||||
- uses: teamsApp/extendToM365
|
||||
with:
|
||||
# Relative path to the build app package.
|
||||
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
|
||||
# Write the information of created resources into environment file for
|
||||
# the specified environment variable(s).
|
||||
writeToEnvironmentFile:
|
||||
titleId: M365_TITLE_ID
|
||||
appId: M365_APP_ID
|
||||
|
||||
deploy:
|
||||
# Run npm command
|
||||
- uses: cli/runNpmCommand
|
||||
name: install dependencies
|
||||
with:
|
||||
workingDirectory: src
|
||||
args: install --no-audit
|
|
@ -0,0 +1,116 @@
|
|||
# yaml-language-server: $schema=https://aka.ms/teams-toolkit/1.0.0/yaml.schema.json
|
||||
# Visit https://aka.ms/teamsfx-v5.0-guide for details on this file
|
||||
# Visit https://aka.ms/teamsfx-actions for details on actions
|
||||
version: 1.0.0
|
||||
|
||||
environmentFolderPath: ./env
|
||||
|
||||
# Triggered when 'teamsfx deploy' is executed
|
||||
deploy:
|
||||
# Run npm command
|
||||
- uses: cli/runNpmCommand
|
||||
name: install dependencies
|
||||
with:
|
||||
workingDirectory: src
|
||||
args: install
|
||||
- uses: cli/runNpxCommand
|
||||
with:
|
||||
workingDirectory: src
|
||||
args: gulp bundle --ship --no-color
|
||||
- uses: cli/runNpxCommand
|
||||
with:
|
||||
workingDirectory: src
|
||||
args: gulp package-solution --ship --no-color
|
||||
- uses: spfx/deploy
|
||||
with:
|
||||
createAppCatalogIfNotExist: false
|
||||
packageSolutionPath: ./src/config/package-solution.json
|
||||
|
||||
# Triggered when 'teamsfx provision' is executed
|
||||
provision:
|
||||
# Creates a Teams app
|
||||
- uses: teamsApp/create
|
||||
with:
|
||||
# Teams app name
|
||||
name: salesorders-${{TEAMSFX_ENV}}
|
||||
# Write the information of created resources into environment file for
|
||||
# the specified environment variable(s).
|
||||
writeToEnvironmentFile:
|
||||
teamsAppId: TEAMS_APP_ID
|
||||
|
||||
# Validate using manifest schema
|
||||
- uses: teamsApp/validateManifest
|
||||
with:
|
||||
# Path to manifest template
|
||||
manifestPath: ./appPackage/manifest.json
|
||||
# Build Teams app package with latest env value
|
||||
- uses: teamsApp/zipAppPackage
|
||||
with:
|
||||
# Path to manifest template
|
||||
manifestPath: ./appPackage/manifest.json
|
||||
outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
|
||||
outputJsonPath: ./appPackage/build/manifest.${{TEAMSFX_ENV}}.json
|
||||
# Validate app package using validation rules
|
||||
- uses: teamsApp/validateAppPackage
|
||||
with:
|
||||
# Relative path to this file. This is the path for built zip file.
|
||||
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
|
||||
# Apply the Teams app manifest to an existing Teams app in
|
||||
# Teams Developer Portal.
|
||||
# Will use the app id in manifest file to determine which Teams app to update.
|
||||
- uses: teamsApp/update
|
||||
with:
|
||||
# Relative path to this file. This is the path for built zip file.
|
||||
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
|
||||
# Extend your Teams app to Outlook and the Microsoft 365 app
|
||||
- uses: teamsApp/extendToM365
|
||||
with:
|
||||
# Relative path to the build app package.
|
||||
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
|
||||
# Write the information of created resources into environment file for
|
||||
# the specified environment variable(s).
|
||||
writeToEnvironmentFile:
|
||||
titleId: M365_TITLE_ID
|
||||
appId: M365_APP_ID
|
||||
|
||||
# Triggered when 'teamsfx publish' is executed
|
||||
publish:
|
||||
# Validate using manifest schema
|
||||
- uses: teamsApp/validateManifest
|
||||
with:
|
||||
# Path to manifest template
|
||||
manifestPath: ./appPackage/manifest.json
|
||||
# Build Teams app package with latest env value
|
||||
- uses: teamsApp/zipAppPackage
|
||||
with:
|
||||
# Path to manifest template
|
||||
manifestPath: ./appPackage/manifest.json
|
||||
outputZipPath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
|
||||
outputJsonPath: ./appPackage/build/manifest.${{TEAMSFX_ENV}}.json
|
||||
- uses: teamsApp/copyAppPackageToSPFx
|
||||
with:
|
||||
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
|
||||
spfxFolder: ./src
|
||||
# Validate app package using validation rules
|
||||
- uses: teamsApp/validateAppPackage
|
||||
with:
|
||||
# Relative path to this file. This is the path for built zip file.
|
||||
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
|
||||
# Apply the Teams app manifest to an existing Teams app in
|
||||
# Teams Developer Portal.
|
||||
# Will use the app id in manifest file to determine which Teams app to update.
|
||||
- uses: teamsApp/update
|
||||
with:
|
||||
# Relative path to this file. This is the path for built zip file.
|
||||
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
|
||||
# Publish the app to
|
||||
# Teams Admin Center (https://admin.teams.microsoft.com/policies/manage-apps)
|
||||
# for review and approval
|
||||
- uses: teamsApp/publishAppPackage
|
||||
with:
|
||||
appPackagePath: ./appPackage/build/appPackage.${{TEAMSFX_ENV}}.zip
|
||||
# Write the information of created resources into environment file for
|
||||
# the specified environment variable(s).
|
||||
writeToEnvironmentFile:
|
||||
publishedAppId: TEAMS_APP_PUBLISHED_APP_ID
|
||||
projectId: 02e1503f-0d66-4418-9b60-bdffce05db24
|