Compare commits
345 Commits
feature/cy
...
feature/IO
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
44f2287b07 | ||
|
|
8f91416623 | ||
|
|
a18dbbb6c4 | ||
|
|
57d8ca5829 | ||
|
|
4c6a2d6d63 | ||
|
|
5861d0e9b6 | ||
|
|
e36904794b | ||
|
|
1c89d12034 | ||
|
|
5e36a4ae89 | ||
|
|
f553307587 | ||
|
|
2c80c81197 | ||
|
|
9d865cf130 | ||
|
|
8e119ce0dd | ||
|
|
fe49161718 | ||
|
|
040e366335 | ||
|
|
4655663dd8 | ||
|
|
6e1fbda79b | ||
|
|
b2f616f1eb | ||
|
|
76eec7bebc | ||
|
|
aa5f405e1b | ||
|
|
ca9752d119 | ||
|
|
45b4af5225 | ||
|
|
d2d310cf57 | ||
|
|
5d1a7657a9 | ||
|
|
5cb17994cd | ||
|
|
dab78e3dc9 | ||
|
|
1232f28b3d | ||
|
|
8e8d40d4b0 | ||
|
|
7fae408454 | ||
|
|
1cdafaa2cc | ||
|
|
b9ca7ef2e3 | ||
|
|
60867ae4dc | ||
|
|
b0ddb62ac0 | ||
|
|
39a4646339 | ||
|
|
584322819f | ||
|
|
051ee347a9 | ||
|
|
acf1b387de | ||
|
|
d350515c90 | ||
|
|
121e579388 | ||
|
|
cf5ebb8130 | ||
|
|
2dabf3c811 | ||
|
|
04509fa587 | ||
|
|
56fef0f43c | ||
|
|
42702ef015 | ||
|
|
25bee3cfdf | ||
|
|
baf06fee6c | ||
|
|
a3557bbc86 | ||
|
|
3e00e7981d | ||
|
|
12fa270a1a | ||
|
|
de250b152a | ||
|
|
c45741257f | ||
|
|
3988386c79 | ||
|
|
492032c1e2 | ||
|
|
8222e56485 | ||
|
|
49a61e1564 | ||
|
|
eed18aa1c5 | ||
|
|
2de3f8b022 | ||
|
|
91476c7ad3 | ||
|
|
00eb7926f9 | ||
|
|
854ad21b20 | ||
|
|
3c3f9521f6 | ||
|
|
561bcf10d9 | ||
|
|
75d9faa05b | ||
|
|
ac72177fbb | ||
|
|
088faf152c | ||
|
|
90cba9ed24 | ||
|
|
a0702785c5 | ||
|
|
6898d609fe | ||
|
|
d70893e2ba | ||
|
|
6155b8bf24 | ||
|
|
239dc5c62d | ||
|
|
2586855f11 | ||
|
|
b3b3c4c737 | ||
|
|
abe5fadeea | ||
|
|
08e5543536 | ||
|
|
f1a10e0df4 | ||
|
|
7dc3c00628 | ||
|
|
1c5c403d65 | ||
|
|
7594f53e88 | ||
|
|
b861957342 | ||
|
|
2bf24ff5a1 | ||
|
|
6e5fcbfdbd | ||
|
|
759a8ac58c | ||
|
|
833baca9cc | ||
|
|
889ef61185 | ||
|
|
add1eddbc1 | ||
|
|
1c63aa39c4 | ||
|
|
0cabd80b94 | ||
|
|
7f756bab88 | ||
|
|
99b847822f | ||
|
|
f66d9b8c09 | ||
|
|
5660de42af | ||
|
|
ccbe92c275 | ||
|
|
b0ea8a71fb | ||
|
|
060871306f | ||
|
|
2eb4e142ff | ||
|
|
adf8cf9e8d | ||
|
|
852fd9c388 | ||
|
|
e921f28105 | ||
|
|
6db68b76db | ||
|
|
51ebfd86e7 | ||
|
|
79a90bb9ee | ||
|
|
1664f9c935 | ||
|
|
23fcdd6375 | ||
|
|
ea7c22daec | ||
|
|
10ffb33ec9 | ||
|
|
f9e023f922 | ||
|
|
c7832bdd82 | ||
|
|
329bdbe22d | ||
|
|
2df046c39d | ||
|
|
46065f1986 | ||
|
|
66b3fb6988 | ||
|
|
5eda224393 | ||
|
|
e387abcd14 | ||
|
|
4c2d4e20a6 | ||
|
|
3d26c2e94e | ||
|
|
d9e2ef9300 | ||
|
|
b00fdadc1b | ||
|
|
4d5e06b9fc | ||
|
|
ad42dd1295 | ||
|
|
1f4c1c9e92 | ||
|
|
2938b9c94c | ||
|
|
2227acab3a | ||
|
|
bde17446ad | ||
|
|
081165b6f5 | ||
|
|
7e717c0b1f | ||
|
|
e242aaa9f5 | ||
|
|
fe60538acf | ||
|
|
2db88f57df | ||
|
|
7461e58000 | ||
|
|
cd0b7a4e56 | ||
|
|
2a3b4e89ab | ||
|
|
1d77eda3e2 | ||
|
|
490e1f696a | ||
|
|
b96c618f54 | ||
|
|
1afda01d34 | ||
|
|
b9d11580d4 | ||
|
|
27fadb9ae2 | ||
|
|
4c5a2cefe9 | ||
|
|
175692559c | ||
|
|
57b27f73c3 | ||
|
|
7badb09ba1 | ||
|
|
c39f1d824a | ||
|
|
132cf98a37 | ||
|
|
59f71d53cd | ||
|
|
f4b3a990d7 | ||
|
|
20371ea00d | ||
|
|
3086a654a1 | ||
|
|
60768c8847 | ||
|
|
a68f8d6880 | ||
|
|
0cad64ff6d | ||
|
|
522665256e | ||
|
|
d3fe2c9d06 | ||
|
|
f080e84985 | ||
|
|
2a0ad46eea | ||
|
|
3a83160b33 | ||
|
|
7725080a11 | ||
|
|
701c532e48 | ||
|
|
1932795f55 | ||
|
|
cc7bd1c792 | ||
|
|
7799d93f3d | ||
|
|
a7cf36d5f8 | ||
|
|
54cc02068c | ||
|
|
f575870685 | ||
|
|
171b61b92f | ||
|
|
de44116940 | ||
|
|
3c0a883326 | ||
|
|
14d6cc94dd | ||
|
|
c0d9bacf1d | ||
|
|
d787821345 | ||
|
|
ed6eab4c38 | ||
|
|
b12c9407d9 | ||
|
|
300aee5b02 | ||
|
|
357f40bdc2 | ||
|
|
0a93551db4 | ||
|
|
8602ccbb8a | ||
|
|
d7b0e3046b | ||
|
|
30689a8ca6 | ||
|
|
0e06b449cb | ||
|
|
8e8208dd9a | ||
|
|
79e2fecb24 | ||
|
|
86e909e4e9 | ||
|
|
c7ff893397 | ||
|
|
3981b8684c | ||
|
|
1fb856f95f | ||
|
|
c62c3fa938 | ||
|
|
554ec37ace | ||
|
|
be4feca990 | ||
|
|
ec45454b3d | ||
|
|
0e78cb47f9 | ||
|
|
e5b8d003ec | ||
|
|
2eb81dde37 | ||
|
|
614549a545 | ||
|
|
5717727d2a | ||
|
|
f3714cea1e | ||
|
|
a3375e6152 | ||
|
|
f48fb7130e | ||
|
|
1460fa6fd7 | ||
|
|
3d9a07bd39 | ||
|
|
bd4aa4027a | ||
|
|
9fa995f002 | ||
|
|
3ed48b26f1 | ||
|
|
d585cacdfc | ||
|
|
55ddaca328 | ||
|
|
3fc7af9780 | ||
|
|
146bf95e51 | ||
|
|
58defad2ea | ||
|
|
9c40a03a06 | ||
|
|
a1b6ccc23d | ||
|
|
9b4247d6f6 | ||
|
|
8a6d94f193 | ||
|
|
6e7d1abd70 | ||
|
|
6bd74aae87 | ||
|
|
f21caa10fc | ||
|
|
3d164eb070 | ||
|
|
88ab3a21e2 | ||
|
|
dde6f17029 | ||
|
|
45bc1893a0 | ||
|
|
1aceef9153 | ||
|
|
d053e682d7 | ||
|
|
984a4a4cf6 | ||
|
|
678892d134 | ||
|
|
9438ef9683 | ||
|
|
dc187bbf24 | ||
|
|
10a354e479 | ||
|
|
31092c20a9 | ||
|
|
09aae78715 | ||
|
|
86beaf049c | ||
|
|
3bc0653230 | ||
|
|
b950b3f825 | ||
|
|
3891fbefdf | ||
|
|
73bcc72fc3 | ||
|
|
f3911859c7 | ||
|
|
12e3d61cfb | ||
|
|
c42276ab3a | ||
|
|
4cba91e097 | ||
|
|
c695aea12e | ||
|
|
111f554dea | ||
|
|
fe2a731b5f | ||
|
|
61e6511547 | ||
|
|
85346e203b | ||
|
|
41d25cbc52 | ||
|
|
c565e2199d | ||
|
|
085c27ad20 | ||
|
|
8fa0946cfa | ||
|
|
a1ab254d6f | ||
|
|
38e6b5010e | ||
|
|
99d3943955 | ||
|
|
2415b4c2b4 | ||
|
|
99c7ba1fbc | ||
|
|
36e593f806 | ||
|
|
d825c04850 | ||
|
|
ca7dfacec4 | ||
|
|
1138540518 | ||
|
|
242c275e7d | ||
|
|
59db305cb8 | ||
|
|
fea69fe3a5 | ||
|
|
43e4ff911e | ||
|
|
1dc6130fdf | ||
|
|
ae4cff98e7 | ||
|
|
3650cacb51 | ||
|
|
c2bf6841e1 | ||
|
|
910afbf48d | ||
|
|
f41b94d16d | ||
|
|
24da0207e5 | ||
|
|
bf34765e6b | ||
|
|
4c98a347f5 | ||
|
|
840e760619 | ||
|
|
9d9edfd674 | ||
|
|
739265ee6a | ||
|
|
62a5b49836 | ||
|
|
038aaf249e | ||
|
|
e0eb4657d2 | ||
|
|
02a6ccd481 | ||
|
|
79e75a5e73 | ||
|
|
e93e138f78 | ||
|
|
8d22248f4b | ||
|
|
bb8024ba9c | ||
|
|
4639e31e55 | ||
|
|
a960963e36 | ||
|
|
e8fde14f9b | ||
|
|
3be50b5067 | ||
|
|
90e87adc34 | ||
|
|
563c1d2402 | ||
|
|
81053b3cbf | ||
|
|
2108a4e96c | ||
|
|
f4290bf20c | ||
|
|
c04a690dc3 | ||
|
|
5371657aa4 | ||
|
|
20e84668a5 | ||
|
|
599f4e143c | ||
|
|
2e40583d31 | ||
|
|
07c307e17b | ||
|
|
94440e5c48 | ||
|
|
176774a888 | ||
|
|
aa5d6f2090 | ||
|
|
7b3dcf295e | ||
|
|
6bde1b1baf | ||
|
|
380dbd8b96 | ||
|
|
a34c2a5bc2 | ||
|
|
d8ba40979e | ||
|
|
5cd0527e16 | ||
|
|
25513ae5b5 | ||
|
|
d89acbd49d | ||
|
|
a54862a309 | ||
|
|
423157dfcc | ||
|
|
6607c80aca | ||
|
|
162aeca7c8 | ||
|
|
1583ed2d61 | ||
|
|
c78b13baa3 | ||
|
|
fc404b1f3b | ||
|
|
6528a0c700 | ||
|
|
79f032ecaf | ||
|
|
42b4534d21 | ||
|
|
32de0ddeb6 | ||
|
|
c6ba3fd8f0 | ||
|
|
76025b5db1 | ||
|
|
ea27fcd476 | ||
|
|
968816b4a6 | ||
|
|
9de076f060 | ||
|
|
08d334e93a | ||
|
|
119904ca2b | ||
|
|
af009a0bb3 | ||
|
|
f7e1b023df | ||
|
|
f8e74d9bad | ||
|
|
f6bf1ce793 | ||
|
|
9413bc60cf | ||
|
|
34f5fad365 | ||
|
|
d69ce2d2a9 | ||
|
|
5855569194 | ||
|
|
b0755a0cde | ||
|
|
4f852e7493 | ||
|
|
a551258895 | ||
|
|
deec40a89c | ||
|
|
145dd9bec6 | ||
|
|
b8e5d4412f | ||
|
|
277fb8f839 | ||
|
|
d3d5485846 | ||
|
|
55091d61d6 | ||
|
|
5b5df8a3a1 | ||
|
|
ccf48cfcf1 | ||
|
|
c89342b6ef | ||
|
|
e97ceb7cbe | ||
|
|
de34cbd937 | ||
|
|
cf7a1b0168 |
13
README.MD
13
README.MD
@@ -1,14 +1,3 @@
|
|||||||
Yarn Dependency Management:
|
|
||||||
To force upgrades for some packages:
|
|
||||||
yarn upgrade-interactive --latest
|
|
||||||
|
|
||||||
To Start Hasura CLI:
|
|
||||||
npx hasura console
|
|
||||||
|
|
||||||
Migrating to Staging:
|
|
||||||
npx hasura migrate apply --endpoint https://db.imex.online/ --admin-secret 'Production-ImEXOnline!@#'
|
|
||||||
npx hasura migrate apply --endpoint https://db.test.bodyshop.app/ --admin-secret 'Test-ImEXOnlineBySnaptSoftware!'
|
|
||||||
|
|
||||||
NGROK TEsting:
|
NGROK TEsting:
|
||||||
./ngrok.exe http http://localhost:4000 -host-header="localhost:4000"
|
./ngrok.exe http http://localhost:4000 -host-header="localhost:4000"
|
||||||
|
|
||||||
@@ -21,4 +10,4 @@ hasura migrate apply --version "1620771761757" --skip-execution --endpoint https
|
|||||||
hasura migrate status --endpoint https://db.imex.online/ --admin-secret 'Production-ImEXOnline!@#'
|
hasura migrate status --endpoint https://db.imex.online/ --admin-secret 'Production-ImEXOnline!@#'
|
||||||
|
|
||||||
Generate the license file:
|
Generate the license file:
|
||||||
$ generate-license-file --input package.json --output third-party-licenses.txt --overwrite
|
$ generate-license-file --input package.json --output third-party-licenses.txt --overwrite
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -8,6 +8,6 @@ REACT_APP_CLOUDINARY_API_KEY=957865933348715
|
|||||||
REACT_APP_CLOUDINARY_THUMB_TRANSFORMATIONS=c_fill,h_250,w_250
|
REACT_APP_CLOUDINARY_THUMB_TRANSFORMATIONS=c_fill,h_250,w_250
|
||||||
REACT_APP_FIREBASE_PUBLIC_VAPID_KEY='BG3tzU7L2BXlGZ_3VLK4PNaRceoEXEnmHfxcVbRMF5o5g05ejslhVPki9kBM9cBBT-08Ad9kN3HSpS6JmrWD6h4'
|
REACT_APP_FIREBASE_PUBLIC_VAPID_KEY='BG3tzU7L2BXlGZ_3VLK4PNaRceoEXEnmHfxcVbRMF5o5g05ejslhVPki9kBM9cBBT-08Ad9kN3HSpS6JmrWD6h4'
|
||||||
REACT_APP_STRIPE_PUBLIC_KEY=pk_test_51GqB4TJl3nQjrZ0wCQWAxAhlNF8jKe0tipIa6ExBaxwJGitwvFsIZUEua4dUzaMIAuXp4qwYHXx7lgjyQSwP0Pe900vzm38C7g
|
REACT_APP_STRIPE_PUBLIC_KEY=pk_test_51GqB4TJl3nQjrZ0wCQWAxAhlNF8jKe0tipIa6ExBaxwJGitwvFsIZUEua4dUzaMIAuXp4qwYHXx7lgjyQSwP0Pe900vzm38C7g
|
||||||
REACT_APP_AXIOS_BASE_API_URL=https://api.imex.online/
|
REACT_APP_AXIOS_BASE_API_URL=http://localhost:4000
|
||||||
REACT_APP_REPORTS_SERVER_URL=https://reports3.test.imex.online
|
REACT_APP_REPORTS_SERVER_URL=https://reports3.test.imex.online
|
||||||
REACT_APP_SPLIT_API=ts615lqgnmk84thn72uk18uu5pgce6e0l4rc
|
REACT_APP_SPLIT_API=ts615lqgnmk84thn72uk18uu5pgce6e0l4rc
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
GENERATE_SOURCEMAP=false
|
||||||
REACT_APP_GRAPHQL_ENDPOINT=https://db.imex.online/v1/graphql
|
REACT_APP_GRAPHQL_ENDPOINT=https://db.imex.online/v1/graphql
|
||||||
REACT_APP_GRAPHQL_ENDPOINT_WS=wss://db.imex.online/v1/graphql
|
REACT_APP_GRAPHQL_ENDPOINT_WS=wss://db.imex.online/v1/graphql
|
||||||
REACT_APP_GA_CODE=231103507
|
REACT_APP_GA_CODE=231103507
|
||||||
|
|||||||
@@ -1,9 +0,0 @@
|
|||||||
const { defineConfig } = require("cypress");
|
|
||||||
|
|
||||||
module.exports = defineConfig({
|
|
||||||
e2e: {
|
|
||||||
setupNodeEvents(on, config) {
|
|
||||||
// implement node event listeners here
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
||||||
8
client/cypress.json
Normal file
8
client/cypress.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"baseUrl": "http://localhost:3000",
|
||||||
|
"experimentalStudio": true,
|
||||||
|
"env": {
|
||||||
|
"FIREBASE_USERNAME": "cypress@imex.test",
|
||||||
|
"FIREBASE_PASSWORD": "cypress"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
/// <reference types="cypress" />
|
|
||||||
|
|
||||||
context("Actions", () => {
|
|
||||||
beforeEach(() => {});
|
|
||||||
|
|
||||||
// https://on.cypress.io/interacting-with-elements
|
|
||||||
|
|
||||||
it("Attempt a failed login.", () => {
|
|
||||||
cy.visit("http://localhost:3000");
|
|
||||||
cy.get(".ant-btn").contains("Sign In").click();
|
|
||||||
cy.get("#email").type("fake@email.com");
|
|
||||||
cy.get("#password").type("fakepassword");
|
|
||||||
cy.get(".ant-btn").contains("Login").click();
|
|
||||||
cy.should("have.text", "user");
|
|
||||||
});
|
|
||||||
|
|
||||||
it("Attempt a failed login.", () => {});
|
|
||||||
});
|
|
||||||
5
client/cypress/fixtures/profile.json
Normal file
5
client/cypress/fixtures/profile.json
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"id": 8739,
|
||||||
|
"name": "Jane",
|
||||||
|
"email": "jane@example.com"
|
||||||
|
}
|
||||||
1
client/cypress/fixtures/users.json
Normal file
1
client/cypress/fixtures/users.json
Normal file
@@ -0,0 +1 @@
|
|||||||
|
[]
|
||||||
23
client/cypress/integration/01-General Render/01-home.spec.js
Normal file
23
client/cypress/integration/01-General Render/01-home.spec.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
/// <reference types="Cypress" />
|
||||||
|
const { FIREBASE_USERNAME, FIREBASE_PASSWORcD } = Cypress.env();
|
||||||
|
describe("Renders the General Page", () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit("/");
|
||||||
|
});
|
||||||
|
it("Renders Correctly", () => {});
|
||||||
|
it("Has the Slogan", () => {
|
||||||
|
cy.findByText("A whole x22new kind of shop management system.").should(
|
||||||
|
"exist"
|
||||||
|
);
|
||||||
|
/* ==== Generated with Cypress Studio ==== */
|
||||||
|
cy.get(
|
||||||
|
".ant-menu-item-active > .ant-menu-title-content > .header0-item-block"
|
||||||
|
).click();
|
||||||
|
cy.get("#email").clear();
|
||||||
|
cy.get("#email").type("patrick@imex.dev");
|
||||||
|
cy.get("#password").clear();
|
||||||
|
cy.get("#password").type("patrick123{enter}");
|
||||||
|
cy.get(".ant-form > .ant-btn").click();
|
||||||
|
/* ==== End Cypress Studio ==== */
|
||||||
|
});
|
||||||
|
});
|
||||||
143
client/cypress/integration/1-getting-started/todo.spec.js
Normal file
143
client/cypress/integration/1-getting-started/todo.spec.js
Normal file
@@ -0,0 +1,143 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
// Welcome to Cypress!
|
||||||
|
//
|
||||||
|
// This spec file contains a variety of sample tests
|
||||||
|
// for a todo list app that are designed to demonstrate
|
||||||
|
// the power of writing tests in Cypress.
|
||||||
|
//
|
||||||
|
// To learn more about how Cypress works and
|
||||||
|
// what makes it such an awesome testing tool,
|
||||||
|
// please read our getting started guide:
|
||||||
|
// https://on.cypress.io/introduction-to-cypress
|
||||||
|
|
||||||
|
describe('example to-do app', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// Cypress starts out with a blank slate for each test
|
||||||
|
// so we must tell it to visit our website with the `cy.visit()` command.
|
||||||
|
// Since we want to visit the same URL at the start of all our tests,
|
||||||
|
// we include it in our beforeEach function so that it runs before each test
|
||||||
|
cy.visit('https://example.cypress.io/todo')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('displays two todo items by default', () => {
|
||||||
|
// We use the `cy.get()` command to get all elements that match the selector.
|
||||||
|
// Then, we use `should` to assert that there are two matched items,
|
||||||
|
// which are the two default items.
|
||||||
|
cy.get('.todo-list li').should('have.length', 2)
|
||||||
|
|
||||||
|
// We can go even further and check that the default todos each contain
|
||||||
|
// the correct text. We use the `first` and `last` functions
|
||||||
|
// to get just the first and last matched elements individually,
|
||||||
|
// and then perform an assertion with `should`.
|
||||||
|
cy.get('.todo-list li').first().should('have.text', 'Pay electric bill')
|
||||||
|
cy.get('.todo-list li').last().should('have.text', 'Walk the dog')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can add new todo items', () => {
|
||||||
|
// We'll store our item text in a variable so we can reuse it
|
||||||
|
const newItem = 'Feed the cat'
|
||||||
|
|
||||||
|
// Let's get the input element and use the `type` command to
|
||||||
|
// input our new list item. After typing the content of our item,
|
||||||
|
// we need to type the enter key as well in order to submit the input.
|
||||||
|
// This input has a data-test attribute so we'll use that to select the
|
||||||
|
// element in accordance with best practices:
|
||||||
|
// https://on.cypress.io/selecting-elements
|
||||||
|
cy.get('[data-test=new-todo]').type(`${newItem}{enter}`)
|
||||||
|
|
||||||
|
// Now that we've typed our new item, let's check that it actually was added to the list.
|
||||||
|
// Since it's the newest item, it should exist as the last element in the list.
|
||||||
|
// In addition, with the two default items, we should have a total of 3 elements in the list.
|
||||||
|
// Since assertions yield the element that was asserted on,
|
||||||
|
// we can chain both of these assertions together into a single statement.
|
||||||
|
cy.get('.todo-list li')
|
||||||
|
.should('have.length', 3)
|
||||||
|
.last()
|
||||||
|
.should('have.text', newItem)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can check off an item as completed', () => {
|
||||||
|
// In addition to using the `get` command to get an element by selector,
|
||||||
|
// we can also use the `contains` command to get an element by its contents.
|
||||||
|
// However, this will yield the <label>, which is lowest-level element that contains the text.
|
||||||
|
// In order to check the item, we'll find the <input> element for this <label>
|
||||||
|
// by traversing up the dom to the parent element. From there, we can `find`
|
||||||
|
// the child checkbox <input> element and use the `check` command to check it.
|
||||||
|
cy.contains('Pay electric bill')
|
||||||
|
.parent()
|
||||||
|
.find('input[type=checkbox]')
|
||||||
|
.check()
|
||||||
|
|
||||||
|
// Now that we've checked the button, we can go ahead and make sure
|
||||||
|
// that the list element is now marked as completed.
|
||||||
|
// Again we'll use `contains` to find the <label> element and then use the `parents` command
|
||||||
|
// to traverse multiple levels up the dom until we find the corresponding <li> element.
|
||||||
|
// Once we get that element, we can assert that it has the completed class.
|
||||||
|
cy.contains('Pay electric bill')
|
||||||
|
.parents('li')
|
||||||
|
.should('have.class', 'completed')
|
||||||
|
})
|
||||||
|
|
||||||
|
context('with a checked task', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
// We'll take the command we used above to check off an element
|
||||||
|
// Since we want to perform multiple tests that start with checking
|
||||||
|
// one element, we put it in the beforeEach hook
|
||||||
|
// so that it runs at the start of every test.
|
||||||
|
cy.contains('Pay electric bill')
|
||||||
|
.parent()
|
||||||
|
.find('input[type=checkbox]')
|
||||||
|
.check()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can filter for uncompleted tasks', () => {
|
||||||
|
// We'll click on the "active" button in order to
|
||||||
|
// display only incomplete items
|
||||||
|
cy.contains('Active').click()
|
||||||
|
|
||||||
|
// After filtering, we can assert that there is only the one
|
||||||
|
// incomplete item in the list.
|
||||||
|
cy.get('.todo-list li')
|
||||||
|
.should('have.length', 1)
|
||||||
|
.first()
|
||||||
|
.should('have.text', 'Walk the dog')
|
||||||
|
|
||||||
|
// For good measure, let's also assert that the task we checked off
|
||||||
|
// does not exist on the page.
|
||||||
|
cy.contains('Pay electric bill').should('not.exist')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can filter for completed tasks', () => {
|
||||||
|
// We can perform similar steps as the test above to ensure
|
||||||
|
// that only completed tasks are shown
|
||||||
|
cy.contains('Completed').click()
|
||||||
|
|
||||||
|
cy.get('.todo-list li')
|
||||||
|
.should('have.length', 1)
|
||||||
|
.first()
|
||||||
|
.should('have.text', 'Pay electric bill')
|
||||||
|
|
||||||
|
cy.contains('Walk the dog').should('not.exist')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can delete all completed tasks', () => {
|
||||||
|
// First, let's click the "Clear completed" button
|
||||||
|
// `contains` is actually serving two purposes here.
|
||||||
|
// First, it's ensuring that the button exists within the dom.
|
||||||
|
// This button only appears when at least one task is checked
|
||||||
|
// so this command is implicitly verifying that it does exist.
|
||||||
|
// Second, it selects the button so we can click it.
|
||||||
|
cy.contains('Clear completed').click()
|
||||||
|
|
||||||
|
// Then we can make sure that there is only one element
|
||||||
|
// in the list and our element does not exist
|
||||||
|
cy.get('.todo-list li')
|
||||||
|
.should('have.length', 1)
|
||||||
|
.should('not.have.text', 'Pay electric bill')
|
||||||
|
|
||||||
|
// Finally, make sure that the clear button no longer exists.
|
||||||
|
cy.contains('Clear completed').should('not.exist')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
299
client/cypress/integration/2-advanced-examples/actions.spec.js
Normal file
299
client/cypress/integration/2-advanced-examples/actions.spec.js
Normal file
@@ -0,0 +1,299 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
context('Actions', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/commands/actions')
|
||||||
|
})
|
||||||
|
|
||||||
|
// https://on.cypress.io/interacting-with-elements
|
||||||
|
|
||||||
|
it('.type() - type into a DOM element', () => {
|
||||||
|
// https://on.cypress.io/type
|
||||||
|
cy.get('.action-email')
|
||||||
|
.type('fake@email.com').should('have.value', 'fake@email.com')
|
||||||
|
|
||||||
|
// .type() with special character sequences
|
||||||
|
.type('{leftarrow}{rightarrow}{uparrow}{downarrow}')
|
||||||
|
.type('{del}{selectall}{backspace}')
|
||||||
|
|
||||||
|
// .type() with key modifiers
|
||||||
|
.type('{alt}{option}') //these are equivalent
|
||||||
|
.type('{ctrl}{control}') //these are equivalent
|
||||||
|
.type('{meta}{command}{cmd}') //these are equivalent
|
||||||
|
.type('{shift}')
|
||||||
|
|
||||||
|
// Delay each keypress by 0.1 sec
|
||||||
|
.type('slow.typing@email.com', { delay: 100 })
|
||||||
|
.should('have.value', 'slow.typing@email.com')
|
||||||
|
|
||||||
|
cy.get('.action-disabled')
|
||||||
|
// Ignore error checking prior to type
|
||||||
|
// like whether the input is visible or disabled
|
||||||
|
.type('disabled error checking', { force: true })
|
||||||
|
.should('have.value', 'disabled error checking')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.focus() - focus on a DOM element', () => {
|
||||||
|
// https://on.cypress.io/focus
|
||||||
|
cy.get('.action-focus').focus()
|
||||||
|
.should('have.class', 'focus')
|
||||||
|
.prev().should('have.attr', 'style', 'color: orange;')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.blur() - blur off a DOM element', () => {
|
||||||
|
// https://on.cypress.io/blur
|
||||||
|
cy.get('.action-blur').type('About to blur').blur()
|
||||||
|
.should('have.class', 'error')
|
||||||
|
.prev().should('have.attr', 'style', 'color: red;')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.clear() - clears an input or textarea element', () => {
|
||||||
|
// https://on.cypress.io/clear
|
||||||
|
cy.get('.action-clear').type('Clear this text')
|
||||||
|
.should('have.value', 'Clear this text')
|
||||||
|
.clear()
|
||||||
|
.should('have.value', '')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.submit() - submit a form', () => {
|
||||||
|
// https://on.cypress.io/submit
|
||||||
|
cy.get('.action-form')
|
||||||
|
.find('[type="text"]').type('HALFOFF')
|
||||||
|
|
||||||
|
cy.get('.action-form').submit()
|
||||||
|
.next().should('contain', 'Your form has been submitted!')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.click() - click on a DOM element', () => {
|
||||||
|
// https://on.cypress.io/click
|
||||||
|
cy.get('.action-btn').click()
|
||||||
|
|
||||||
|
// You can click on 9 specific positions of an element:
|
||||||
|
// -----------------------------------
|
||||||
|
// | topLeft top topRight |
|
||||||
|
// | |
|
||||||
|
// | |
|
||||||
|
// | |
|
||||||
|
// | left center right |
|
||||||
|
// | |
|
||||||
|
// | |
|
||||||
|
// | |
|
||||||
|
// | bottomLeft bottom bottomRight |
|
||||||
|
// -----------------------------------
|
||||||
|
|
||||||
|
// clicking in the center of the element is the default
|
||||||
|
cy.get('#action-canvas').click()
|
||||||
|
|
||||||
|
cy.get('#action-canvas').click('topLeft')
|
||||||
|
cy.get('#action-canvas').click('top')
|
||||||
|
cy.get('#action-canvas').click('topRight')
|
||||||
|
cy.get('#action-canvas').click('left')
|
||||||
|
cy.get('#action-canvas').click('right')
|
||||||
|
cy.get('#action-canvas').click('bottomLeft')
|
||||||
|
cy.get('#action-canvas').click('bottom')
|
||||||
|
cy.get('#action-canvas').click('bottomRight')
|
||||||
|
|
||||||
|
// .click() accepts an x and y coordinate
|
||||||
|
// that controls where the click occurs :)
|
||||||
|
|
||||||
|
cy.get('#action-canvas')
|
||||||
|
.click(80, 75) // click 80px on x coord and 75px on y coord
|
||||||
|
.click(170, 75)
|
||||||
|
.click(80, 165)
|
||||||
|
.click(100, 185)
|
||||||
|
.click(125, 190)
|
||||||
|
.click(150, 185)
|
||||||
|
.click(170, 165)
|
||||||
|
|
||||||
|
// click multiple elements by passing multiple: true
|
||||||
|
cy.get('.action-labels>.label').click({ multiple: true })
|
||||||
|
|
||||||
|
// Ignore error checking prior to clicking
|
||||||
|
cy.get('.action-opacity>.btn').click({ force: true })
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.dblclick() - double click on a DOM element', () => {
|
||||||
|
// https://on.cypress.io/dblclick
|
||||||
|
|
||||||
|
// Our app has a listener on 'dblclick' event in our 'scripts.js'
|
||||||
|
// that hides the div and shows an input on double click
|
||||||
|
cy.get('.action-div').dblclick().should('not.be.visible')
|
||||||
|
cy.get('.action-input-hidden').should('be.visible')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.rightclick() - right click on a DOM element', () => {
|
||||||
|
// https://on.cypress.io/rightclick
|
||||||
|
|
||||||
|
// Our app has a listener on 'contextmenu' event in our 'scripts.js'
|
||||||
|
// that hides the div and shows an input on right click
|
||||||
|
cy.get('.rightclick-action-div').rightclick().should('not.be.visible')
|
||||||
|
cy.get('.rightclick-action-input-hidden').should('be.visible')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.check() - check a checkbox or radio element', () => {
|
||||||
|
// https://on.cypress.io/check
|
||||||
|
|
||||||
|
// By default, .check() will check all
|
||||||
|
// matching checkbox or radio elements in succession, one after another
|
||||||
|
cy.get('.action-checkboxes [type="checkbox"]').not('[disabled]')
|
||||||
|
.check().should('be.checked')
|
||||||
|
|
||||||
|
cy.get('.action-radios [type="radio"]').not('[disabled]')
|
||||||
|
.check().should('be.checked')
|
||||||
|
|
||||||
|
// .check() accepts a value argument
|
||||||
|
cy.get('.action-radios [type="radio"]')
|
||||||
|
.check('radio1').should('be.checked')
|
||||||
|
|
||||||
|
// .check() accepts an array of values
|
||||||
|
cy.get('.action-multiple-checkboxes [type="checkbox"]')
|
||||||
|
.check(['checkbox1', 'checkbox2']).should('be.checked')
|
||||||
|
|
||||||
|
// Ignore error checking prior to checking
|
||||||
|
cy.get('.action-checkboxes [disabled]')
|
||||||
|
.check({ force: true }).should('be.checked')
|
||||||
|
|
||||||
|
cy.get('.action-radios [type="radio"]')
|
||||||
|
.check('radio3', { force: true }).should('be.checked')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.uncheck() - uncheck a checkbox element', () => {
|
||||||
|
// https://on.cypress.io/uncheck
|
||||||
|
|
||||||
|
// By default, .uncheck() will uncheck all matching
|
||||||
|
// checkbox elements in succession, one after another
|
||||||
|
cy.get('.action-check [type="checkbox"]')
|
||||||
|
.not('[disabled]')
|
||||||
|
.uncheck().should('not.be.checked')
|
||||||
|
|
||||||
|
// .uncheck() accepts a value argument
|
||||||
|
cy.get('.action-check [type="checkbox"]')
|
||||||
|
.check('checkbox1')
|
||||||
|
.uncheck('checkbox1').should('not.be.checked')
|
||||||
|
|
||||||
|
// .uncheck() accepts an array of values
|
||||||
|
cy.get('.action-check [type="checkbox"]')
|
||||||
|
.check(['checkbox1', 'checkbox3'])
|
||||||
|
.uncheck(['checkbox1', 'checkbox3']).should('not.be.checked')
|
||||||
|
|
||||||
|
// Ignore error checking prior to unchecking
|
||||||
|
cy.get('.action-check [disabled]')
|
||||||
|
.uncheck({ force: true }).should('not.be.checked')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.select() - select an option in a <select> element', () => {
|
||||||
|
// https://on.cypress.io/select
|
||||||
|
|
||||||
|
// at first, no option should be selected
|
||||||
|
cy.get('.action-select')
|
||||||
|
.should('have.value', '--Select a fruit--')
|
||||||
|
|
||||||
|
// Select option(s) with matching text content
|
||||||
|
cy.get('.action-select').select('apples')
|
||||||
|
// confirm the apples were selected
|
||||||
|
// note that each value starts with "fr-" in our HTML
|
||||||
|
cy.get('.action-select').should('have.value', 'fr-apples')
|
||||||
|
|
||||||
|
cy.get('.action-select-multiple')
|
||||||
|
.select(['apples', 'oranges', 'bananas'])
|
||||||
|
// when getting multiple values, invoke "val" method first
|
||||||
|
.invoke('val')
|
||||||
|
.should('deep.equal', ['fr-apples', 'fr-oranges', 'fr-bananas'])
|
||||||
|
|
||||||
|
// Select option(s) with matching value
|
||||||
|
cy.get('.action-select').select('fr-bananas')
|
||||||
|
// can attach an assertion right away to the element
|
||||||
|
.should('have.value', 'fr-bananas')
|
||||||
|
|
||||||
|
cy.get('.action-select-multiple')
|
||||||
|
.select(['fr-apples', 'fr-oranges', 'fr-bananas'])
|
||||||
|
.invoke('val')
|
||||||
|
.should('deep.equal', ['fr-apples', 'fr-oranges', 'fr-bananas'])
|
||||||
|
|
||||||
|
// assert the selected values include oranges
|
||||||
|
cy.get('.action-select-multiple')
|
||||||
|
.invoke('val').should('include', 'fr-oranges')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.scrollIntoView() - scroll an element into view', () => {
|
||||||
|
// https://on.cypress.io/scrollintoview
|
||||||
|
|
||||||
|
// normally all of these buttons are hidden,
|
||||||
|
// because they're not within
|
||||||
|
// the viewable area of their parent
|
||||||
|
// (we need to scroll to see them)
|
||||||
|
cy.get('#scroll-horizontal button')
|
||||||
|
.should('not.be.visible')
|
||||||
|
|
||||||
|
// scroll the button into view, as if the user had scrolled
|
||||||
|
cy.get('#scroll-horizontal button').scrollIntoView()
|
||||||
|
.should('be.visible')
|
||||||
|
|
||||||
|
cy.get('#scroll-vertical button')
|
||||||
|
.should('not.be.visible')
|
||||||
|
|
||||||
|
// Cypress handles the scroll direction needed
|
||||||
|
cy.get('#scroll-vertical button').scrollIntoView()
|
||||||
|
.should('be.visible')
|
||||||
|
|
||||||
|
cy.get('#scroll-both button')
|
||||||
|
.should('not.be.visible')
|
||||||
|
|
||||||
|
// Cypress knows to scroll to the right and down
|
||||||
|
cy.get('#scroll-both button').scrollIntoView()
|
||||||
|
.should('be.visible')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.trigger() - trigger an event on a DOM element', () => {
|
||||||
|
// https://on.cypress.io/trigger
|
||||||
|
|
||||||
|
// To interact with a range input (slider)
|
||||||
|
// we need to set its value & trigger the
|
||||||
|
// event to signal it changed
|
||||||
|
|
||||||
|
// Here, we invoke jQuery's val() method to set
|
||||||
|
// the value and trigger the 'change' event
|
||||||
|
cy.get('.trigger-input-range')
|
||||||
|
.invoke('val', 25)
|
||||||
|
.trigger('change')
|
||||||
|
.get('input[type=range]').siblings('p')
|
||||||
|
.should('have.text', '25')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.scrollTo() - scroll the window or element to a position', () => {
|
||||||
|
// https://on.cypress.io/scrollto
|
||||||
|
|
||||||
|
// You can scroll to 9 specific positions of an element:
|
||||||
|
// -----------------------------------
|
||||||
|
// | topLeft top topRight |
|
||||||
|
// | |
|
||||||
|
// | |
|
||||||
|
// | |
|
||||||
|
// | left center right |
|
||||||
|
// | |
|
||||||
|
// | |
|
||||||
|
// | |
|
||||||
|
// | bottomLeft bottom bottomRight |
|
||||||
|
// -----------------------------------
|
||||||
|
|
||||||
|
// if you chain .scrollTo() off of cy, we will
|
||||||
|
// scroll the entire window
|
||||||
|
cy.scrollTo('bottom')
|
||||||
|
|
||||||
|
cy.get('#scrollable-horizontal').scrollTo('right')
|
||||||
|
|
||||||
|
// or you can scroll to a specific coordinate:
|
||||||
|
// (x axis, y axis) in pixels
|
||||||
|
cy.get('#scrollable-vertical').scrollTo(250, 250)
|
||||||
|
|
||||||
|
// or you can scroll to a specific percentage
|
||||||
|
// of the (width, height) of the element
|
||||||
|
cy.get('#scrollable-both').scrollTo('75%', '25%')
|
||||||
|
|
||||||
|
// control the easing of the scroll (default is 'swing')
|
||||||
|
cy.get('#scrollable-vertical').scrollTo('center', { easing: 'linear' })
|
||||||
|
|
||||||
|
// control the duration of the scroll (in ms)
|
||||||
|
cy.get('#scrollable-both').scrollTo('center', { duration: 2000 })
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
context('Aliasing', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/commands/aliasing')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.as() - alias a DOM element for later use', () => {
|
||||||
|
// https://on.cypress.io/as
|
||||||
|
|
||||||
|
// Alias a DOM element for use later
|
||||||
|
// We don't have to traverse to the element
|
||||||
|
// later in our code, we reference it with @
|
||||||
|
|
||||||
|
cy.get('.as-table').find('tbody>tr')
|
||||||
|
.first().find('td').first()
|
||||||
|
.find('button').as('firstBtn')
|
||||||
|
|
||||||
|
// when we reference the alias, we place an
|
||||||
|
// @ in front of its name
|
||||||
|
cy.get('@firstBtn').click()
|
||||||
|
|
||||||
|
cy.get('@firstBtn')
|
||||||
|
.should('have.class', 'btn-success')
|
||||||
|
.and('contain', 'Changed')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.as() - alias a route for later use', () => {
|
||||||
|
// Alias the route to wait for its response
|
||||||
|
cy.intercept('GET', '**/comments/*').as('getComment')
|
||||||
|
|
||||||
|
// we have code that gets a comment when
|
||||||
|
// the button is clicked in scripts.js
|
||||||
|
cy.get('.network-btn').click()
|
||||||
|
|
||||||
|
// https://on.cypress.io/wait
|
||||||
|
cy.wait('@getComment').its('response.statusCode').should('eq', 200)
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,177 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
context('Assertions', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/commands/assertions')
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('Implicit Assertions', () => {
|
||||||
|
it('.should() - make an assertion about the current subject', () => {
|
||||||
|
// https://on.cypress.io/should
|
||||||
|
cy.get('.assertion-table')
|
||||||
|
.find('tbody tr:last')
|
||||||
|
.should('have.class', 'success')
|
||||||
|
.find('td')
|
||||||
|
.first()
|
||||||
|
// checking the text of the <td> element in various ways
|
||||||
|
.should('have.text', 'Column content')
|
||||||
|
.should('contain', 'Column content')
|
||||||
|
.should('have.html', 'Column content')
|
||||||
|
// chai-jquery uses "is()" to check if element matches selector
|
||||||
|
.should('match', 'td')
|
||||||
|
// to match text content against a regular expression
|
||||||
|
// first need to invoke jQuery method text()
|
||||||
|
// and then match using regular expression
|
||||||
|
.invoke('text')
|
||||||
|
.should('match', /column content/i)
|
||||||
|
|
||||||
|
// a better way to check element's text content against a regular expression
|
||||||
|
// is to use "cy.contains"
|
||||||
|
// https://on.cypress.io/contains
|
||||||
|
cy.get('.assertion-table')
|
||||||
|
.find('tbody tr:last')
|
||||||
|
// finds first <td> element with text content matching regular expression
|
||||||
|
.contains('td', /column content/i)
|
||||||
|
.should('be.visible')
|
||||||
|
|
||||||
|
// for more information about asserting element's text
|
||||||
|
// see https://on.cypress.io/using-cypress-faq#How-do-I-get-an-element’s-text-contents
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.and() - chain multiple assertions together', () => {
|
||||||
|
// https://on.cypress.io/and
|
||||||
|
cy.get('.assertions-link')
|
||||||
|
.should('have.class', 'active')
|
||||||
|
.and('have.attr', 'href')
|
||||||
|
.and('include', 'cypress.io')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('Explicit Assertions', () => {
|
||||||
|
// https://on.cypress.io/assertions
|
||||||
|
it('expect - make an assertion about a specified subject', () => {
|
||||||
|
// We can use Chai's BDD style assertions
|
||||||
|
expect(true).to.be.true
|
||||||
|
const o = { foo: 'bar' }
|
||||||
|
|
||||||
|
expect(o).to.equal(o)
|
||||||
|
expect(o).to.deep.equal({ foo: 'bar' })
|
||||||
|
// matching text using regular expression
|
||||||
|
expect('FooBar').to.match(/bar$/i)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('pass your own callback function to should()', () => {
|
||||||
|
// Pass a function to should that can have any number
|
||||||
|
// of explicit assertions within it.
|
||||||
|
// The ".should(cb)" function will be retried
|
||||||
|
// automatically until it passes all your explicit assertions or times out.
|
||||||
|
cy.get('.assertions-p')
|
||||||
|
.find('p')
|
||||||
|
.should(($p) => {
|
||||||
|
// https://on.cypress.io/$
|
||||||
|
// return an array of texts from all of the p's
|
||||||
|
// @ts-ignore TS6133 unused variable
|
||||||
|
const texts = $p.map((i, el) => Cypress.$(el).text())
|
||||||
|
|
||||||
|
// jquery map returns jquery object
|
||||||
|
// and .get() convert this to simple array
|
||||||
|
const paragraphs = texts.get()
|
||||||
|
|
||||||
|
// array should have length of 3
|
||||||
|
expect(paragraphs, 'has 3 paragraphs').to.have.length(3)
|
||||||
|
|
||||||
|
// use second argument to expect(...) to provide clear
|
||||||
|
// message with each assertion
|
||||||
|
expect(paragraphs, 'has expected text in each paragraph').to.deep.eq([
|
||||||
|
'Some text from first p',
|
||||||
|
'More text from second p',
|
||||||
|
'And even more text from third p',
|
||||||
|
])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('finds element by class name regex', () => {
|
||||||
|
cy.get('.docs-header')
|
||||||
|
.find('div')
|
||||||
|
// .should(cb) callback function will be retried
|
||||||
|
.should(($div) => {
|
||||||
|
expect($div).to.have.length(1)
|
||||||
|
|
||||||
|
const className = $div[0].className
|
||||||
|
|
||||||
|
expect(className).to.match(/heading-/)
|
||||||
|
})
|
||||||
|
// .then(cb) callback is not retried,
|
||||||
|
// it either passes or fails
|
||||||
|
.then(($div) => {
|
||||||
|
expect($div, 'text content').to.have.text('Introduction')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('can throw any error', () => {
|
||||||
|
cy.get('.docs-header')
|
||||||
|
.find('div')
|
||||||
|
.should(($div) => {
|
||||||
|
if ($div.length !== 1) {
|
||||||
|
// you can throw your own errors
|
||||||
|
throw new Error('Did not find 1 element')
|
||||||
|
}
|
||||||
|
|
||||||
|
const className = $div[0].className
|
||||||
|
|
||||||
|
if (!className.match(/heading-/)) {
|
||||||
|
throw new Error(`Could not find class "heading-" in ${className}`)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('matches unknown text between two elements', () => {
|
||||||
|
/**
|
||||||
|
* Text from the first element.
|
||||||
|
* @type {string}
|
||||||
|
*/
|
||||||
|
let text
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Normalizes passed text,
|
||||||
|
* useful before comparing text with spaces and different capitalization.
|
||||||
|
* @param {string} s Text to normalize
|
||||||
|
*/
|
||||||
|
const normalizeText = (s) => s.replace(/\s/g, '').toLowerCase()
|
||||||
|
|
||||||
|
cy.get('.two-elements')
|
||||||
|
.find('.first')
|
||||||
|
.then(($first) => {
|
||||||
|
// save text from the first element
|
||||||
|
text = normalizeText($first.text())
|
||||||
|
})
|
||||||
|
|
||||||
|
cy.get('.two-elements')
|
||||||
|
.find('.second')
|
||||||
|
.should(($div) => {
|
||||||
|
// we can massage text before comparing
|
||||||
|
const secondText = normalizeText($div.text())
|
||||||
|
|
||||||
|
expect(secondText, 'second text').to.equal(text)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('assert - assert shape of an object', () => {
|
||||||
|
const person = {
|
||||||
|
name: 'Joe',
|
||||||
|
age: 20,
|
||||||
|
}
|
||||||
|
|
||||||
|
assert.isObject(person, 'value is object')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('retries the should callback until assertions pass', () => {
|
||||||
|
cy.get('#random-number')
|
||||||
|
.should(($div) => {
|
||||||
|
const n = parseFloat($div.text())
|
||||||
|
|
||||||
|
expect(n).to.be.gte(1).and.be.lte(10)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
context('Connectors', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/commands/connectors')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.each() - iterate over an array of elements', () => {
|
||||||
|
// https://on.cypress.io/each
|
||||||
|
cy.get('.connectors-each-ul>li')
|
||||||
|
.each(($el, index, $list) => {
|
||||||
|
console.log($el, index, $list)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.its() - get properties on the current subject', () => {
|
||||||
|
// https://on.cypress.io/its
|
||||||
|
cy.get('.connectors-its-ul>li')
|
||||||
|
// calls the 'length' property yielding that value
|
||||||
|
.its('length')
|
||||||
|
.should('be.gt', 2)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.invoke() - invoke a function on the current subject', () => {
|
||||||
|
// our div is hidden in our script.js
|
||||||
|
// $('.connectors-div').hide()
|
||||||
|
|
||||||
|
// https://on.cypress.io/invoke
|
||||||
|
cy.get('.connectors-div').should('be.hidden')
|
||||||
|
// call the jquery method 'show' on the 'div.container'
|
||||||
|
.invoke('show')
|
||||||
|
.should('be.visible')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.spread() - spread an array as individual args to callback function', () => {
|
||||||
|
// https://on.cypress.io/spread
|
||||||
|
const arr = ['foo', 'bar', 'baz']
|
||||||
|
|
||||||
|
cy.wrap(arr).spread((foo, bar, baz) => {
|
||||||
|
expect(foo).to.eq('foo')
|
||||||
|
expect(bar).to.eq('bar')
|
||||||
|
expect(baz).to.eq('baz')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('.then()', () => {
|
||||||
|
it('invokes a callback function with the current subject', () => {
|
||||||
|
// https://on.cypress.io/then
|
||||||
|
cy.get('.connectors-list > li')
|
||||||
|
.then(($lis) => {
|
||||||
|
expect($lis, '3 items').to.have.length(3)
|
||||||
|
expect($lis.eq(0), 'first item').to.contain('Walk the dog')
|
||||||
|
expect($lis.eq(1), 'second item').to.contain('Feed the cat')
|
||||||
|
expect($lis.eq(2), 'third item').to.contain('Write JavaScript')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('yields the returned value to the next command', () => {
|
||||||
|
cy.wrap(1)
|
||||||
|
.then((num) => {
|
||||||
|
expect(num).to.equal(1)
|
||||||
|
|
||||||
|
return 2
|
||||||
|
})
|
||||||
|
.then((num) => {
|
||||||
|
expect(num).to.equal(2)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('yields the original subject without return', () => {
|
||||||
|
cy.wrap(1)
|
||||||
|
.then((num) => {
|
||||||
|
expect(num).to.equal(1)
|
||||||
|
// note that nothing is returned from this callback
|
||||||
|
})
|
||||||
|
.then((num) => {
|
||||||
|
// this callback receives the original unchanged value 1
|
||||||
|
expect(num).to.equal(1)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('yields the value yielded by the last Cypress command inside', () => {
|
||||||
|
cy.wrap(1)
|
||||||
|
.then((num) => {
|
||||||
|
expect(num).to.equal(1)
|
||||||
|
// note how we run a Cypress command
|
||||||
|
// the result yielded by this Cypress command
|
||||||
|
// will be passed to the second ".then"
|
||||||
|
cy.wrap(2)
|
||||||
|
})
|
||||||
|
.then((num) => {
|
||||||
|
// this callback receives the value yielded by "cy.wrap(2)"
|
||||||
|
expect(num).to.equal(2)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,77 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
context('Cookies', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
Cypress.Cookies.debug(true)
|
||||||
|
|
||||||
|
cy.visit('https://example.cypress.io/commands/cookies')
|
||||||
|
|
||||||
|
// clear cookies again after visiting to remove
|
||||||
|
// any 3rd party cookies picked up such as cloudflare
|
||||||
|
cy.clearCookies()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.getCookie() - get a browser cookie', () => {
|
||||||
|
// https://on.cypress.io/getcookie
|
||||||
|
cy.get('#getCookie .set-a-cookie').click()
|
||||||
|
|
||||||
|
// cy.getCookie() yields a cookie object
|
||||||
|
cy.getCookie('token').should('have.property', 'value', '123ABC')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.getCookies() - get browser cookies', () => {
|
||||||
|
// https://on.cypress.io/getcookies
|
||||||
|
cy.getCookies().should('be.empty')
|
||||||
|
|
||||||
|
cy.get('#getCookies .set-a-cookie').click()
|
||||||
|
|
||||||
|
// cy.getCookies() yields an array of cookies
|
||||||
|
cy.getCookies().should('have.length', 1).should((cookies) => {
|
||||||
|
// each cookie has these properties
|
||||||
|
expect(cookies[0]).to.have.property('name', 'token')
|
||||||
|
expect(cookies[0]).to.have.property('value', '123ABC')
|
||||||
|
expect(cookies[0]).to.have.property('httpOnly', false)
|
||||||
|
expect(cookies[0]).to.have.property('secure', false)
|
||||||
|
expect(cookies[0]).to.have.property('domain')
|
||||||
|
expect(cookies[0]).to.have.property('path')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.setCookie() - set a browser cookie', () => {
|
||||||
|
// https://on.cypress.io/setcookie
|
||||||
|
cy.getCookies().should('be.empty')
|
||||||
|
|
||||||
|
cy.setCookie('foo', 'bar')
|
||||||
|
|
||||||
|
// cy.getCookie() yields a cookie object
|
||||||
|
cy.getCookie('foo').should('have.property', 'value', 'bar')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.clearCookie() - clear a browser cookie', () => {
|
||||||
|
// https://on.cypress.io/clearcookie
|
||||||
|
cy.getCookie('token').should('be.null')
|
||||||
|
|
||||||
|
cy.get('#clearCookie .set-a-cookie').click()
|
||||||
|
|
||||||
|
cy.getCookie('token').should('have.property', 'value', '123ABC')
|
||||||
|
|
||||||
|
// cy.clearCookies() yields null
|
||||||
|
cy.clearCookie('token').should('be.null')
|
||||||
|
|
||||||
|
cy.getCookie('token').should('be.null')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.clearCookies() - clear browser cookies', () => {
|
||||||
|
// https://on.cypress.io/clearcookies
|
||||||
|
cy.getCookies().should('be.empty')
|
||||||
|
|
||||||
|
cy.get('#clearCookies .set-a-cookie').click()
|
||||||
|
|
||||||
|
cy.getCookies().should('have.length', 1)
|
||||||
|
|
||||||
|
// cy.clearCookies() yields null
|
||||||
|
cy.clearCookies()
|
||||||
|
|
||||||
|
cy.getCookies().should('be.empty')
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,202 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
context('Cypress.Commands', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/cypress-api')
|
||||||
|
})
|
||||||
|
|
||||||
|
// https://on.cypress.io/custom-commands
|
||||||
|
|
||||||
|
it('.add() - create a custom command', () => {
|
||||||
|
Cypress.Commands.add('console', {
|
||||||
|
prevSubject: true,
|
||||||
|
}, (subject, method) => {
|
||||||
|
// the previous subject is automatically received
|
||||||
|
// and the commands arguments are shifted
|
||||||
|
|
||||||
|
// allow us to change the console method used
|
||||||
|
method = method || 'log'
|
||||||
|
|
||||||
|
// log the subject to the console
|
||||||
|
// @ts-ignore TS7017
|
||||||
|
console[method]('The subject is', subject)
|
||||||
|
|
||||||
|
// whatever we return becomes the new subject
|
||||||
|
// we don't want to change the subject so
|
||||||
|
// we return whatever was passed in
|
||||||
|
return subject
|
||||||
|
})
|
||||||
|
|
||||||
|
// @ts-ignore TS2339
|
||||||
|
cy.get('button').console('info').then(($button) => {
|
||||||
|
// subject is still $button
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
context('Cypress.Cookies', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/cypress-api')
|
||||||
|
})
|
||||||
|
|
||||||
|
// https://on.cypress.io/cookies
|
||||||
|
it('.debug() - enable or disable debugging', () => {
|
||||||
|
Cypress.Cookies.debug(true)
|
||||||
|
|
||||||
|
// Cypress will now log in the console when
|
||||||
|
// cookies are set or cleared
|
||||||
|
cy.setCookie('fakeCookie', '123ABC')
|
||||||
|
cy.clearCookie('fakeCookie')
|
||||||
|
cy.setCookie('fakeCookie', '123ABC')
|
||||||
|
cy.clearCookie('fakeCookie')
|
||||||
|
cy.setCookie('fakeCookie', '123ABC')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.preserveOnce() - preserve cookies by key', () => {
|
||||||
|
// normally cookies are reset after each test
|
||||||
|
cy.getCookie('fakeCookie').should('not.be.ok')
|
||||||
|
|
||||||
|
// preserving a cookie will not clear it when
|
||||||
|
// the next test starts
|
||||||
|
cy.setCookie('lastCookie', '789XYZ')
|
||||||
|
Cypress.Cookies.preserveOnce('lastCookie')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.defaults() - set defaults for all cookies', () => {
|
||||||
|
// now any cookie with the name 'session_id' will
|
||||||
|
// not be cleared before each new test runs
|
||||||
|
Cypress.Cookies.defaults({
|
||||||
|
preserve: 'session_id',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
context('Cypress.arch', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/cypress-api')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Get CPU architecture name of underlying OS', () => {
|
||||||
|
// https://on.cypress.io/arch
|
||||||
|
expect(Cypress.arch).to.exist
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
context('Cypress.config()', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/cypress-api')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Get and set configuration options', () => {
|
||||||
|
// https://on.cypress.io/config
|
||||||
|
let myConfig = Cypress.config()
|
||||||
|
|
||||||
|
expect(myConfig).to.have.property('animationDistanceThreshold', 5)
|
||||||
|
expect(myConfig).to.have.property('baseUrl', null)
|
||||||
|
expect(myConfig).to.have.property('defaultCommandTimeout', 4000)
|
||||||
|
expect(myConfig).to.have.property('requestTimeout', 5000)
|
||||||
|
expect(myConfig).to.have.property('responseTimeout', 30000)
|
||||||
|
expect(myConfig).to.have.property('viewportHeight', 660)
|
||||||
|
expect(myConfig).to.have.property('viewportWidth', 1000)
|
||||||
|
expect(myConfig).to.have.property('pageLoadTimeout', 60000)
|
||||||
|
expect(myConfig).to.have.property('waitForAnimations', true)
|
||||||
|
|
||||||
|
expect(Cypress.config('pageLoadTimeout')).to.eq(60000)
|
||||||
|
|
||||||
|
// this will change the config for the rest of your tests!
|
||||||
|
Cypress.config('pageLoadTimeout', 20000)
|
||||||
|
|
||||||
|
expect(Cypress.config('pageLoadTimeout')).to.eq(20000)
|
||||||
|
|
||||||
|
Cypress.config('pageLoadTimeout', 60000)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
context('Cypress.dom', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/cypress-api')
|
||||||
|
})
|
||||||
|
|
||||||
|
// https://on.cypress.io/dom
|
||||||
|
it('.isHidden() - determine if a DOM element is hidden', () => {
|
||||||
|
let hiddenP = Cypress.$('.dom-p p.hidden').get(0)
|
||||||
|
let visibleP = Cypress.$('.dom-p p.visible').get(0)
|
||||||
|
|
||||||
|
// our first paragraph has css class 'hidden'
|
||||||
|
expect(Cypress.dom.isHidden(hiddenP)).to.be.true
|
||||||
|
expect(Cypress.dom.isHidden(visibleP)).to.be.false
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
context('Cypress.env()', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/cypress-api')
|
||||||
|
})
|
||||||
|
|
||||||
|
// We can set environment variables for highly dynamic values
|
||||||
|
|
||||||
|
// https://on.cypress.io/environment-variables
|
||||||
|
it('Get environment variables', () => {
|
||||||
|
// https://on.cypress.io/env
|
||||||
|
// set multiple environment variables
|
||||||
|
Cypress.env({
|
||||||
|
host: 'veronica.dev.local',
|
||||||
|
api_server: 'http://localhost:8888/v1/',
|
||||||
|
})
|
||||||
|
|
||||||
|
// get environment variable
|
||||||
|
expect(Cypress.env('host')).to.eq('veronica.dev.local')
|
||||||
|
|
||||||
|
// set environment variable
|
||||||
|
Cypress.env('api_server', 'http://localhost:8888/v2/')
|
||||||
|
expect(Cypress.env('api_server')).to.eq('http://localhost:8888/v2/')
|
||||||
|
|
||||||
|
// get all environment variable
|
||||||
|
expect(Cypress.env()).to.have.property('host', 'veronica.dev.local')
|
||||||
|
expect(Cypress.env()).to.have.property('api_server', 'http://localhost:8888/v2/')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
context('Cypress.log', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/cypress-api')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Control what is printed to the Command Log', () => {
|
||||||
|
// https://on.cypress.io/cypress-log
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
context('Cypress.platform', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/cypress-api')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Get underlying OS name', () => {
|
||||||
|
// https://on.cypress.io/platform
|
||||||
|
expect(Cypress.platform).to.be.exist
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
context('Cypress.version', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/cypress-api')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Get current version of Cypress being run', () => {
|
||||||
|
// https://on.cypress.io/version
|
||||||
|
expect(Cypress.version).to.be.exist
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
context('Cypress.spec', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/cypress-api')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Get current spec information', () => {
|
||||||
|
// https://on.cypress.io/spec
|
||||||
|
// wrap the object so we can inspect it easily by clicking in the command log
|
||||||
|
cy.wrap(Cypress.spec).should('include.keys', ['name', 'relative', 'absolute'])
|
||||||
|
})
|
||||||
|
})
|
||||||
88
client/cypress/integration/2-advanced-examples/files.spec.js
Normal file
88
client/cypress/integration/2-advanced-examples/files.spec.js
Normal file
@@ -0,0 +1,88 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
/// JSON fixture file can be loaded directly using
|
||||||
|
// the built-in JavaScript bundler
|
||||||
|
// @ts-ignore
|
||||||
|
const requiredExample = require('../../fixtures/example')
|
||||||
|
|
||||||
|
context('Files', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/commands/files')
|
||||||
|
})
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
// load example.json fixture file and store
|
||||||
|
// in the test context object
|
||||||
|
cy.fixture('example.json').as('example')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.fixture() - load a fixture', () => {
|
||||||
|
// https://on.cypress.io/fixture
|
||||||
|
|
||||||
|
// Instead of writing a response inline you can
|
||||||
|
// use a fixture file's content.
|
||||||
|
|
||||||
|
// when application makes an Ajax request matching "GET **/comments/*"
|
||||||
|
// Cypress will intercept it and reply with the object in `example.json` fixture
|
||||||
|
cy.intercept('GET', '**/comments/*', { fixture: 'example.json' }).as('getComment')
|
||||||
|
|
||||||
|
// we have code that gets a comment when
|
||||||
|
// the button is clicked in scripts.js
|
||||||
|
cy.get('.fixture-btn').click()
|
||||||
|
|
||||||
|
cy.wait('@getComment').its('response.body')
|
||||||
|
.should('have.property', 'name')
|
||||||
|
.and('include', 'Using fixtures to represent data')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.fixture() or require - load a fixture', function () {
|
||||||
|
// we are inside the "function () { ... }"
|
||||||
|
// callback and can use test context object "this"
|
||||||
|
// "this.example" was loaded in "beforeEach" function callback
|
||||||
|
expect(this.example, 'fixture in the test context')
|
||||||
|
.to.deep.equal(requiredExample)
|
||||||
|
|
||||||
|
// or use "cy.wrap" and "should('deep.equal', ...)" assertion
|
||||||
|
cy.wrap(this.example)
|
||||||
|
.should('deep.equal', requiredExample)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.readFile() - read file contents', () => {
|
||||||
|
// https://on.cypress.io/readfile
|
||||||
|
|
||||||
|
// You can read a file and yield its contents
|
||||||
|
// The filePath is relative to your project's root.
|
||||||
|
cy.readFile('cypress.json').then((json) => {
|
||||||
|
expect(json).to.be.an('object')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.writeFile() - write to a file', () => {
|
||||||
|
// https://on.cypress.io/writefile
|
||||||
|
|
||||||
|
// You can write to a file
|
||||||
|
|
||||||
|
// Use a response from a request to automatically
|
||||||
|
// generate a fixture file for use later
|
||||||
|
cy.request('https://jsonplaceholder.cypress.io/users')
|
||||||
|
.then((response) => {
|
||||||
|
cy.writeFile('cypress/fixtures/users.json', response.body)
|
||||||
|
})
|
||||||
|
|
||||||
|
cy.fixture('users').should((users) => {
|
||||||
|
expect(users[0].name).to.exist
|
||||||
|
})
|
||||||
|
|
||||||
|
// JavaScript arrays and objects are stringified
|
||||||
|
// and formatted into text.
|
||||||
|
cy.writeFile('cypress/fixtures/profile.json', {
|
||||||
|
id: 8739,
|
||||||
|
name: 'Jane',
|
||||||
|
email: 'jane@example.com',
|
||||||
|
})
|
||||||
|
|
||||||
|
cy.fixture('profile').should((profile) => {
|
||||||
|
expect(profile.name).to.eq('Jane')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
context('Local Storage', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/commands/local-storage')
|
||||||
|
})
|
||||||
|
// Although local storage is automatically cleared
|
||||||
|
// in between tests to maintain a clean state
|
||||||
|
// sometimes we need to clear the local storage manually
|
||||||
|
|
||||||
|
it('cy.clearLocalStorage() - clear all data in local storage', () => {
|
||||||
|
// https://on.cypress.io/clearlocalstorage
|
||||||
|
cy.get('.ls-btn').click().should(() => {
|
||||||
|
expect(localStorage.getItem('prop1')).to.eq('red')
|
||||||
|
expect(localStorage.getItem('prop2')).to.eq('blue')
|
||||||
|
expect(localStorage.getItem('prop3')).to.eq('magenta')
|
||||||
|
})
|
||||||
|
|
||||||
|
// clearLocalStorage() yields the localStorage object
|
||||||
|
cy.clearLocalStorage().should((ls) => {
|
||||||
|
expect(ls.getItem('prop1')).to.be.null
|
||||||
|
expect(ls.getItem('prop2')).to.be.null
|
||||||
|
expect(ls.getItem('prop3')).to.be.null
|
||||||
|
})
|
||||||
|
|
||||||
|
cy.get('.ls-btn').click().should(() => {
|
||||||
|
expect(localStorage.getItem('prop1')).to.eq('red')
|
||||||
|
expect(localStorage.getItem('prop2')).to.eq('blue')
|
||||||
|
expect(localStorage.getItem('prop3')).to.eq('magenta')
|
||||||
|
})
|
||||||
|
|
||||||
|
// Clear key matching string in Local Storage
|
||||||
|
cy.clearLocalStorage('prop1').should((ls) => {
|
||||||
|
expect(ls.getItem('prop1')).to.be.null
|
||||||
|
expect(ls.getItem('prop2')).to.eq('blue')
|
||||||
|
expect(ls.getItem('prop3')).to.eq('magenta')
|
||||||
|
})
|
||||||
|
|
||||||
|
cy.get('.ls-btn').click().should(() => {
|
||||||
|
expect(localStorage.getItem('prop1')).to.eq('red')
|
||||||
|
expect(localStorage.getItem('prop2')).to.eq('blue')
|
||||||
|
expect(localStorage.getItem('prop3')).to.eq('magenta')
|
||||||
|
})
|
||||||
|
|
||||||
|
// Clear keys matching regex in Local Storage
|
||||||
|
cy.clearLocalStorage(/prop1|2/).should((ls) => {
|
||||||
|
expect(ls.getItem('prop1')).to.be.null
|
||||||
|
expect(ls.getItem('prop2')).to.be.null
|
||||||
|
expect(ls.getItem('prop3')).to.eq('magenta')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
context('Location', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/commands/location')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.hash() - get the current URL hash', () => {
|
||||||
|
// https://on.cypress.io/hash
|
||||||
|
cy.hash().should('be.empty')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.location() - get window.location', () => {
|
||||||
|
// https://on.cypress.io/location
|
||||||
|
cy.location().should((location) => {
|
||||||
|
expect(location.hash).to.be.empty
|
||||||
|
expect(location.href).to.eq('https://example.cypress.io/commands/location')
|
||||||
|
expect(location.host).to.eq('example.cypress.io')
|
||||||
|
expect(location.hostname).to.eq('example.cypress.io')
|
||||||
|
expect(location.origin).to.eq('https://example.cypress.io')
|
||||||
|
expect(location.pathname).to.eq('/commands/location')
|
||||||
|
expect(location.port).to.eq('')
|
||||||
|
expect(location.protocol).to.eq('https:')
|
||||||
|
expect(location.search).to.be.empty
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.url() - get the current URL', () => {
|
||||||
|
// https://on.cypress.io/url
|
||||||
|
cy.url().should('eq', 'https://example.cypress.io/commands/location')
|
||||||
|
})
|
||||||
|
})
|
||||||
104
client/cypress/integration/2-advanced-examples/misc.spec.js
Normal file
104
client/cypress/integration/2-advanced-examples/misc.spec.js
Normal file
@@ -0,0 +1,104 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
context('Misc', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/commands/misc')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.end() - end the command chain', () => {
|
||||||
|
// https://on.cypress.io/end
|
||||||
|
|
||||||
|
// cy.end is useful when you want to end a chain of commands
|
||||||
|
// and force Cypress to re-query from the root element
|
||||||
|
cy.get('.misc-table').within(() => {
|
||||||
|
// ends the current chain and yields null
|
||||||
|
cy.contains('Cheryl').click().end()
|
||||||
|
|
||||||
|
// queries the entire table again
|
||||||
|
cy.contains('Charles').click()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.exec() - execute a system command', () => {
|
||||||
|
// execute a system command.
|
||||||
|
// so you can take actions necessary for
|
||||||
|
// your test outside the scope of Cypress.
|
||||||
|
// https://on.cypress.io/exec
|
||||||
|
|
||||||
|
// we can use Cypress.platform string to
|
||||||
|
// select appropriate command
|
||||||
|
// https://on.cypress/io/platform
|
||||||
|
cy.log(`Platform ${Cypress.platform} architecture ${Cypress.arch}`)
|
||||||
|
|
||||||
|
// on CircleCI Windows build machines we have a failure to run bash shell
|
||||||
|
// https://github.com/cypress-io/cypress/issues/5169
|
||||||
|
// so skip some of the tests by passing flag "--env circle=true"
|
||||||
|
const isCircleOnWindows = Cypress.platform === 'win32' && Cypress.env('circle')
|
||||||
|
|
||||||
|
if (isCircleOnWindows) {
|
||||||
|
cy.log('Skipping test on CircleCI')
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
// cy.exec problem on Shippable CI
|
||||||
|
// https://github.com/cypress-io/cypress/issues/6718
|
||||||
|
const isShippable = Cypress.platform === 'linux' && Cypress.env('shippable')
|
||||||
|
|
||||||
|
if (isShippable) {
|
||||||
|
cy.log('Skipping test on ShippableCI')
|
||||||
|
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
cy.exec('echo Jane Lane')
|
||||||
|
.its('stdout').should('contain', 'Jane Lane')
|
||||||
|
|
||||||
|
if (Cypress.platform === 'win32') {
|
||||||
|
cy.exec('print cypress.json')
|
||||||
|
.its('stderr').should('be.empty')
|
||||||
|
} else {
|
||||||
|
cy.exec('cat cypress.json')
|
||||||
|
.its('stderr').should('be.empty')
|
||||||
|
|
||||||
|
cy.exec('pwd')
|
||||||
|
.its('code').should('eq', 0)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.focused() - get the DOM element that has focus', () => {
|
||||||
|
// https://on.cypress.io/focused
|
||||||
|
cy.get('.misc-form').find('#name').click()
|
||||||
|
cy.focused().should('have.id', 'name')
|
||||||
|
|
||||||
|
cy.get('.misc-form').find('#description').click()
|
||||||
|
cy.focused().should('have.id', 'description')
|
||||||
|
})
|
||||||
|
|
||||||
|
context('Cypress.Screenshot', function () {
|
||||||
|
it('cy.screenshot() - take a screenshot', () => {
|
||||||
|
// https://on.cypress.io/screenshot
|
||||||
|
cy.screenshot('my-image')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Cypress.Screenshot.defaults() - change default config of screenshots', function () {
|
||||||
|
Cypress.Screenshot.defaults({
|
||||||
|
blackout: ['.foo'],
|
||||||
|
capture: 'viewport',
|
||||||
|
clip: { x: 0, y: 0, width: 200, height: 200 },
|
||||||
|
scale: false,
|
||||||
|
disableTimersAndAnimations: true,
|
||||||
|
screenshotOnRunFailure: true,
|
||||||
|
onBeforeScreenshot () { },
|
||||||
|
onAfterScreenshot () { },
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.wrap() - wrap an object', () => {
|
||||||
|
// https://on.cypress.io/wrap
|
||||||
|
cy.wrap({ foo: 'bar' })
|
||||||
|
.should('have.property', 'foo')
|
||||||
|
.and('include', 'bar')
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
context('Navigation', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io')
|
||||||
|
cy.get('.navbar-nav').contains('Commands').click()
|
||||||
|
cy.get('.dropdown-menu').contains('Navigation').click()
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.go() - go back or forward in the browser\'s history', () => {
|
||||||
|
// https://on.cypress.io/go
|
||||||
|
|
||||||
|
cy.location('pathname').should('include', 'navigation')
|
||||||
|
|
||||||
|
cy.go('back')
|
||||||
|
cy.location('pathname').should('not.include', 'navigation')
|
||||||
|
|
||||||
|
cy.go('forward')
|
||||||
|
cy.location('pathname').should('include', 'navigation')
|
||||||
|
|
||||||
|
// clicking back
|
||||||
|
cy.go(-1)
|
||||||
|
cy.location('pathname').should('not.include', 'navigation')
|
||||||
|
|
||||||
|
// clicking forward
|
||||||
|
cy.go(1)
|
||||||
|
cy.location('pathname').should('include', 'navigation')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.reload() - reload the page', () => {
|
||||||
|
// https://on.cypress.io/reload
|
||||||
|
cy.reload()
|
||||||
|
|
||||||
|
// reload the page without using the cache
|
||||||
|
cy.reload(true)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.visit() - visit a remote url', () => {
|
||||||
|
// https://on.cypress.io/visit
|
||||||
|
|
||||||
|
// Visit any sub-domain of your current domain
|
||||||
|
|
||||||
|
// Pass options to the visit
|
||||||
|
cy.visit('https://example.cypress.io/commands/navigation', {
|
||||||
|
timeout: 50000, // increase total time for the visit to resolve
|
||||||
|
onBeforeLoad (contentWindow) {
|
||||||
|
// contentWindow is the remote page's window object
|
||||||
|
expect(typeof contentWindow === 'object').to.be.true
|
||||||
|
},
|
||||||
|
onLoad (contentWindow) {
|
||||||
|
// contentWindow is the remote page's window object
|
||||||
|
expect(typeof contentWindow === 'object').to.be.true
|
||||||
|
},
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,163 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
context('Network Requests', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/commands/network-requests')
|
||||||
|
})
|
||||||
|
|
||||||
|
// Manage HTTP requests in your app
|
||||||
|
|
||||||
|
it('cy.request() - make an XHR request', () => {
|
||||||
|
// https://on.cypress.io/request
|
||||||
|
cy.request('https://jsonplaceholder.cypress.io/comments')
|
||||||
|
.should((response) => {
|
||||||
|
expect(response.status).to.eq(200)
|
||||||
|
// the server sometimes gets an extra comment posted from another machine
|
||||||
|
// which gets returned as 1 extra object
|
||||||
|
expect(response.body).to.have.property('length').and.be.oneOf([500, 501])
|
||||||
|
expect(response).to.have.property('headers')
|
||||||
|
expect(response).to.have.property('duration')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.request() - verify response using BDD syntax', () => {
|
||||||
|
cy.request('https://jsonplaceholder.cypress.io/comments')
|
||||||
|
.then((response) => {
|
||||||
|
// https://on.cypress.io/assertions
|
||||||
|
expect(response).property('status').to.equal(200)
|
||||||
|
expect(response).property('body').to.have.property('length').and.be.oneOf([500, 501])
|
||||||
|
expect(response).to.include.keys('headers', 'duration')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.request() with query parameters', () => {
|
||||||
|
// will execute request
|
||||||
|
// https://jsonplaceholder.cypress.io/comments?postId=1&id=3
|
||||||
|
cy.request({
|
||||||
|
url: 'https://jsonplaceholder.cypress.io/comments',
|
||||||
|
qs: {
|
||||||
|
postId: 1,
|
||||||
|
id: 3,
|
||||||
|
},
|
||||||
|
})
|
||||||
|
.its('body')
|
||||||
|
.should('be.an', 'array')
|
||||||
|
.and('have.length', 1)
|
||||||
|
.its('0') // yields first element of the array
|
||||||
|
.should('contain', {
|
||||||
|
postId: 1,
|
||||||
|
id: 3,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.request() - pass result to the second request', () => {
|
||||||
|
// first, let's find out the userId of the first user we have
|
||||||
|
cy.request('https://jsonplaceholder.cypress.io/users?_limit=1')
|
||||||
|
.its('body') // yields the response object
|
||||||
|
.its('0') // yields the first element of the returned list
|
||||||
|
// the above two commands its('body').its('0')
|
||||||
|
// can be written as its('body.0')
|
||||||
|
// if you do not care about TypeScript checks
|
||||||
|
.then((user) => {
|
||||||
|
expect(user).property('id').to.be.a('number')
|
||||||
|
// make a new post on behalf of the user
|
||||||
|
cy.request('POST', 'https://jsonplaceholder.cypress.io/posts', {
|
||||||
|
userId: user.id,
|
||||||
|
title: 'Cypress Test Runner',
|
||||||
|
body: 'Fast, easy and reliable testing for anything that runs in a browser.',
|
||||||
|
})
|
||||||
|
})
|
||||||
|
// note that the value here is the returned value of the 2nd request
|
||||||
|
// which is the new post object
|
||||||
|
.then((response) => {
|
||||||
|
expect(response).property('status').to.equal(201) // new entity created
|
||||||
|
expect(response).property('body').to.contain({
|
||||||
|
title: 'Cypress Test Runner',
|
||||||
|
})
|
||||||
|
|
||||||
|
// we don't know the exact post id - only that it will be > 100
|
||||||
|
// since JSONPlaceholder has built-in 100 posts
|
||||||
|
expect(response.body).property('id').to.be.a('number')
|
||||||
|
.and.to.be.gt(100)
|
||||||
|
|
||||||
|
// we don't know the user id here - since it was in above closure
|
||||||
|
// so in this test just confirm that the property is there
|
||||||
|
expect(response.body).property('userId').to.be.a('number')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.request() - save response in the shared test context', () => {
|
||||||
|
// https://on.cypress.io/variables-and-aliases
|
||||||
|
cy.request('https://jsonplaceholder.cypress.io/users?_limit=1')
|
||||||
|
.its('body').its('0') // yields the first element of the returned list
|
||||||
|
.as('user') // saves the object in the test context
|
||||||
|
.then(function () {
|
||||||
|
// NOTE 👀
|
||||||
|
// By the time this callback runs the "as('user')" command
|
||||||
|
// has saved the user object in the test context.
|
||||||
|
// To access the test context we need to use
|
||||||
|
// the "function () { ... }" callback form,
|
||||||
|
// otherwise "this" points at a wrong or undefined object!
|
||||||
|
cy.request('POST', 'https://jsonplaceholder.cypress.io/posts', {
|
||||||
|
userId: this.user.id,
|
||||||
|
title: 'Cypress Test Runner',
|
||||||
|
body: 'Fast, easy and reliable testing for anything that runs in a browser.',
|
||||||
|
})
|
||||||
|
.its('body').as('post') // save the new post from the response
|
||||||
|
})
|
||||||
|
.then(function () {
|
||||||
|
// When this callback runs, both "cy.request" API commands have finished
|
||||||
|
// and the test context has "user" and "post" objects set.
|
||||||
|
// Let's verify them.
|
||||||
|
expect(this.post, 'post has the right user id').property('userId').to.equal(this.user.id)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.intercept() - route responses to matching requests', () => {
|
||||||
|
// https://on.cypress.io/intercept
|
||||||
|
|
||||||
|
let message = 'whoa, this comment does not exist'
|
||||||
|
|
||||||
|
// Listen to GET to comments/1
|
||||||
|
cy.intercept('GET', '**/comments/*').as('getComment')
|
||||||
|
|
||||||
|
// we have code that gets a comment when
|
||||||
|
// the button is clicked in scripts.js
|
||||||
|
cy.get('.network-btn').click()
|
||||||
|
|
||||||
|
// https://on.cypress.io/wait
|
||||||
|
cy.wait('@getComment').its('response.statusCode').should('be.oneOf', [200, 304])
|
||||||
|
|
||||||
|
// Listen to POST to comments
|
||||||
|
cy.intercept('POST', '**/comments').as('postComment')
|
||||||
|
|
||||||
|
// we have code that posts a comment when
|
||||||
|
// the button is clicked in scripts.js
|
||||||
|
cy.get('.network-post').click()
|
||||||
|
cy.wait('@postComment').should(({ request, response }) => {
|
||||||
|
expect(request.body).to.include('email')
|
||||||
|
expect(request.headers).to.have.property('content-type')
|
||||||
|
expect(response && response.body).to.have.property('name', 'Using POST in cy.intercept()')
|
||||||
|
})
|
||||||
|
|
||||||
|
// Stub a response to PUT comments/ ****
|
||||||
|
cy.intercept({
|
||||||
|
method: 'PUT',
|
||||||
|
url: '**/comments/*',
|
||||||
|
}, {
|
||||||
|
statusCode: 404,
|
||||||
|
body: { error: message },
|
||||||
|
headers: { 'access-control-allow-origin': '*' },
|
||||||
|
delayMs: 500,
|
||||||
|
}).as('putComment')
|
||||||
|
|
||||||
|
// we have code that puts a comment when
|
||||||
|
// the button is clicked in scripts.js
|
||||||
|
cy.get('.network-put').click()
|
||||||
|
|
||||||
|
cy.wait('@putComment')
|
||||||
|
|
||||||
|
// our 404 statusCode logic in scripts.js executed
|
||||||
|
cy.get('.network-put-comment').should('contain', message)
|
||||||
|
})
|
||||||
|
})
|
||||||
114
client/cypress/integration/2-advanced-examples/querying.spec.js
Normal file
114
client/cypress/integration/2-advanced-examples/querying.spec.js
Normal file
@@ -0,0 +1,114 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
context('Querying', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/commands/querying')
|
||||||
|
})
|
||||||
|
|
||||||
|
// The most commonly used query is 'cy.get()', you can
|
||||||
|
// think of this like the '$' in jQuery
|
||||||
|
|
||||||
|
it('cy.get() - query DOM elements', () => {
|
||||||
|
// https://on.cypress.io/get
|
||||||
|
|
||||||
|
cy.get('#query-btn').should('contain', 'Button')
|
||||||
|
|
||||||
|
cy.get('.query-btn').should('contain', 'Button')
|
||||||
|
|
||||||
|
cy.get('#querying .well>button:first').should('contain', 'Button')
|
||||||
|
// ↲
|
||||||
|
// Use CSS selectors just like jQuery
|
||||||
|
|
||||||
|
cy.get('[data-test-id="test-example"]').should('have.class', 'example')
|
||||||
|
|
||||||
|
// 'cy.get()' yields jQuery object, you can get its attribute
|
||||||
|
// by invoking `.attr()` method
|
||||||
|
cy.get('[data-test-id="test-example"]')
|
||||||
|
.invoke('attr', 'data-test-id')
|
||||||
|
.should('equal', 'test-example')
|
||||||
|
|
||||||
|
// or you can get element's CSS property
|
||||||
|
cy.get('[data-test-id="test-example"]')
|
||||||
|
.invoke('css', 'position')
|
||||||
|
.should('equal', 'static')
|
||||||
|
|
||||||
|
// or use assertions directly during 'cy.get()'
|
||||||
|
// https://on.cypress.io/assertions
|
||||||
|
cy.get('[data-test-id="test-example"]')
|
||||||
|
.should('have.attr', 'data-test-id', 'test-example')
|
||||||
|
.and('have.css', 'position', 'static')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.contains() - query DOM elements with matching content', () => {
|
||||||
|
// https://on.cypress.io/contains
|
||||||
|
cy.get('.query-list')
|
||||||
|
.contains('bananas')
|
||||||
|
.should('have.class', 'third')
|
||||||
|
|
||||||
|
// we can pass a regexp to `.contains()`
|
||||||
|
cy.get('.query-list')
|
||||||
|
.contains(/^b\w+/)
|
||||||
|
.should('have.class', 'third')
|
||||||
|
|
||||||
|
cy.get('.query-list')
|
||||||
|
.contains('apples')
|
||||||
|
.should('have.class', 'first')
|
||||||
|
|
||||||
|
// passing a selector to contains will
|
||||||
|
// yield the selector containing the text
|
||||||
|
cy.get('#querying')
|
||||||
|
.contains('ul', 'oranges')
|
||||||
|
.should('have.class', 'query-list')
|
||||||
|
|
||||||
|
cy.get('.query-button')
|
||||||
|
.contains('Save Form')
|
||||||
|
.should('have.class', 'btn')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.within() - query DOM elements within a specific element', () => {
|
||||||
|
// https://on.cypress.io/within
|
||||||
|
cy.get('.query-form').within(() => {
|
||||||
|
cy.get('input:first').should('have.attr', 'placeholder', 'Email')
|
||||||
|
cy.get('input:last').should('have.attr', 'placeholder', 'Password')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.root() - query the root DOM element', () => {
|
||||||
|
// https://on.cypress.io/root
|
||||||
|
|
||||||
|
// By default, root is the document
|
||||||
|
cy.root().should('match', 'html')
|
||||||
|
|
||||||
|
cy.get('.query-ul').within(() => {
|
||||||
|
// In this within, the root is now the ul DOM element
|
||||||
|
cy.root().should('have.class', 'query-ul')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('best practices - selecting elements', () => {
|
||||||
|
// https://on.cypress.io/best-practices#Selecting-Elements
|
||||||
|
cy.get('[data-cy=best-practices-selecting-elements]').within(() => {
|
||||||
|
// Worst - too generic, no context
|
||||||
|
cy.get('button').click()
|
||||||
|
|
||||||
|
// Bad. Coupled to styling. Highly subject to change.
|
||||||
|
cy.get('.btn.btn-large').click()
|
||||||
|
|
||||||
|
// Average. Coupled to the `name` attribute which has HTML semantics.
|
||||||
|
cy.get('[name=submission]').click()
|
||||||
|
|
||||||
|
// Better. But still coupled to styling or JS event listeners.
|
||||||
|
cy.get('#main').click()
|
||||||
|
|
||||||
|
// Slightly better. Uses an ID but also ensures the element
|
||||||
|
// has an ARIA role attribute
|
||||||
|
cy.get('#main[role=button]').click()
|
||||||
|
|
||||||
|
// Much better. But still coupled to text content that may change.
|
||||||
|
cy.contains('Submit').click()
|
||||||
|
|
||||||
|
// Best. Insulated from all changes.
|
||||||
|
cy.get('[data-cy=submit]').click()
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,205 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
// remove no check once Cypress.sinon is typed
|
||||||
|
// https://github.com/cypress-io/cypress/issues/6720
|
||||||
|
|
||||||
|
context('Spies, Stubs, and Clock', () => {
|
||||||
|
it('cy.spy() - wrap a method in a spy', () => {
|
||||||
|
// https://on.cypress.io/spy
|
||||||
|
cy.visit('https://example.cypress.io/commands/spies-stubs-clocks')
|
||||||
|
|
||||||
|
const obj = {
|
||||||
|
foo () {},
|
||||||
|
}
|
||||||
|
|
||||||
|
const spy = cy.spy(obj, 'foo').as('anyArgs')
|
||||||
|
|
||||||
|
obj.foo()
|
||||||
|
|
||||||
|
expect(spy).to.be.called
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.spy() retries until assertions pass', () => {
|
||||||
|
cy.visit('https://example.cypress.io/commands/spies-stubs-clocks')
|
||||||
|
|
||||||
|
const obj = {
|
||||||
|
/**
|
||||||
|
* Prints the argument passed
|
||||||
|
* @param x {any}
|
||||||
|
*/
|
||||||
|
foo (x) {
|
||||||
|
console.log('obj.foo called with', x)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
cy.spy(obj, 'foo').as('foo')
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
obj.foo('first')
|
||||||
|
}, 500)
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
obj.foo('second')
|
||||||
|
}, 2500)
|
||||||
|
|
||||||
|
cy.get('@foo').should('have.been.calledTwice')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.stub() - create a stub and/or replace a function with stub', () => {
|
||||||
|
// https://on.cypress.io/stub
|
||||||
|
cy.visit('https://example.cypress.io/commands/spies-stubs-clocks')
|
||||||
|
|
||||||
|
const obj = {
|
||||||
|
/**
|
||||||
|
* prints both arguments to the console
|
||||||
|
* @param a {string}
|
||||||
|
* @param b {string}
|
||||||
|
*/
|
||||||
|
foo (a, b) {
|
||||||
|
console.log('a', a, 'b', b)
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const stub = cy.stub(obj, 'foo').as('foo')
|
||||||
|
|
||||||
|
obj.foo('foo', 'bar')
|
||||||
|
|
||||||
|
expect(stub).to.be.called
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.clock() - control time in the browser', () => {
|
||||||
|
// https://on.cypress.io/clock
|
||||||
|
|
||||||
|
// create the date in UTC so its always the same
|
||||||
|
// no matter what local timezone the browser is running in
|
||||||
|
const now = new Date(Date.UTC(2017, 2, 14)).getTime()
|
||||||
|
|
||||||
|
cy.clock(now)
|
||||||
|
cy.visit('https://example.cypress.io/commands/spies-stubs-clocks')
|
||||||
|
cy.get('#clock-div').click()
|
||||||
|
.should('have.text', '1489449600')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.tick() - move time in the browser', () => {
|
||||||
|
// https://on.cypress.io/tick
|
||||||
|
|
||||||
|
// create the date in UTC so its always the same
|
||||||
|
// no matter what local timezone the browser is running in
|
||||||
|
const now = new Date(Date.UTC(2017, 2, 14)).getTime()
|
||||||
|
|
||||||
|
cy.clock(now)
|
||||||
|
cy.visit('https://example.cypress.io/commands/spies-stubs-clocks')
|
||||||
|
cy.get('#tick-div').click()
|
||||||
|
.should('have.text', '1489449600')
|
||||||
|
|
||||||
|
cy.tick(10000) // 10 seconds passed
|
||||||
|
cy.get('#tick-div').click()
|
||||||
|
.should('have.text', '1489449610')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.stub() matches depending on arguments', () => {
|
||||||
|
// see all possible matchers at
|
||||||
|
// https://sinonjs.org/releases/latest/matchers/
|
||||||
|
const greeter = {
|
||||||
|
/**
|
||||||
|
* Greets a person
|
||||||
|
* @param {string} name
|
||||||
|
*/
|
||||||
|
greet (name) {
|
||||||
|
return `Hello, ${name}!`
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
cy.stub(greeter, 'greet')
|
||||||
|
.callThrough() // if you want non-matched calls to call the real method
|
||||||
|
.withArgs(Cypress.sinon.match.string).returns('Hi')
|
||||||
|
.withArgs(Cypress.sinon.match.number).throws(new Error('Invalid name'))
|
||||||
|
|
||||||
|
expect(greeter.greet('World')).to.equal('Hi')
|
||||||
|
// @ts-ignore
|
||||||
|
expect(() => greeter.greet(42)).to.throw('Invalid name')
|
||||||
|
expect(greeter.greet).to.have.been.calledTwice
|
||||||
|
|
||||||
|
// non-matched calls goes the actual method
|
||||||
|
// @ts-ignore
|
||||||
|
expect(greeter.greet()).to.equal('Hello, undefined!')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('matches call arguments using Sinon matchers', () => {
|
||||||
|
// see all possible matchers at
|
||||||
|
// https://sinonjs.org/releases/latest/matchers/
|
||||||
|
const calculator = {
|
||||||
|
/**
|
||||||
|
* returns the sum of two arguments
|
||||||
|
* @param a {number}
|
||||||
|
* @param b {number}
|
||||||
|
*/
|
||||||
|
add (a, b) {
|
||||||
|
return a + b
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
const spy = cy.spy(calculator, 'add').as('add')
|
||||||
|
|
||||||
|
expect(calculator.add(2, 3)).to.equal(5)
|
||||||
|
|
||||||
|
// if we want to assert the exact values used during the call
|
||||||
|
expect(spy).to.be.calledWith(2, 3)
|
||||||
|
|
||||||
|
// let's confirm "add" method was called with two numbers
|
||||||
|
expect(spy).to.be.calledWith(Cypress.sinon.match.number, Cypress.sinon.match.number)
|
||||||
|
|
||||||
|
// alternatively, provide the value to match
|
||||||
|
expect(spy).to.be.calledWith(Cypress.sinon.match(2), Cypress.sinon.match(3))
|
||||||
|
|
||||||
|
// match any value
|
||||||
|
expect(spy).to.be.calledWith(Cypress.sinon.match.any, 3)
|
||||||
|
|
||||||
|
// match any value from a list
|
||||||
|
expect(spy).to.be.calledWith(Cypress.sinon.match.in([1, 2, 3]), 3)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if the given number is event
|
||||||
|
* @param {number} x
|
||||||
|
*/
|
||||||
|
const isEven = (x) => x % 2 === 0
|
||||||
|
|
||||||
|
// expect the value to pass a custom predicate function
|
||||||
|
// the second argument to "sinon.match(predicate, message)" is
|
||||||
|
// shown if the predicate does not pass and assertion fails
|
||||||
|
expect(spy).to.be.calledWith(Cypress.sinon.match(isEven, 'isEven'), 3)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a function that checks if a given number is larger than the limit
|
||||||
|
* @param {number} limit
|
||||||
|
* @returns {(x: number) => boolean}
|
||||||
|
*/
|
||||||
|
const isGreaterThan = (limit) => (x) => x > limit
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a function that checks if a given number is less than the limit
|
||||||
|
* @param {number} limit
|
||||||
|
* @returns {(x: number) => boolean}
|
||||||
|
*/
|
||||||
|
const isLessThan = (limit) => (x) => x < limit
|
||||||
|
|
||||||
|
// you can combine several matchers using "and", "or"
|
||||||
|
expect(spy).to.be.calledWith(
|
||||||
|
Cypress.sinon.match.number,
|
||||||
|
Cypress.sinon.match(isGreaterThan(2), '> 2').and(Cypress.sinon.match(isLessThan(4), '< 4')),
|
||||||
|
)
|
||||||
|
|
||||||
|
expect(spy).to.be.calledWith(
|
||||||
|
Cypress.sinon.match.number,
|
||||||
|
Cypress.sinon.match(isGreaterThan(200), '> 200').or(Cypress.sinon.match(3)),
|
||||||
|
)
|
||||||
|
|
||||||
|
// matchers can be used from BDD assertions
|
||||||
|
cy.get('@add').should('have.been.calledWith',
|
||||||
|
Cypress.sinon.match.number, Cypress.sinon.match(3))
|
||||||
|
|
||||||
|
// you can alias matchers for shorter test code
|
||||||
|
const { match: M } = Cypress.sinon
|
||||||
|
|
||||||
|
cy.get('@add').should('have.been.calledWith', M.number, M(3))
|
||||||
|
})
|
||||||
|
})
|
||||||
121
client/cypress/integration/2-advanced-examples/traversal.spec.js
Normal file
121
client/cypress/integration/2-advanced-examples/traversal.spec.js
Normal file
@@ -0,0 +1,121 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
context('Traversal', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/commands/traversal')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.children() - get child DOM elements', () => {
|
||||||
|
// https://on.cypress.io/children
|
||||||
|
cy.get('.traversal-breadcrumb')
|
||||||
|
.children('.active')
|
||||||
|
.should('contain', 'Data')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.closest() - get closest ancestor DOM element', () => {
|
||||||
|
// https://on.cypress.io/closest
|
||||||
|
cy.get('.traversal-badge')
|
||||||
|
.closest('ul')
|
||||||
|
.should('have.class', 'list-group')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.eq() - get a DOM element at a specific index', () => {
|
||||||
|
// https://on.cypress.io/eq
|
||||||
|
cy.get('.traversal-list>li')
|
||||||
|
.eq(1).should('contain', 'siamese')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.filter() - get DOM elements that match the selector', () => {
|
||||||
|
// https://on.cypress.io/filter
|
||||||
|
cy.get('.traversal-nav>li')
|
||||||
|
.filter('.active').should('contain', 'About')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.find() - get descendant DOM elements of the selector', () => {
|
||||||
|
// https://on.cypress.io/find
|
||||||
|
cy.get('.traversal-pagination')
|
||||||
|
.find('li').find('a')
|
||||||
|
.should('have.length', 7)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.first() - get first DOM element', () => {
|
||||||
|
// https://on.cypress.io/first
|
||||||
|
cy.get('.traversal-table td')
|
||||||
|
.first().should('contain', '1')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.last() - get last DOM element', () => {
|
||||||
|
// https://on.cypress.io/last
|
||||||
|
cy.get('.traversal-buttons .btn')
|
||||||
|
.last().should('contain', 'Submit')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.next() - get next sibling DOM element', () => {
|
||||||
|
// https://on.cypress.io/next
|
||||||
|
cy.get('.traversal-ul')
|
||||||
|
.contains('apples').next().should('contain', 'oranges')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.nextAll() - get all next sibling DOM elements', () => {
|
||||||
|
// https://on.cypress.io/nextall
|
||||||
|
cy.get('.traversal-next-all')
|
||||||
|
.contains('oranges')
|
||||||
|
.nextAll().should('have.length', 3)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.nextUntil() - get next sibling DOM elements until next el', () => {
|
||||||
|
// https://on.cypress.io/nextuntil
|
||||||
|
cy.get('#veggies')
|
||||||
|
.nextUntil('#nuts').should('have.length', 3)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.not() - remove DOM elements from set of DOM elements', () => {
|
||||||
|
// https://on.cypress.io/not
|
||||||
|
cy.get('.traversal-disabled .btn')
|
||||||
|
.not('[disabled]').should('not.contain', 'Disabled')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.parent() - get parent DOM element from DOM elements', () => {
|
||||||
|
// https://on.cypress.io/parent
|
||||||
|
cy.get('.traversal-mark')
|
||||||
|
.parent().should('contain', 'Morbi leo risus')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.parents() - get parent DOM elements from DOM elements', () => {
|
||||||
|
// https://on.cypress.io/parents
|
||||||
|
cy.get('.traversal-cite')
|
||||||
|
.parents().should('match', 'blockquote')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.parentsUntil() - get parent DOM elements from DOM elements until el', () => {
|
||||||
|
// https://on.cypress.io/parentsuntil
|
||||||
|
cy.get('.clothes-nav')
|
||||||
|
.find('.active')
|
||||||
|
.parentsUntil('.clothes-nav')
|
||||||
|
.should('have.length', 2)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.prev() - get previous sibling DOM element', () => {
|
||||||
|
// https://on.cypress.io/prev
|
||||||
|
cy.get('.birds').find('.active')
|
||||||
|
.prev().should('contain', 'Lorikeets')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.prevAll() - get all previous sibling DOM elements', () => {
|
||||||
|
// https://on.cypress.io/prevall
|
||||||
|
cy.get('.fruits-list').find('.third')
|
||||||
|
.prevAll().should('have.length', 2)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.prevUntil() - get all previous sibling DOM elements until el', () => {
|
||||||
|
// https://on.cypress.io/prevuntil
|
||||||
|
cy.get('.foods-list').find('#nuts')
|
||||||
|
.prevUntil('#veggies').should('have.length', 3)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('.siblings() - get all sibling DOM elements', () => {
|
||||||
|
// https://on.cypress.io/siblings
|
||||||
|
cy.get('.traversal-pills .active')
|
||||||
|
.siblings().should('have.length', 2)
|
||||||
|
})
|
||||||
|
})
|
||||||
110
client/cypress/integration/2-advanced-examples/utilities.spec.js
Normal file
110
client/cypress/integration/2-advanced-examples/utilities.spec.js
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
context('Utilities', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/utilities')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Cypress._ - call a lodash method', () => {
|
||||||
|
// https://on.cypress.io/_
|
||||||
|
cy.request('https://jsonplaceholder.cypress.io/users')
|
||||||
|
.then((response) => {
|
||||||
|
let ids = Cypress._.chain(response.body).map('id').take(3).value()
|
||||||
|
|
||||||
|
expect(ids).to.deep.eq([1, 2, 3])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Cypress.$ - call a jQuery method', () => {
|
||||||
|
// https://on.cypress.io/$
|
||||||
|
let $li = Cypress.$('.utility-jquery li:first')
|
||||||
|
|
||||||
|
cy.wrap($li)
|
||||||
|
.should('not.have.class', 'active')
|
||||||
|
.click()
|
||||||
|
.should('have.class', 'active')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Cypress.Blob - blob utilities and base64 string conversion', () => {
|
||||||
|
// https://on.cypress.io/blob
|
||||||
|
cy.get('.utility-blob').then(($div) => {
|
||||||
|
// https://github.com/nolanlawson/blob-util#imgSrcToDataURL
|
||||||
|
// get the dataUrl string for the javascript-logo
|
||||||
|
return Cypress.Blob.imgSrcToDataURL('https://example.cypress.io/assets/img/javascript-logo.png', undefined, 'anonymous')
|
||||||
|
.then((dataUrl) => {
|
||||||
|
// create an <img> element and set its src to the dataUrl
|
||||||
|
let img = Cypress.$('<img />', { src: dataUrl })
|
||||||
|
|
||||||
|
// need to explicitly return cy here since we are initially returning
|
||||||
|
// the Cypress.Blob.imgSrcToDataURL promise to our test
|
||||||
|
// append the image
|
||||||
|
$div.append(img)
|
||||||
|
|
||||||
|
cy.get('.utility-blob img').click()
|
||||||
|
.should('have.attr', 'src', dataUrl)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Cypress.minimatch - test out glob patterns against strings', () => {
|
||||||
|
// https://on.cypress.io/minimatch
|
||||||
|
let matching = Cypress.minimatch('/users/1/comments', '/users/*/comments', {
|
||||||
|
matchBase: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(matching, 'matching wildcard').to.be.true
|
||||||
|
|
||||||
|
matching = Cypress.minimatch('/users/1/comments/2', '/users/*/comments', {
|
||||||
|
matchBase: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(matching, 'comments').to.be.false
|
||||||
|
|
||||||
|
// ** matches against all downstream path segments
|
||||||
|
matching = Cypress.minimatch('/foo/bar/baz/123/quux?a=b&c=2', '/foo/**', {
|
||||||
|
matchBase: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(matching, 'comments').to.be.true
|
||||||
|
|
||||||
|
// whereas * matches only the next path segment
|
||||||
|
|
||||||
|
matching = Cypress.minimatch('/foo/bar/baz/123/quux?a=b&c=2', '/foo/*', {
|
||||||
|
matchBase: false,
|
||||||
|
})
|
||||||
|
|
||||||
|
expect(matching, 'comments').to.be.false
|
||||||
|
})
|
||||||
|
|
||||||
|
it('Cypress.Promise - instantiate a bluebird promise', () => {
|
||||||
|
// https://on.cypress.io/promise
|
||||||
|
let waited = false
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Bluebird<string>
|
||||||
|
*/
|
||||||
|
function waitOneSecond () {
|
||||||
|
// return a promise that resolves after 1 second
|
||||||
|
// @ts-ignore TS2351 (new Cypress.Promise)
|
||||||
|
return new Cypress.Promise((resolve, reject) => {
|
||||||
|
setTimeout(() => {
|
||||||
|
// set waited to true
|
||||||
|
waited = true
|
||||||
|
|
||||||
|
// resolve with 'foo' string
|
||||||
|
resolve('foo')
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
cy.then(() => {
|
||||||
|
// return a promise to cy.then() that
|
||||||
|
// is awaited until it resolves
|
||||||
|
// @ts-ignore TS7006
|
||||||
|
return waitOneSecond().then((str) => {
|
||||||
|
expect(str).to.eq('foo')
|
||||||
|
expect(waited).to.be.true
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,59 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
context('Viewport', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/commands/viewport')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.viewport() - set the viewport size and dimension', () => {
|
||||||
|
// https://on.cypress.io/viewport
|
||||||
|
|
||||||
|
cy.get('#navbar').should('be.visible')
|
||||||
|
cy.viewport(320, 480)
|
||||||
|
|
||||||
|
// the navbar should have collapse since our screen is smaller
|
||||||
|
cy.get('#navbar').should('not.be.visible')
|
||||||
|
cy.get('.navbar-toggle').should('be.visible').click()
|
||||||
|
cy.get('.nav').find('a').should('be.visible')
|
||||||
|
|
||||||
|
// lets see what our app looks like on a super large screen
|
||||||
|
cy.viewport(2999, 2999)
|
||||||
|
|
||||||
|
// cy.viewport() accepts a set of preset sizes
|
||||||
|
// to easily set the screen to a device's width and height
|
||||||
|
|
||||||
|
// We added a cy.wait() between each viewport change so you can see
|
||||||
|
// the change otherwise it is a little too fast to see :)
|
||||||
|
|
||||||
|
cy.viewport('macbook-15')
|
||||||
|
cy.wait(200)
|
||||||
|
cy.viewport('macbook-13')
|
||||||
|
cy.wait(200)
|
||||||
|
cy.viewport('macbook-11')
|
||||||
|
cy.wait(200)
|
||||||
|
cy.viewport('ipad-2')
|
||||||
|
cy.wait(200)
|
||||||
|
cy.viewport('ipad-mini')
|
||||||
|
cy.wait(200)
|
||||||
|
cy.viewport('iphone-6+')
|
||||||
|
cy.wait(200)
|
||||||
|
cy.viewport('iphone-6')
|
||||||
|
cy.wait(200)
|
||||||
|
cy.viewport('iphone-5')
|
||||||
|
cy.wait(200)
|
||||||
|
cy.viewport('iphone-4')
|
||||||
|
cy.wait(200)
|
||||||
|
cy.viewport('iphone-3')
|
||||||
|
cy.wait(200)
|
||||||
|
|
||||||
|
// cy.viewport() accepts an orientation for all presets
|
||||||
|
// the default orientation is 'portrait'
|
||||||
|
cy.viewport('ipad-2', 'portrait')
|
||||||
|
cy.wait(200)
|
||||||
|
cy.viewport('iphone-4', 'landscape')
|
||||||
|
cy.wait(200)
|
||||||
|
|
||||||
|
// The viewport will be reset back to the default dimensions
|
||||||
|
// in between tests (the default can be set in cypress.json)
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
context('Waiting', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/commands/waiting')
|
||||||
|
})
|
||||||
|
// BE CAREFUL of adding unnecessary wait times.
|
||||||
|
// https://on.cypress.io/best-practices#Unnecessary-Waiting
|
||||||
|
|
||||||
|
// https://on.cypress.io/wait
|
||||||
|
it('cy.wait() - wait for a specific amount of time', () => {
|
||||||
|
cy.get('.wait-input1').type('Wait 1000ms after typing')
|
||||||
|
cy.wait(1000)
|
||||||
|
cy.get('.wait-input2').type('Wait 1000ms after typing')
|
||||||
|
cy.wait(1000)
|
||||||
|
cy.get('.wait-input3').type('Wait 1000ms after typing')
|
||||||
|
cy.wait(1000)
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.wait() - wait for a specific route', () => {
|
||||||
|
// Listen to GET to comments/1
|
||||||
|
cy.intercept('GET', '**/comments/*').as('getComment')
|
||||||
|
|
||||||
|
// we have code that gets a comment when
|
||||||
|
// the button is clicked in scripts.js
|
||||||
|
cy.get('.network-btn').click()
|
||||||
|
|
||||||
|
// wait for GET comments/1
|
||||||
|
cy.wait('@getComment').its('response.statusCode').should('be.oneOf', [200, 304])
|
||||||
|
})
|
||||||
|
})
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
|
||||||
|
context('Window', () => {
|
||||||
|
beforeEach(() => {
|
||||||
|
cy.visit('https://example.cypress.io/commands/window')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.window() - get the global window object', () => {
|
||||||
|
// https://on.cypress.io/window
|
||||||
|
cy.window().should('have.property', 'top')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.document() - get the document object', () => {
|
||||||
|
// https://on.cypress.io/document
|
||||||
|
cy.document().should('have.property', 'charset').and('eq', 'UTF-8')
|
||||||
|
})
|
||||||
|
|
||||||
|
it('cy.title() - get the title', () => {
|
||||||
|
// https://on.cypress.io/title
|
||||||
|
cy.title().should('include', 'Kitchen Sink')
|
||||||
|
})
|
||||||
|
})
|
||||||
22
client/cypress/plugins/index.js
Normal file
22
client/cypress/plugins/index.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
/// <reference types="cypress" />
|
||||||
|
// ***********************************************************
|
||||||
|
// This example plugins/index.js can be used to load plugins
|
||||||
|
//
|
||||||
|
// You can change the location of this file or turn off loading
|
||||||
|
// the plugins file with the 'pluginsFile' configuration option.
|
||||||
|
//
|
||||||
|
// You can read more here:
|
||||||
|
// https://on.cypress.io/plugins-guide
|
||||||
|
// ***********************************************************
|
||||||
|
|
||||||
|
// This function is called when a project is opened or re-opened (e.g. due to
|
||||||
|
// the project's config changing)
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Cypress.PluginConfig}
|
||||||
|
*/
|
||||||
|
// eslint-disable-next-line no-unused-vars
|
||||||
|
module.exports = (on, config) => {
|
||||||
|
// `on` is used to hook into various events Cypress emits
|
||||||
|
// `config` is the resolved Cypress config
|
||||||
|
}
|
||||||
@@ -22,4 +22,6 @@
|
|||||||
//
|
//
|
||||||
//
|
//
|
||||||
// -- This will overwrite an existing command --
|
// -- This will overwrite an existing command --
|
||||||
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })
|
||||||
|
|
||||||
|
import "@testing-library/cypress/add-commands";
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
// ***********************************************************
|
// ***********************************************************
|
||||||
// This example support/e2e.js is processed and
|
// This example support/index.js is processed and
|
||||||
// loaded automatically before your test files.
|
// loaded automatically before your test files.
|
||||||
//
|
//
|
||||||
// This is a great place to put global configuration and
|
// This is a great place to put global configuration and
|
||||||
@@ -17,4 +17,4 @@
|
|||||||
import './commands'
|
import './commands'
|
||||||
|
|
||||||
// Alternatively you can use CommonJS syntax:
|
// Alternatively you can use CommonJS syntax:
|
||||||
// require('./commands')
|
// require('./commands')
|
||||||
8
client/cypress/tsconfig.json
Normal file
8
client/cypress/tsconfig.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"allowJs": true,
|
||||||
|
"baseUrl": "../node_modules",
|
||||||
|
"types": ["cypress"]
|
||||||
|
},
|
||||||
|
"include": ["**/*.*"]
|
||||||
|
}
|
||||||
@@ -4,70 +4,70 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"proxy": "http://localhost:4000",
|
"proxy": "http://localhost:4000",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@apollo/client": "^3.6.9",
|
"@apollo/client": "^3.7.9",
|
||||||
"@asseinfo/react-kanban": "^2.2.0",
|
"@asseinfo/react-kanban": "^2.2.0",
|
||||||
"@craco/craco": "^6.4.5",
|
"@craco/craco": "^7.0.0",
|
||||||
"@fingerprintjs/fingerprintjs": "^3.3.3",
|
"@fingerprintjs/fingerprintjs": "^3.3.3",
|
||||||
"@jsreport/browser-client": "^3.1.0",
|
"@jsreport/browser-client": "^3.1.0",
|
||||||
"@sentry/react": "^7.7.0",
|
"@sentry/react": "^7.40.0",
|
||||||
"@sentry/tracing": "^7.7.0",
|
"@sentry/tracing": "^7.40.0",
|
||||||
"@splitsoftware/splitio-react": "^1.6.0",
|
"@splitsoftware/splitio-react": "^1.8.1",
|
||||||
"@stripe/react-stripe-js": "^1.9.0",
|
|
||||||
"@stripe/stripe-js": "^1.32.0",
|
|
||||||
"@tanem/react-nprogress": "^5.0.8",
|
"@tanem/react-nprogress": "^5.0.8",
|
||||||
"antd": "^4.22.3",
|
"antd": "^4.24.8",
|
||||||
"apollo-link-logger": "^2.0.0",
|
"apollo-link-logger": "^2.0.1",
|
||||||
"axios": "^0.27.2",
|
"axios": "^1.3.4",
|
||||||
"craco-less": "^1.20.0",
|
"craco-less": "^2.0.0",
|
||||||
"dinero.js": "^1.9.1",
|
"dinero.js": "^1.9.1",
|
||||||
|
"dotenv": "^16.0.1",
|
||||||
"enquire-js": "^0.2.1",
|
"enquire-js": "^0.2.1",
|
||||||
"env-cmd": "^10.1.0",
|
"env-cmd": "^10.1.0",
|
||||||
"exifr": "^7.1.3",
|
"exifr": "^7.1.3",
|
||||||
"firebase": "^9.9.1",
|
"firebase": "^9.17.1",
|
||||||
"graphql": "^16.5.0",
|
"graphql": "^16.6.0",
|
||||||
"i18next": "^21.8.14",
|
"i18next": "^22.4.10",
|
||||||
"i18next-browser-languagedetector": "^6.1.4",
|
"i18next-browser-languagedetector": "^7.0.1",
|
||||||
"jsoneditor": "^9.9.0",
|
"jsoneditor": "^9.9.0",
|
||||||
"jsreport-browser-client-dist": "^1.3.0",
|
"jsreport-browser-client-dist": "^1.3.0",
|
||||||
"libphonenumber-js": "^1.10.9",
|
"libphonenumber-js": "^1.10.21",
|
||||||
"logrocket": "^3.0.1",
|
"logrocket": "^3.0.1",
|
||||||
"markerjs2": "^2.22.0",
|
"markerjs2": "^2.28.1",
|
||||||
"moment-business-days": "^1.2.0",
|
"moment-business-days": "^1.2.0",
|
||||||
"moment-timezone": "^0.5.34",
|
"moment-timezone": "^0.5.41",
|
||||||
"normalize-url": "^7.0.3",
|
"normalize-url": "^8.0.0",
|
||||||
"phone": "^3.1.23",
|
"phone": "^3.1.35",
|
||||||
"preval.macro": "^5.0.0",
|
"preval.macro": "^5.0.0",
|
||||||
"prop-types": "^15.8.1",
|
"prop-types": "^15.8.1",
|
||||||
"query-string": "^7.1.1",
|
"query-string": "^7.1.3",
|
||||||
"rc-queue-anim": "^2.0.0",
|
"rc-queue-anim": "^2.0.0",
|
||||||
"rc-scroll-anim": "^2.7.6",
|
"rc-scroll-anim": "^2.7.6",
|
||||||
"react": "^17.0.2",
|
"react": "^17.0.2",
|
||||||
"react-big-calendar": "^1.5.0",
|
"react-big-calendar": "^1.6.8",
|
||||||
"react-color": "^2.19.3",
|
"react-color": "^2.19.3",
|
||||||
"react-cookie": "^4.1.1",
|
"react-cookie": "^4.1.1",
|
||||||
"react-dom": "^17.0.2",
|
"react-dom": "^17.0.2",
|
||||||
"react-drag-listview": "^0.2.1",
|
"react-drag-listview": "^0.2.1",
|
||||||
"react-grid-gallery": "^0.5.5",
|
"react-grid-gallery": "^1.0.0",
|
||||||
"react-grid-layout": "^1.3.4",
|
"react-grid-layout": "^1.3.4",
|
||||||
"react-i18next": "^11.18.1",
|
"react-i18next": "^12.2.0",
|
||||||
"react-icons": "^4.4.0",
|
"react-icons": "^4.7.1",
|
||||||
"react-number-format": "^4.9.3",
|
"react-image-lightbox": "^5.1.4",
|
||||||
"react-redux": "^7.2.8",
|
"react-number-format": "^5.1.3",
|
||||||
|
"react-redux": "^8.0.5",
|
||||||
"react-resizable": "^3.0.4",
|
"react-resizable": "^3.0.4",
|
||||||
"react-router-dom": "^5.3.0",
|
"react-router-dom": "^5.3.0",
|
||||||
"react-scripts": "^4.0.3",
|
"react-scripts": "^5.0.1",
|
||||||
"react-sticky": "^6.0.3",
|
"react-sticky": "^6.0.3",
|
||||||
"react-sublime-video": "^0.2.5",
|
"react-sublime-video": "^0.2.5",
|
||||||
"react-virtualized": "^9.22.3",
|
"react-virtualized": "^9.22.3",
|
||||||
"recharts": "^2.1.12",
|
"recharts": "^2.4.3",
|
||||||
"redux": "^4.2.0",
|
"redux": "^4.2.1",
|
||||||
"redux-persist": "^6.0.0",
|
"redux-persist": "^6.0.0",
|
||||||
"redux-saga": "^1.1.3",
|
"redux-saga": "^1.2.2",
|
||||||
"redux-state-sync": "^3.1.4",
|
"redux-state-sync": "^3.1.4",
|
||||||
"reselect": "^4.1.6",
|
"reselect": "^4.1.7",
|
||||||
"sass": "^1.54.0",
|
"sass": "^1.58.3",
|
||||||
"socket.io-client": "^4.5.1",
|
"socket.io-client": "^4.6.1",
|
||||||
"styled-components": "^5.3.5",
|
"styled-components": "^5.3.6",
|
||||||
"subscriptions-transport-ws": "^0.11.0",
|
"subscriptions-transport-ws": "^0.11.0",
|
||||||
"web-vitals": "^2.1.4",
|
"web-vitals": "^2.1.4",
|
||||||
"workbox-background-sync": "^6.5.3",
|
"workbox-background-sync": "^6.5.3",
|
||||||
@@ -81,7 +81,8 @@
|
|||||||
"workbox-range-requests": "^6.5.3",
|
"workbox-range-requests": "^6.5.3",
|
||||||
"workbox-routing": "^6.5.3",
|
"workbox-routing": "^6.5.3",
|
||||||
"workbox-strategies": "^6.5.3",
|
"workbox-strategies": "^6.5.3",
|
||||||
"workbox-streams": "^6.5.3"
|
"workbox-streams": "^6.5.3",
|
||||||
|
"yauzl": "^2.10.0"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"analyze": "source-map-explorer 'build/static/js/*.js'",
|
"analyze": "source-map-explorer 'build/static/js/*.js'",
|
||||||
@@ -91,7 +92,8 @@
|
|||||||
"build-deploy:test": "yarn run build:test && s3cmd sync build/* s3://imex-online-test && echo '🚀 TESTING Deployed!'",
|
"build-deploy:test": "yarn run build:test && s3cmd sync build/* s3://imex-online-test && echo '🚀 TESTING Deployed!'",
|
||||||
"buildcra": "REACT_APP_GIT_SHA=`git rev-parse --short HEAD` craco build",
|
"buildcra": "REACT_APP_GIT_SHA=`git rev-parse --short HEAD` craco build",
|
||||||
"test": "cypress open",
|
"test": "cypress open",
|
||||||
"eject": "react-scripts eject"
|
"eject": "react-scripts eject",
|
||||||
|
"madge": "madge --image ./madge-graph.svg --extensions js,jsx,ts,tsx --circular ."
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
"extends": [
|
"extends": [
|
||||||
@@ -116,8 +118,9 @@
|
|||||||
"react-error-overlay": "6.0.9"
|
"react-error-overlay": "6.0.9"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@sentry/webpack-plugin": "^1.19.0",
|
"@sentry/webpack-plugin": "^1.20.0",
|
||||||
"cypress": "^12.2.0",
|
"@testing-library/cypress": "^8.0.3",
|
||||||
|
"cypress": "^10.3.1",
|
||||||
"eslint-plugin-cypress": "^2.12.1",
|
"eslint-plugin-cypress": "^2.12.1",
|
||||||
"react-error-overlay": "6.0.11",
|
"react-error-overlay": "6.0.11",
|
||||||
"redux-logger": "^3.0.6",
|
"redux-logger": "^3.0.6",
|
||||||
|
|||||||
13087
client/patches/peerjs+1.3.2.patch
Normal file
13087
client/patches/peerjs+1.3.2.patch
Normal file
File diff suppressed because one or more lines are too long
@@ -143,8 +143,16 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Update row highlighting on production board.
|
||||||
//Update row highlighting on production board.
|
|
||||||
.ant-table-tbody > tr.ant-table-row:hover > td {
|
.ant-table-tbody > tr.ant-table-row:hover > td {
|
||||||
background: #eaeaea !important;
|
background: #eaeaea !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.job-line-manual {
|
||||||
|
color: tomato;
|
||||||
|
font-style: italic;
|
||||||
|
}
|
||||||
|
|
||||||
|
td.ant-table-column-sort {
|
||||||
|
background-color: transparent;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
import {
|
import React from "react";
|
||||||
PaymentRequestButtonElement,
|
|
||||||
useStripe,
|
|
||||||
} from "@stripe/react-stripe-js";
|
|
||||||
import React, { useEffect, useState } from "react";
|
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||||
@@ -19,49 +15,6 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
});
|
});
|
||||||
|
|
||||||
function Test({ bodyshop, setEmailOptions }) {
|
function Test({ bodyshop, setEmailOptions }) {
|
||||||
const stripe = useStripe();
|
|
||||||
|
|
||||||
const [paymentRequest, setPaymentRequest] = useState(null);
|
|
||||||
useEffect(() => {
|
|
||||||
if (stripe) {
|
|
||||||
const pr = stripe.paymentRequest({
|
|
||||||
country: "CA",
|
|
||||||
displayItems: [{ label: "Deductible", amount: 1099 }],
|
|
||||||
currency: "cad",
|
|
||||||
total: {
|
|
||||||
label: "Demo total",
|
|
||||||
amount: 1099,
|
|
||||||
},
|
|
||||||
requestPayerName: true,
|
|
||||||
requestPayerEmail: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Check the availability of the Payment Request API.
|
|
||||||
pr.canMakePayment().then((result) => {
|
|
||||||
if (result) {
|
|
||||||
setPaymentRequest(pr);
|
|
||||||
} else {
|
|
||||||
// var details = {
|
|
||||||
// total: { label: "", amount: { currency: "CAD", value: "0.00" } },
|
|
||||||
// };
|
|
||||||
new PaymentRequest(
|
|
||||||
[{ supportedMethods: ["basic-card"] }],
|
|
||||||
{}
|
|
||||||
// details
|
|
||||||
).show();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, [stripe]);
|
|
||||||
|
|
||||||
if (paymentRequest) {
|
|
||||||
return (
|
|
||||||
<div style={{ height: "300px" }}>
|
|
||||||
<PaymentRequestButtonElement options={{ paymentRequest }} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<button
|
<button
|
||||||
|
|||||||
@@ -107,11 +107,6 @@ export function AccountingPayablesTableComponent({
|
|||||||
dataIndex: "transactionid",
|
dataIndex: "transactionid",
|
||||||
key: "transactionid",
|
key: "transactionid",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: t("payments.fields.stripeid"),
|
|
||||||
dataIndex: "stripeid",
|
|
||||||
key: "stripeid",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: t("payments.fields.created_at"),
|
title: t("payments.fields.created_at"),
|
||||||
dataIndex: "created_at",
|
dataIndex: "created_at",
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { DELETE_BILL } from "../../graphql/bills.queries";
|
import { DELETE_BILL } from "../../graphql/bills.queries";
|
||||||
import RbacWrapper from "../rbac-wrapper/rbac-wrapper.component";
|
import RbacWrapper from "../rbac-wrapper/rbac-wrapper.component";
|
||||||
|
|
||||||
export default function BillDeleteButton({ bill }) {
|
export default function BillDeleteButton({ bill, callback }) {
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [deleteBill] = useMutation(DELETE_BILL);
|
const [deleteBill] = useMutation(DELETE_BILL);
|
||||||
@@ -36,6 +36,8 @@ export default function BillDeleteButton({ bill }) {
|
|||||||
|
|
||||||
if (!!!result.errors) {
|
if (!!!result.errors) {
|
||||||
notification["success"]({ message: t("bills.successes.deleted") });
|
notification["success"]({ message: t("bills.successes.deleted") });
|
||||||
|
|
||||||
|
if (callback && typeof callback === "function") callback(bill.id);
|
||||||
} else {
|
} else {
|
||||||
//Check if it's an fkey violation.
|
//Check if it's an fkey violation.
|
||||||
const error = JSON.stringify(result.errors);
|
const error = JSON.stringify(result.errors);
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ import { createStructuredSelector } from "reselect";
|
|||||||
import { selectBreadcrumbs } from "../../redux/application/application.selectors";
|
import { selectBreadcrumbs } from "../../redux/application/application.selectors";
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
import GlobalSearch from "../global-search/global-search.component";
|
import GlobalSearch from "../global-search/global-search.component";
|
||||||
|
import GlobalSearchOs from "../global-search/global-search-os.component";
|
||||||
import "./breadcrumbs.styles.scss";
|
import "./breadcrumbs.styles.scss";
|
||||||
|
import { useTreatments } from "@splitsoftware/splitio-react";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
breadcrumbs: selectBreadcrumbs,
|
breadcrumbs: selectBreadcrumbs,
|
||||||
@@ -15,6 +17,12 @@ const mapStateToProps = createStructuredSelector({
|
|||||||
});
|
});
|
||||||
|
|
||||||
export function BreadCrumbs({ breadcrumbs, bodyshop }) {
|
export function BreadCrumbs({ breadcrumbs, bodyshop }) {
|
||||||
|
const { OpenSearch } = useTreatments(
|
||||||
|
["OpenSearch"],
|
||||||
|
{},
|
||||||
|
bodyshop && bodyshop.imexshopid
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Row className="breadcrumb-container">
|
<Row className="breadcrumb-container">
|
||||||
<Col xs={24} sm={24} md={16}>
|
<Col xs={24} sm={24} md={16}>
|
||||||
@@ -38,7 +46,7 @@ export function BreadCrumbs({ breadcrumbs, bodyshop }) {
|
|||||||
</Breadcrumb>
|
</Breadcrumb>
|
||||||
</Col>
|
</Col>
|
||||||
<Col xs={24} sm={24} md={8}>
|
<Col xs={24} sm={24} md={8}>
|
||||||
<GlobalSearch />
|
{OpenSearch.treatment === "on" ? <GlobalSearchOs /> : <GlobalSearch />}
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ export default function CABCpvrtCalculator({ disabled, form }) {
|
|||||||
|
|
||||||
const handleFinish = async (values) => {
|
const handleFinish = async (values) => {
|
||||||
logImEXEvent("job_ca_bc_pvrt_calculate");
|
logImEXEvent("job_ca_bc_pvrt_calculate");
|
||||||
form.setFieldsValue({ ca_bc_pvrt: ((values.rate||0) * (values.days||0)).toFixed(2) });
|
form.setFieldsValue({
|
||||||
|
ca_bc_pvrt: ((values.rate || 0) * (values.days || 0)).toFixed(2),
|
||||||
|
});
|
||||||
|
form.setFields([{ name: "ca_bc_pvrt", touched: true }]);
|
||||||
setVisibility(false);
|
setVisibility(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ export function ChatConversationContainer({ bodyshop, selectedConversation }) {
|
|||||||
MARK_MESSAGES_AS_READ_BY_CONVERSATION,
|
MARK_MESSAGES_AS_READ_BY_CONVERSATION,
|
||||||
{
|
{
|
||||||
variables: { conversationId: selectedConversation },
|
variables: { conversationId: selectedConversation },
|
||||||
|
refetchQueries: ["UNREAD_CONVERSATION_COUNT"],
|
||||||
update(cache) {
|
update(cache) {
|
||||||
cache.modify({
|
cache.modify({
|
||||||
id: cache.identify({
|
id: cache.identify({
|
||||||
|
|||||||
@@ -10,7 +10,10 @@ import React, { useEffect, useState } from "react";
|
|||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { CONVERSATION_LIST_QUERY } from "../../graphql/conversations.queries";
|
import {
|
||||||
|
CONVERSATION_LIST_QUERY,
|
||||||
|
UNREAD_CONVERSATION_COUNT,
|
||||||
|
} from "../../graphql/conversations.queries";
|
||||||
import { toggleChatVisible } from "../../redux/messaging/messaging.actions";
|
import { toggleChatVisible } from "../../redux/messaging/messaging.actions";
|
||||||
import {
|
import {
|
||||||
selectChatVisible,
|
selectChatVisible,
|
||||||
@@ -37,9 +40,17 @@ export function ChatPopupComponent({
|
|||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [pollInterval, setpollInterval] = useState(0);
|
const [pollInterval, setpollInterval] = useState(0);
|
||||||
|
|
||||||
|
const { data: unreadData } = useQuery(UNREAD_CONVERSATION_COUNT, {
|
||||||
|
fetchPolicy: "network-only",
|
||||||
|
nextFetchPolicy: "network-only",
|
||||||
|
...(pollInterval > 0 ? { pollInterval } : {}),
|
||||||
|
});
|
||||||
|
|
||||||
const { loading, data, refetch, called } = useQuery(CONVERSATION_LIST_QUERY, {
|
const { loading, data, refetch, called } = useQuery(CONVERSATION_LIST_QUERY, {
|
||||||
fetchPolicy: "network-only",
|
fetchPolicy: "network-only",
|
||||||
nextFetchPolicy: "network-only",
|
nextFetchPolicy: "network-only",
|
||||||
|
skip: !chatVisible,
|
||||||
...(pollInterval > 0 ? { pollInterval } : {}),
|
...(pollInterval > 0 ? { pollInterval } : {}),
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -57,12 +68,14 @@ export function ChatPopupComponent({
|
|||||||
if (called && chatVisible) refetch();
|
if (called && chatVisible) refetch();
|
||||||
}, [chatVisible, called, refetch]);
|
}, [chatVisible, called, refetch]);
|
||||||
|
|
||||||
const unreadCount = data
|
// const unreadCount = data
|
||||||
? data.conversations.reduce(
|
// ? data.conversations.reduce(
|
||||||
(acc, val) => val.messages_aggregate.aggregate.count + acc,
|
// (acc, val) => val.messages_aggregate.aggregate.count + acc,
|
||||||
0
|
// 0
|
||||||
)
|
// )
|
||||||
: 0;
|
// : 0;
|
||||||
|
|
||||||
|
const unreadCount = unreadData?.messages_aggregate.aggregate.count || 0;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Badge count={unreadCount}>
|
<Badge count={unreadCount}>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import moment from "moment";
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { DateFormatter } from "../../utils/DateFormatter";
|
import { DateFormatter } from "../../utils/DateFormatter";
|
||||||
import ContractLicenseDecodeButton from "../contract-license-decode-button/contract-license-decode-button.component";
|
//import ContractLicenseDecodeButton from "../contract-license-decode-button/contract-license-decode-button.component";
|
||||||
import ContractStatusSelector from "../contract-status-select/contract-status-select.component";
|
import ContractStatusSelector from "../contract-status-select/contract-status-select.component";
|
||||||
import ContractsRatesChangeButton from "../contracts-rates-change-button/contracts-rates-change-button.component";
|
import ContractsRatesChangeButton from "../contracts-rates-change-button/contracts-rates-change-button.component";
|
||||||
import CourtesyCarFuelSlider from "../courtesy-car-fuel-select/courtesy-car-fuel-select.component";
|
import CourtesyCarFuelSlider from "../courtesy-car-fuel-select/courtesy-car-fuel-select.component";
|
||||||
@@ -165,7 +165,9 @@ export default function ContractFormComponent({
|
|||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
<ContractLicenseDecodeButton form={form} />
|
{
|
||||||
|
//<ContractLicenseDecodeButton form={form} />
|
||||||
|
}
|
||||||
</Space>
|
</Space>
|
||||||
</div>
|
</div>
|
||||||
<LayoutFormRow header={t("contracts.labels.driverinformation")}>
|
<LayoutFormRow header={t("contracts.labels.driverinformation")}>
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ export default function DataLabel({
|
|||||||
vertical,
|
vertical,
|
||||||
visible = true,
|
visible = true,
|
||||||
valueStyle = {},
|
valueStyle = {},
|
||||||
|
valueClassName,
|
||||||
|
onValueClick,
|
||||||
...props
|
...props
|
||||||
}) {
|
}) {
|
||||||
if (!visible || (hideIfNull && !!!children)) return null;
|
if (!visible || (hideIfNull && !!!children)) return null;
|
||||||
@@ -28,7 +30,10 @@ export default function DataLabel({
|
|||||||
marginLeft: ".3rem",
|
marginLeft: ".3rem",
|
||||||
fontWeight: "bolder",
|
fontWeight: "bolder",
|
||||||
wordWrap: "break-word",
|
wordWrap: "break-word",
|
||||||
|
cursor: onValueClick !== undefined ? "pointer" : "",
|
||||||
}}
|
}}
|
||||||
|
className={valueClassName}
|
||||||
|
onClick={onValueClick}
|
||||||
>
|
>
|
||||||
{typeof children === "string" ? (
|
{typeof children === "string" ? (
|
||||||
<Typography.Text style={valueStyle}>{children}</Typography.Text>
|
<Typography.Text style={valueStyle}>{children}</Typography.Text>
|
||||||
|
|||||||
@@ -0,0 +1,216 @@
|
|||||||
|
import { AutoComplete, Divider, Input, Space } from "antd";
|
||||||
|
import axios from "axios";
|
||||||
|
import _ from "lodash";
|
||||||
|
import React, { useState } from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { Link, useHistory } from "react-router-dom";
|
||||||
|
import PhoneNumberFormatter from "../../utils/PhoneFormatter";
|
||||||
|
import OwnerNameDisplay, {
|
||||||
|
OwnerNameDisplayFunction,
|
||||||
|
} from "../owner-name-display/owner-name-display.component";
|
||||||
|
import VehicleVinDisplay from "../vehicle-vin-display/vehicle-vin-display.component";
|
||||||
|
|
||||||
|
export default function GlobalSearchOs() {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const history = useHistory();
|
||||||
|
const [loading, setLoading] = useState(false);
|
||||||
|
const [data, setData] = useState(false);
|
||||||
|
|
||||||
|
const executeSearch = async (v) => {
|
||||||
|
if (v && v && v !== "" && v.length >= 3) {
|
||||||
|
try {
|
||||||
|
setLoading(true);
|
||||||
|
const searchData = await axios.post("/search", {
|
||||||
|
search: v,
|
||||||
|
});
|
||||||
|
|
||||||
|
const resultsByType = {
|
||||||
|
payments: [],
|
||||||
|
jobs: [],
|
||||||
|
bills: [],
|
||||||
|
owners: [],
|
||||||
|
vehicles: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
searchData.data.hits.hits.forEach((hit) => {
|
||||||
|
resultsByType[hit._index].push(hit._source);
|
||||||
|
});
|
||||||
|
setData([
|
||||||
|
{
|
||||||
|
label: renderTitle(t("menus.header.search.jobs")),
|
||||||
|
options: resultsByType.jobs.map((job) => {
|
||||||
|
return {
|
||||||
|
key: job.id,
|
||||||
|
value: job.ro_number || "N/A",
|
||||||
|
label: (
|
||||||
|
<Link to={`/manage/jobs/${job.id}`}>
|
||||||
|
<Space size="small" split={<Divider type="vertical" />}>
|
||||||
|
<strong>{job.ro_number || t("general.labels.na")}</strong>
|
||||||
|
<span>{`${job.status || ""}`}</span>
|
||||||
|
<span>
|
||||||
|
<OwnerNameDisplay ownerObject={job} />
|
||||||
|
</span>
|
||||||
|
<span>{`${job.v_model_yr || ""} ${
|
||||||
|
job.v_make_desc || ""
|
||||||
|
} ${job.v_model_desc || ""}`}</span>
|
||||||
|
<span>{`${job.clm_no || ""}`}</span>
|
||||||
|
</Space>
|
||||||
|
</Link>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: renderTitle(t("menus.header.search.owners")),
|
||||||
|
options: resultsByType.owners.map((owner) => {
|
||||||
|
return {
|
||||||
|
key: owner.id,
|
||||||
|
value: OwnerNameDisplayFunction(owner),
|
||||||
|
label: (
|
||||||
|
<Link to={`/manage/owners/${owner.id}`}>
|
||||||
|
<Space
|
||||||
|
size="small"
|
||||||
|
split={<Divider type="vertical" />}
|
||||||
|
wrap
|
||||||
|
>
|
||||||
|
<span>
|
||||||
|
<OwnerNameDisplay ownerObject={owner} />
|
||||||
|
</span>
|
||||||
|
<PhoneNumberFormatter>
|
||||||
|
{owner.ownr_ph1}
|
||||||
|
</PhoneNumberFormatter>
|
||||||
|
<PhoneNumberFormatter>
|
||||||
|
{owner.ownr_ph2}
|
||||||
|
</PhoneNumberFormatter>
|
||||||
|
</Space>
|
||||||
|
</Link>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: renderTitle(t("menus.header.search.vehicles")),
|
||||||
|
options: resultsByType.vehicles.map((vehicle) => {
|
||||||
|
return {
|
||||||
|
key: vehicle.id,
|
||||||
|
value: `${vehicle.v_model_yr || ""} ${
|
||||||
|
vehicle.v_make_desc || ""
|
||||||
|
} ${vehicle.v_model_desc || ""}`,
|
||||||
|
label: (
|
||||||
|
<Link to={`/manage/vehicles/${vehicle.id}`}>
|
||||||
|
<Space size="small" split={<Divider type="vertical" />}>
|
||||||
|
<span>
|
||||||
|
{`${vehicle.v_model_yr || ""} ${
|
||||||
|
vehicle.v_make_desc || ""
|
||||||
|
} ${vehicle.v_model_desc || ""}`}
|
||||||
|
</span>
|
||||||
|
<span>{vehicle.plate_no || ""}</span>
|
||||||
|
<span>
|
||||||
|
<VehicleVinDisplay>
|
||||||
|
{vehicle.v_vin || ""}
|
||||||
|
</VehicleVinDisplay>
|
||||||
|
</span>
|
||||||
|
</Space>
|
||||||
|
</Link>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: renderTitle(t("menus.header.search.payments")),
|
||||||
|
options: resultsByType.payments.map((payment) => {
|
||||||
|
return {
|
||||||
|
key: payment.id,
|
||||||
|
value: `${payment.job?.ro_number} ${payment.amount}`,
|
||||||
|
label: (
|
||||||
|
<Link to={`/manage/jobs/${payment.job?.id}`}>
|
||||||
|
<Space size="small" split={<Divider type="vertical" />}>
|
||||||
|
<span>{payment.paymentnum}</span>
|
||||||
|
<span>{payment.job?.ro_number}</span>
|
||||||
|
<span>{payment.memo || ""}</span>
|
||||||
|
<span>{payment.amount || ""}</span>
|
||||||
|
<span>{payment.transactionid || ""}</span>
|
||||||
|
</Space>
|
||||||
|
</Link>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: renderTitle(t("menus.header.search.bills")),
|
||||||
|
options: resultsByType.bills.map((bill) => {
|
||||||
|
return {
|
||||||
|
key: bill.id,
|
||||||
|
value: `${bill.invoice_number} - ${bill.vendor.name}`,
|
||||||
|
label: (
|
||||||
|
<Link to={`/manage/bills?billid=${bill.id}`}>
|
||||||
|
<Space size="small" split={<Divider type="vertical" />}>
|
||||||
|
<span>{bill.invoice_number}</span>
|
||||||
|
<span>{bill.vendor.name}</span>
|
||||||
|
<span>{bill.date}</span>
|
||||||
|
</Space>
|
||||||
|
</Link>
|
||||||
|
),
|
||||||
|
};
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
// {
|
||||||
|
// label: renderTitle(t("menus.header.search.phonebook")),
|
||||||
|
// options: resultsByType.search_phonebook.map((pb) => {
|
||||||
|
// return {
|
||||||
|
// key: pb.id,
|
||||||
|
// value: `${pb.firstname || ""} ${pb.lastname || ""} ${
|
||||||
|
// pb.company || ""
|
||||||
|
// }`,
|
||||||
|
// label: (
|
||||||
|
// <Link to={`/manage/phonebook?phonebookentry=${pb.id}`}>
|
||||||
|
// <Space size="small" split={<Divider type="vertical" />}>
|
||||||
|
// <span>{`${pb.firstname || ""} ${pb.lastname || ""} ${
|
||||||
|
// pb.company || ""
|
||||||
|
// }`}</span>
|
||||||
|
// <PhoneNumberFormatter>{pb.phone1}</PhoneNumberFormatter>
|
||||||
|
// <span>{pb.email}</span>
|
||||||
|
// </Space>
|
||||||
|
// </Link>
|
||||||
|
// ),
|
||||||
|
// };
|
||||||
|
// }),
|
||||||
|
// },
|
||||||
|
]);
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error while fetching search results", error);
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
const debouncedExecuteSearch = _.debounce(executeSearch, 750);
|
||||||
|
|
||||||
|
const handleSearch = (value) => {
|
||||||
|
debouncedExecuteSearch(value);
|
||||||
|
};
|
||||||
|
|
||||||
|
const renderTitle = (title) => {
|
||||||
|
return <span>{title}</span>;
|
||||||
|
};
|
||||||
|
|
||||||
|
return (
|
||||||
|
<AutoComplete
|
||||||
|
options={data}
|
||||||
|
onSearch={handleSearch}
|
||||||
|
defaultActiveFirstOption
|
||||||
|
onSelect={(val, opt) => {
|
||||||
|
history.push(opt.label.props.to);
|
||||||
|
}}
|
||||||
|
onClear={() => setData([])}
|
||||||
|
>
|
||||||
|
<Input.Search
|
||||||
|
size="large"
|
||||||
|
placeholder={t("general.labels.globalsearch")}
|
||||||
|
enterButton
|
||||||
|
allowClear
|
||||||
|
loading={loading}
|
||||||
|
/>
|
||||||
|
</AutoComplete>
|
||||||
|
);
|
||||||
|
}
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
import { useLazyQuery } from "@apollo/client";
|
import { useLazyQuery } from "@apollo/client";
|
||||||
import { LoadingOutlined } from "@ant-design/icons";
|
import { AutoComplete, Divider, Input, Space } from "antd";
|
||||||
import { AutoComplete, Divider, Space } from "antd";
|
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
@@ -19,11 +18,18 @@ export default function GlobalSearch() {
|
|||||||
useLazyQuery(GLOBAL_SEARCH_QUERY);
|
useLazyQuery(GLOBAL_SEARCH_QUERY);
|
||||||
|
|
||||||
const executeSearch = (v) => {
|
const executeSearch = (v) => {
|
||||||
if (v && v.variables.search && v.variables.search !== "") callSearch(v);
|
if (
|
||||||
|
v &&
|
||||||
|
v.variables.search &&
|
||||||
|
v.variables.search !== "" &&
|
||||||
|
v.variables.search.length >= 3
|
||||||
|
)
|
||||||
|
callSearch(v);
|
||||||
};
|
};
|
||||||
const debouncedExecuteSearch = _.debounce(executeSearch, 750);
|
const debouncedExecuteSearch = _.debounce(executeSearch, 750);
|
||||||
|
|
||||||
const handleSearch = (value) => {
|
const handleSearch = (value) => {
|
||||||
|
console.log("Handle Search");
|
||||||
debouncedExecuteSearch({ variables: { search: value } });
|
debouncedExecuteSearch({ variables: { search: value } });
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -38,7 +44,7 @@ export default function GlobalSearch() {
|
|||||||
options: data.search_jobs.map((job) => {
|
options: data.search_jobs.map((job) => {
|
||||||
return {
|
return {
|
||||||
key: job.id,
|
key: job.id,
|
||||||
value: job.ro_number,
|
value: job.ro_number || "N/A",
|
||||||
label: (
|
label: (
|
||||||
<Link to={`/manage/jobs/${job.id}`}>
|
<Link to={`/manage/jobs/${job.id}`}>
|
||||||
<Space size="small" split={<Divider type="vertical" />}>
|
<Space size="small" split={<Divider type="vertical" />}>
|
||||||
@@ -178,13 +184,18 @@ export default function GlobalSearch() {
|
|||||||
<AutoComplete
|
<AutoComplete
|
||||||
options={options}
|
options={options}
|
||||||
onSearch={handleSearch}
|
onSearch={handleSearch}
|
||||||
suffixIcon={loading && <LoadingOutlined spin />}
|
|
||||||
defaultActiveFirstOption
|
defaultActiveFirstOption
|
||||||
placeholder={t("general.labels.globalsearch")}
|
|
||||||
allowClear
|
|
||||||
onSelect={(val, opt) => {
|
onSelect={(val, opt) => {
|
||||||
history.push(opt.label.props.to);
|
history.push(opt.label.props.to);
|
||||||
}}
|
}}
|
||||||
></AutoComplete>
|
>
|
||||||
|
<Input.Search
|
||||||
|
size="large"
|
||||||
|
placeholder={t("general.labels.globalsearch")}
|
||||||
|
enterButton
|
||||||
|
allowClear
|
||||||
|
loading={loading}
|
||||||
|
/>
|
||||||
|
</AutoComplete>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,9 +3,11 @@ import {
|
|||||||
Button,
|
Button,
|
||||||
Divider,
|
Divider,
|
||||||
Dropdown,
|
Dropdown,
|
||||||
|
Form,
|
||||||
Menu,
|
Menu,
|
||||||
notification,
|
notification,
|
||||||
Popover,
|
Popover,
|
||||||
|
Select,
|
||||||
Space,
|
Space,
|
||||||
} from "antd";
|
} from "antd";
|
||||||
import parsePhoneNumber from "libphonenumber-js";
|
import parsePhoneNumber from "libphonenumber-js";
|
||||||
@@ -59,7 +61,10 @@ export function ScheduleEventComponent({
|
|||||||
|
|
||||||
const blockContent = (
|
const blockContent = (
|
||||||
<div>
|
<div>
|
||||||
<Button onClick={() => handleCancel(event.id)} disabled={event.arrived}>
|
<Button
|
||||||
|
onClick={() => handleCancel({ id: event.id })}
|
||||||
|
disabled={event.arrived}
|
||||||
|
>
|
||||||
{t("appointments.actions.cancel")}
|
{t("appointments.actions.cancel")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
@@ -203,10 +208,46 @@ export function ScheduleEventComponent({
|
|||||||
<Button>{t("appointments.actions.sendreminder")}</Button>
|
<Button>{t("appointments.actions.sendreminder")}</Button>
|
||||||
</Dropdown>
|
</Dropdown>
|
||||||
) : null}
|
) : null}
|
||||||
|
<Popover
|
||||||
<Button onClick={() => handleCancel(event.id)} disabled={event.arrived}>
|
trigger="click"
|
||||||
{t("appointments.actions.cancel")}
|
disabled={event.arrived}
|
||||||
</Button>
|
content={
|
||||||
|
<Form
|
||||||
|
layout="vertical"
|
||||||
|
onFinish={({ lost_sale_reason }) => {
|
||||||
|
handleCancel({ id: event.id, lost_sale_reason });
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Form.Item
|
||||||
|
name="lost_sale_reason"
|
||||||
|
label={t("jobs.fields.lost_sale_reason")}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Select
|
||||||
|
options={bodyshop.md_lost_sale_reasons.map((lsr) => ({
|
||||||
|
label: lsr,
|
||||||
|
value: lsr,
|
||||||
|
}))}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
<Button htmlType="submit">
|
||||||
|
{t("appointments.actions.cancel")}
|
||||||
|
</Button>
|
||||||
|
</Form>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
// onClick={() => handleCancel(event.id)}
|
||||||
|
disabled={event.arrived}
|
||||||
|
>
|
||||||
|
{t("appointments.actions.cancel")}
|
||||||
|
</Button>
|
||||||
|
</Popover>
|
||||||
{event.isintake ? (
|
{event.isintake ? (
|
||||||
<Button
|
<Button
|
||||||
disabled={event.arrived}
|
disabled={event.arrived}
|
||||||
@@ -249,7 +290,7 @@ export function ScheduleEventComponent({
|
|||||||
const RegularEvent = event.isintake ? (
|
const RegularEvent = event.isintake ? (
|
||||||
<Space
|
<Space
|
||||||
wrap
|
wrap
|
||||||
size='small'
|
size="small"
|
||||||
style={{
|
style={{
|
||||||
backgroundColor:
|
backgroundColor:
|
||||||
event.color && event.color.hex ? event.color.hex : event.color,
|
event.color && event.color.hex ? event.color.hex : event.color,
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default function ScheduleEventContainer({ bodyshop, event, refetch }) {
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [cancelAppointment] = useMutation(CANCEL_APPOINTMENT_BY_ID);
|
const [cancelAppointment] = useMutation(CANCEL_APPOINTMENT_BY_ID);
|
||||||
const [updateJob] = useMutation(UPDATE_JOB);
|
const [updateJob] = useMutation(UPDATE_JOB);
|
||||||
const handleCancel = async (id) => {
|
const handleCancel = async ({ id, lost_sale_reason }) => {
|
||||||
logImEXEvent("schedule_cancel_appt");
|
logImEXEvent("schedule_cancel_appt");
|
||||||
|
|
||||||
const cancelAppt = await cancelAppointment({
|
const cancelAppt = await cancelAppointment({
|
||||||
@@ -38,7 +38,8 @@ export default function ScheduleEventContainer({ bodyshop, event, refetch }) {
|
|||||||
job: {
|
job: {
|
||||||
date_scheduled: null,
|
date_scheduled: null,
|
||||||
scheduled_in: null,
|
scheduled_in: null,
|
||||||
scheduled_completion:null,
|
scheduled_completion: null,
|
||||||
|
lost_sale_reason,
|
||||||
status: bodyshop.md_ro_statuses.default_imported,
|
status: bodyshop.md_ro_statuses.default_imported,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -103,6 +103,12 @@ export function JobLinesComponent({
|
|||||||
fixed: "left",
|
fixed: "left",
|
||||||
key: "line_desc",
|
key: "line_desc",
|
||||||
sorter: (a, b) => alphaSort(a.line_desc, b.line_desc),
|
sorter: (a, b) => alphaSort(a.line_desc, b.line_desc),
|
||||||
|
onCell: (record) => ({
|
||||||
|
className: record.manual_line && "job-line-manual",
|
||||||
|
style: {
|
||||||
|
...(record.critical ? { boxShadow: " -.5em 0 0 #FFC107" } : {}),
|
||||||
|
},
|
||||||
|
}),
|
||||||
sortOrder:
|
sortOrder:
|
||||||
state.sortedInfo.columnKey === "line_desc" && state.sortedInfo.order,
|
state.sortedInfo.columnKey === "line_desc" && state.sortedInfo.order,
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
@@ -342,7 +348,7 @@ export function JobLinesComponent({
|
|||||||
onClick={() => {
|
onClick={() => {
|
||||||
setJobLineEditContext({
|
setJobLineEditContext({
|
||||||
actions: { refetch: refetch, submit: form && form.submit },
|
actions: { refetch: refetch, submit: form && form.submit },
|
||||||
context: record,
|
context: { ...record, jobid: job.id },
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -22,9 +22,20 @@ export function JoblinePresetButton({ bodyshop, form }) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const menu = (
|
const menu = (
|
||||||
<Menu>
|
<Menu
|
||||||
|
style={{
|
||||||
|
columnCount: Math.max(
|
||||||
|
Math.floor(bodyshop.md_jobline_presets.length / 15),
|
||||||
|
1
|
||||||
|
),
|
||||||
|
}}
|
||||||
|
>
|
||||||
{bodyshop.md_jobline_presets.map((i, idx) => (
|
{bodyshop.md_jobline_presets.map((i, idx) => (
|
||||||
<Menu.Item onClick={() => handleSelect(i)} key={idx}>
|
<Menu.Item
|
||||||
|
onClick={() => handleSelect(i)}
|
||||||
|
key={idx}
|
||||||
|
style={{ breakInside: "avoid" }}
|
||||||
|
>
|
||||||
{i.label}
|
{i.label}
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@@ -40,6 +40,11 @@ export function JobLinesUpsertModalComponent({
|
|||||||
{},
|
{},
|
||||||
bodyshop.imexshopid
|
bodyshop.imexshopid
|
||||||
);
|
);
|
||||||
|
const { Autohouse_Detail_line } = useTreatments(
|
||||||
|
["Autohouse_Detail_line"],
|
||||||
|
{},
|
||||||
|
bodyshop.imexshopid
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Modal
|
<Modal
|
||||||
@@ -155,6 +160,40 @@ export function JobLinesUpsertModalComponent({
|
|||||||
>
|
>
|
||||||
<InputNumber precision={1} />
|
<InputNumber precision={1} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
{Autohouse_Detail_line.treatment === "on" && (
|
||||||
|
<Form.Item
|
||||||
|
label={t("joblines.fields.ah_detail_line")}
|
||||||
|
name="ah_detail_line"
|
||||||
|
valuePropName="checked"
|
||||||
|
dependencies={["mod_lbr_ty"]}
|
||||||
|
initialValue={false}
|
||||||
|
rules={[
|
||||||
|
({ getFieldValue }) => ({
|
||||||
|
validator(rule, value) {
|
||||||
|
if (
|
||||||
|
value === false ||
|
||||||
|
value === undefined ||
|
||||||
|
value === null
|
||||||
|
)
|
||||||
|
return Promise.resolve();
|
||||||
|
if (
|
||||||
|
value === true &&
|
||||||
|
["LA1", "LA2", "LA3", "LA4", "LAU"].includes(
|
||||||
|
getFieldValue("mod_lbr_ty")
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
return Promise.resolve();
|
||||||
|
}
|
||||||
|
return Promise.reject(
|
||||||
|
t("joblines.validations.ahdetailonlyonuserdefinedtypes")
|
||||||
|
);
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Switch />
|
||||||
|
</Form.Item>
|
||||||
|
)}
|
||||||
</LayoutFormRow>
|
</LayoutFormRow>
|
||||||
<LayoutFormRow>
|
<LayoutFormRow>
|
||||||
<Form.Item label={t("joblines.fields.part_type")} name="part_type">
|
<Form.Item label={t("joblines.fields.part_type")} name="part_type">
|
||||||
@@ -218,7 +257,6 @@ export function JobLinesUpsertModalComponent({
|
|||||||
rules={[
|
rules={[
|
||||||
({ getFieldValue }) => ({
|
({ getFieldValue }) => ({
|
||||||
validator(rule, value) {
|
validator(rule, value) {
|
||||||
console.log(value);
|
|
||||||
if (!value || getFieldValue("part_type") !== "PAE") {
|
if (!value || getFieldValue("part_type") !== "PAE") {
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
@@ -229,7 +267,6 @@ export function JobLinesUpsertModalComponent({
|
|||||||
}),
|
}),
|
||||||
({ getFieldValue }) => ({
|
({ getFieldValue }) => ({
|
||||||
validator(rule, value) {
|
validator(rule, value) {
|
||||||
console.log(value, !!value);
|
|
||||||
if (
|
if (
|
||||||
!!getFieldValue("part_type") === (!!value || value === 0)
|
!!getFieldValue("part_type") === (!!value || value === 0)
|
||||||
) {
|
) {
|
||||||
@@ -252,7 +289,7 @@ export function JobLinesUpsertModalComponent({
|
|||||||
name="prt_dsmk_p"
|
name="prt_dsmk_p"
|
||||||
initialValue={0}
|
initialValue={0}
|
||||||
>
|
>
|
||||||
<InputNumber precision={0} min={0} max={100} />
|
<InputNumber precision={0} min={-100} max={100} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={t("joblines.fields.tax_part")}
|
label={t("joblines.fields.tax_part")}
|
||||||
|
|||||||
@@ -13,8 +13,13 @@ import { selectJobLineEditModal } from "../../redux/modals/modals.selectors";
|
|||||||
import UndefinedToNull from "../../utils/undefinedtonull";
|
import UndefinedToNull from "../../utils/undefinedtonull";
|
||||||
import JobLinesUpdsertModal from "./job-lines-upsert-modal.component";
|
import JobLinesUpdsertModal from "./job-lines-upsert-modal.component";
|
||||||
import Axios from "axios";
|
import Axios from "axios";
|
||||||
|
import Dinero from "dinero.js";
|
||||||
|
import CriticalPartsScan from "../../utils/criticalPartsScan";
|
||||||
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
|
import { useTreatments } from "@splitsoftware/splitio-react";
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
jobLineEditModal: selectJobLineEditModal,
|
jobLineEditModal: selectJobLineEditModal,
|
||||||
|
bodyshop: selectBodyshop,
|
||||||
});
|
});
|
||||||
const mapDispatchToProps = (dispatch) => ({
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
toggleModalVisible: () => dispatch(toggleModalVisible("jobLineEdit")),
|
toggleModalVisible: () => dispatch(toggleModalVisible("jobLineEdit")),
|
||||||
@@ -23,7 +28,13 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
function JobLinesUpsertModalContainer({
|
function JobLinesUpsertModalContainer({
|
||||||
jobLineEditModal,
|
jobLineEditModal,
|
||||||
toggleModalVisible,
|
toggleModalVisible,
|
||||||
|
bodyshop,
|
||||||
}) {
|
}) {
|
||||||
|
const { CriticalPartsScanning } = useTreatments(
|
||||||
|
["CriticalPartsScanning"],
|
||||||
|
{},
|
||||||
|
bodyshop.imexshopid
|
||||||
|
);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [insertJobLine] = useMutation(INSERT_NEW_JOB_LINE);
|
const [insertJobLine] = useMutation(INSERT_NEW_JOB_LINE);
|
||||||
const [updateJobLine] = useMutation(UPDATE_JOB_LINE);
|
const [updateJobLine] = useMutation(UPDATE_JOB_LINE);
|
||||||
@@ -40,7 +51,15 @@ function JobLinesUpsertModalContainer({
|
|||||||
manual_line: !(
|
manual_line: !(
|
||||||
jobLineEditModal.context && jobLineEditModal.context.id
|
jobLineEditModal.context && jobLineEditModal.context.id
|
||||||
),
|
),
|
||||||
...UndefinedToNull(values),
|
...UndefinedToNull({
|
||||||
|
...values,
|
||||||
|
prt_dsmk_m: Dinero({
|
||||||
|
amount: Math.round((values.act_price || 0) * 100),
|
||||||
|
})
|
||||||
|
.percentage(Math.abs(values.prt_dsmk_p || 0))
|
||||||
|
.multiply(values.prt_dsmk_p >= 0 ? 1 : -1)
|
||||||
|
.toFormat(0.0),
|
||||||
|
}),
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -68,7 +87,15 @@ function JobLinesUpsertModalContainer({
|
|||||||
const r = await updateJobLine({
|
const r = await updateJobLine({
|
||||||
variables: {
|
variables: {
|
||||||
lineId: jobLineEditModal.context.id,
|
lineId: jobLineEditModal.context.id,
|
||||||
line: values,
|
line: {
|
||||||
|
...values,
|
||||||
|
prt_dsmk_m: Dinero({
|
||||||
|
amount: Math.round(values.act_price * 100),
|
||||||
|
})
|
||||||
|
.percentage(Math.abs(values.prt_dsmk_p || 0))
|
||||||
|
.multiply(values.prt_dsmk_p >= 0 ? 1 : -1)
|
||||||
|
.toFormat(0.0),
|
||||||
|
},
|
||||||
},
|
},
|
||||||
refetchQueries: ["GET_LINE_TICKET_BY_PK"],
|
refetchQueries: ["GET_LINE_TICKET_BY_PK"],
|
||||||
});
|
});
|
||||||
@@ -92,6 +119,9 @@ function JobLinesUpsertModalContainer({
|
|||||||
}
|
}
|
||||||
toggleModalVisible();
|
toggleModalVisible();
|
||||||
}
|
}
|
||||||
|
if (CriticalPartsScanning.treatment === "on") {
|
||||||
|
CriticalPartsScan(jobLineEditModal.context.jobid);
|
||||||
|
}
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -25,8 +25,6 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
dispatch(setModalContext({ context: context, modal: "payment" })),
|
dispatch(setModalContext({ context: context, modal: "payment" })),
|
||||||
});
|
});
|
||||||
|
|
||||||
const stripeTestEnv = process.env.REACT_APP_STRIPE_PUBLIC_KEY; //.includes("test");
|
|
||||||
|
|
||||||
export function JobPayments({
|
export function JobPayments({
|
||||||
job,
|
job,
|
||||||
jobRO,
|
jobRO,
|
||||||
@@ -94,23 +92,6 @@ export function JobPayments({
|
|||||||
state.sortedInfo.columnKey === "transactionid" &&
|
state.sortedInfo.columnKey === "transactionid" &&
|
||||||
state.sortedInfo.order,
|
state.sortedInfo.order,
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: t("payments.fields.stripeid"),
|
|
||||||
dataIndex: "stripeid",
|
|
||||||
key: "stripeid",
|
|
||||||
render: (text, record) =>
|
|
||||||
record.stripeid ? (
|
|
||||||
<a
|
|
||||||
href={
|
|
||||||
stripeTestEnv
|
|
||||||
? `https://dashboard.stripe.com/${bodyshop.stripe_acct_id}/test/payments/${record.stripeid}`
|
|
||||||
: `https://dashboard.stripe.com/${bodyshop.stripe_acct_id}/payments/${record.stripeid}`
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{record.stripeid}
|
|
||||||
</a>
|
|
||||||
) : null,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: t("general.labels.actions"),
|
title: t("general.labels.actions"),
|
||||||
dataIndex: "actions",
|
dataIndex: "actions",
|
||||||
|
|||||||
@@ -166,6 +166,16 @@ export default function ScoreboardAddButton({
|
|||||||
painthrs: 0,
|
painthrs: 0,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
//Add Labor Adjustments
|
||||||
|
v.painthrs = v.painthrs + (job.lbr_adjustments.LAR || 0);
|
||||||
|
v.bodyhrs =
|
||||||
|
v.bodyhrs +
|
||||||
|
Object.keys(job.lbr_adjustments)
|
||||||
|
.filter((key) => key !== "LAR")
|
||||||
|
.reduce((acc, val) => {
|
||||||
|
return acc + job.lbr_adjustments[val];
|
||||||
|
}, 0);
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
date: new moment(),
|
date: new moment(),
|
||||||
bodyhrs: Math.round(v.bodyhrs * 10) / 10,
|
bodyhrs: Math.round(v.bodyhrs * 10) / 10,
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ import {
|
|||||||
useApolloClient,
|
useApolloClient,
|
||||||
useLazyQuery,
|
useLazyQuery,
|
||||||
useMutation,
|
useMutation,
|
||||||
useQuery,
|
useQuery
|
||||||
} from "@apollo/client";
|
} from "@apollo/client";
|
||||||
|
import { useTreatments } from "@splitsoftware/splitio-react";
|
||||||
import { Col, notification, Row } from "antd";
|
import { Col, notification, Row } from "antd";
|
||||||
import Axios from "axios";
|
import Axios from "axios";
|
||||||
import Dinero from "dinero.js";
|
import Dinero from "dinero.js";
|
||||||
@@ -19,7 +20,7 @@ import { logImEXEvent } from "../../firebase/firebase.utils";
|
|||||||
import {
|
import {
|
||||||
DELETE_AVAILABLE_JOB,
|
DELETE_AVAILABLE_JOB,
|
||||||
QUERY_AVAILABLE_JOBS,
|
QUERY_AVAILABLE_JOBS,
|
||||||
QUERY_AVAILABLE_NEW_JOBS_EST_DATA_BY_PK,
|
QUERY_AVAILABLE_NEW_JOBS_EST_DATA_BY_PK
|
||||||
} from "../../graphql/available-jobs.queries";
|
} from "../../graphql/available-jobs.queries";
|
||||||
import { INSERT_NEW_JOB, UPDATE_JOB } from "../../graphql/jobs.queries";
|
import { INSERT_NEW_JOB, UPDATE_JOB } from "../../graphql/jobs.queries";
|
||||||
import { INSERT_NEW_NOTE } from "../../graphql/notes.queries";
|
import { INSERT_NEW_NOTE } from "../../graphql/notes.queries";
|
||||||
@@ -27,10 +28,11 @@ import { SEARCH_VEHICLE_BY_VIN } from "../../graphql/vehicles.queries";
|
|||||||
import { insertAuditTrail } from "../../redux/application/application.actions";
|
import { insertAuditTrail } from "../../redux/application/application.actions";
|
||||||
import {
|
import {
|
||||||
selectBodyshop,
|
selectBodyshop,
|
||||||
selectCurrentUser,
|
selectCurrentUser
|
||||||
} from "../../redux/user/user.selectors";
|
} from "../../redux/user/user.selectors";
|
||||||
import confirmDialog from "../../utils/asyncConfirm";
|
import confirmDialog from "../../utils/asyncConfirm";
|
||||||
import AuditTrailMapping from "../../utils/AuditTrailMappings";
|
import AuditTrailMapping from "../../utils/AuditTrailMappings";
|
||||||
|
import CriticalPartsScan from "../../utils/criticalPartsScan";
|
||||||
import AlertComponent from "../alert/alert.component";
|
import AlertComponent from "../alert/alert.component";
|
||||||
import JobsAvailableScan from "../jobs-available-scan/jobs-available-scan.component";
|
import JobsAvailableScan from "../jobs-available-scan/jobs-available-scan.component";
|
||||||
import JobsFindModalContainer from "../jobs-find-modal/jobs-find-modal.container";
|
import JobsFindModalContainer from "../jobs-find-modal/jobs-find-modal.container";
|
||||||
@@ -53,6 +55,11 @@ export function JobsAvailableContainer({
|
|||||||
currentUser,
|
currentUser,
|
||||||
insertAuditTrail,
|
insertAuditTrail,
|
||||||
}) {
|
}) {
|
||||||
|
const { CriticalPartsScanning } = useTreatments(
|
||||||
|
["CriticalPartsScanning"],
|
||||||
|
{},
|
||||||
|
bodyshop.imexshopid
|
||||||
|
);
|
||||||
const { loading, error, data, refetch } = useQuery(QUERY_AVAILABLE_JOBS, {
|
const { loading, error, data, refetch } = useQuery(QUERY_AVAILABLE_JOBS, {
|
||||||
fetchPolicy: "network-only",
|
fetchPolicy: "network-only",
|
||||||
nextFetchPolicy: "network-only",
|
nextFetchPolicy: "network-only",
|
||||||
@@ -155,6 +162,9 @@ export function JobsAvailableContainer({
|
|||||||
},
|
},
|
||||||
})
|
})
|
||||||
.then((r) => {
|
.then((r) => {
|
||||||
|
if (CriticalPartsScanning.treatment === "on") {
|
||||||
|
CriticalPartsScan(r.data.insert_jobs.returning[0].id);
|
||||||
|
}
|
||||||
notification["success"]({
|
notification["success"]({
|
||||||
message: t("jobs.successes.created"),
|
message: t("jobs.successes.created"),
|
||||||
onClick: () => {
|
onClick: () => {
|
||||||
@@ -241,7 +251,9 @@ export function JobsAvailableContainer({
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
if (CriticalPartsScanning.treatment === "on") {
|
||||||
|
CriticalPartsScan(updateResult.data.update_jobs.returning[0].id);
|
||||||
|
}
|
||||||
if (updateResult.errors) {
|
if (updateResult.errors) {
|
||||||
//error while inserting
|
//error while inserting
|
||||||
notification["error"]({
|
notification["error"]({
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import {
|
|||||||
Space,
|
Space,
|
||||||
Switch,
|
Switch,
|
||||||
} from "antd";
|
} from "antd";
|
||||||
|
import axios from "axios";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
@@ -18,7 +19,6 @@ import { insertAuditTrail } from "../../redux/application/application.actions";
|
|||||||
import { selectJobReadOnly } from "../../redux/application/application.selectors";
|
import { selectJobReadOnly } from "../../redux/application/application.selectors";
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
import AuditTrailMapping from "../../utils/AuditTrailMappings";
|
import AuditTrailMapping from "../../utils/AuditTrailMappings";
|
||||||
import axios from "axios";
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
//currentUser: selectCurrentUser
|
//currentUser: selectCurrentUser
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
@@ -43,14 +43,22 @@ export function JobsConvertButton({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
|
|
||||||
const handleConvert = async (values) => {
|
const handleConvert = async ({ employee_csr, category, ...values }) => {
|
||||||
if (parentFormIsFieldsTouched()) {
|
if (parentFormIsFieldsTouched()) {
|
||||||
alert(t("jobs.labels.savebeforeconversion"));
|
alert(t("jobs.labels.savebeforeconversion"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
const res = await mutationConvertJob({
|
const res = await mutationConvertJob({
|
||||||
variables: { jobId: job.id, ...values },
|
variables: {
|
||||||
|
jobId: job.id,
|
||||||
|
job: {
|
||||||
|
converted: true,
|
||||||
|
...(bodyshop.enforce_conversion_csr ? { employee_csr } : {}),
|
||||||
|
...(bodyshop.enforce_conversion_category ? { category } : {}),
|
||||||
|
...values,
|
||||||
|
},
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
if (values.ca_gst_registrant) {
|
if (values.ca_gst_registrant) {
|
||||||
@@ -83,7 +91,12 @@ export function JobsConvertButton({
|
|||||||
layout="vertical"
|
layout="vertical"
|
||||||
form={form}
|
form={form}
|
||||||
onFinish={handleConvert}
|
onFinish={handleConvert}
|
||||||
initialValues={{ driveable: true, towin: false }}
|
initialValues={{
|
||||||
|
driveable: true,
|
||||||
|
towin: false,
|
||||||
|
employee_csr: job.employee_csr,
|
||||||
|
category: job.category,
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name={["ins_co_nm"]}
|
name={["ins_co_nm"]}
|
||||||
@@ -96,8 +109,8 @@ export function JobsConvertButton({
|
|||||||
]}
|
]}
|
||||||
>
|
>
|
||||||
<Select>
|
<Select>
|
||||||
{bodyshop.md_ins_cos.map((s) => (
|
{bodyshop.md_ins_cos.map((s, i) => (
|
||||||
<Select.Option key={s.name} value={s.name}>
|
<Select.Option key={i} value={s.name}>
|
||||||
{s.name}
|
{s.name}
|
||||||
</Select.Option>
|
</Select.Option>
|
||||||
))}
|
))}
|
||||||
@@ -151,13 +164,70 @@ export function JobsConvertButton({
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
<Form.Item
|
{bodyshop.enforce_conversion_csr && (
|
||||||
label={t("jobs.fields.ca_gst_registrant")}
|
<Form.Item
|
||||||
name="ca_gst_registrant"
|
name={"employee_csr"}
|
||||||
valuePropName="checked"
|
label={t("jobs.fields.employee_csr")}
|
||||||
>
|
rules={[
|
||||||
<Switch />
|
{
|
||||||
</Form.Item>
|
required: bodyshop.enforce_conversion_csr,
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Select
|
||||||
|
showSearch
|
||||||
|
style={{ width: 200 }}
|
||||||
|
optionFilterProp="children"
|
||||||
|
filterOption={(input, option) =>
|
||||||
|
option.props.children
|
||||||
|
.toLowerCase()
|
||||||
|
.indexOf(input.toLowerCase()) >= 0
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{bodyshop.employees
|
||||||
|
.filter((emp) => emp.active)
|
||||||
|
.map((emp) => (
|
||||||
|
<Select.Option
|
||||||
|
value={emp.id}
|
||||||
|
key={emp.id}
|
||||||
|
name={`${emp.first_name} ${emp.last_name}`}
|
||||||
|
>
|
||||||
|
{`${emp.first_name} ${emp.last_name}`}
|
||||||
|
</Select.Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</Form.Item>
|
||||||
|
)}
|
||||||
|
{bodyshop.enforce_conversion_category && (
|
||||||
|
<Form.Item
|
||||||
|
name={"category"}
|
||||||
|
label={t("jobs.fields.category")}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: bodyshop.enforce_conversion_category,
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Select allowClear>
|
||||||
|
{bodyshop.md_categories.map((s) => (
|
||||||
|
<Select.Option key={s} value={s}>
|
||||||
|
{s}
|
||||||
|
</Select.Option>
|
||||||
|
))}
|
||||||
|
</Select>
|
||||||
|
</Form.Item>
|
||||||
|
)}
|
||||||
|
{bodyshop.region_config.toLowerCase().startsWith("ca") && (
|
||||||
|
<Form.Item
|
||||||
|
label={t("jobs.fields.ca_gst_registrant")}
|
||||||
|
name="ca_gst_registrant"
|
||||||
|
valuePropName="checked"
|
||||||
|
>
|
||||||
|
<Switch />
|
||||||
|
</Form.Item>
|
||||||
|
)}
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={t("jobs.fields.driveable")}
|
label={t("jobs.fields.driveable")}
|
||||||
name="driveable"
|
name="driveable"
|
||||||
@@ -194,7 +264,14 @@ export function JobsConvertButton({
|
|||||||
// style={{ display: job.converted ? "none" : "" }}
|
// style={{ display: job.converted ? "none" : "" }}
|
||||||
disabled={job.converted || jobRO}
|
disabled={job.converted || jobRO}
|
||||||
loading={loading}
|
loading={loading}
|
||||||
onClick={() => setVisible(true)}
|
onClick={() => {
|
||||||
|
setVisible(true);
|
||||||
|
form.setFieldsValue({
|
||||||
|
driveable: true,
|
||||||
|
towin: false,
|
||||||
|
employee_csr: job.employee_csr,
|
||||||
|
});
|
||||||
|
}}
|
||||||
>
|
>
|
||||||
{t("jobs.actions.convert")}
|
{t("jobs.actions.convert")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -224,13 +224,15 @@ export function JobsCreateJobsInfo({ bodyshop, form, selected }) {
|
|||||||
>
|
>
|
||||||
<CurrencyInput />
|
<CurrencyInput />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
{bodyshop.region_config.toLowerCase().startsWith("ca") && (
|
||||||
label={t("jobs.fields.ca_gst_registrant")}
|
<Form.Item
|
||||||
name="ca_gst_registrant"
|
label={t("jobs.fields.ca_gst_registrant")}
|
||||||
valuePropName="checked"
|
name="ca_gst_registrant"
|
||||||
>
|
valuePropName="checked"
|
||||||
<Switch />
|
>
|
||||||
</Form.Item>
|
<Switch />
|
||||||
|
</Form.Item>
|
||||||
|
)}
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={t("jobs.fields.other_amount_payable")}
|
label={t("jobs.fields.other_amount_payable")}
|
||||||
name="other_amount_payable"
|
name="other_amount_payable"
|
||||||
|
|||||||
@@ -9,7 +9,11 @@ const colSpan = {
|
|||||||
lg: { span: 12 },
|
lg: { span: 12 },
|
||||||
};
|
};
|
||||||
|
|
||||||
export default function JobsCreateVehicleInfoComponent({ loading, vehicles }) {
|
export default function JobsCreateVehicleInfoComponent({
|
||||||
|
loading,
|
||||||
|
vehicles,
|
||||||
|
form,
|
||||||
|
}) {
|
||||||
const [state, setState] = useContext(JobCreateContext);
|
const [state, setState] = useContext(JobCreateContext);
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
return (
|
return (
|
||||||
@@ -58,7 +62,7 @@ export default function JobsCreateVehicleInfoComponent({ loading, vehicles }) {
|
|||||||
/>
|
/>
|
||||||
</Col>
|
</Col>
|
||||||
<Col {...colSpan}>
|
<Col {...colSpan}>
|
||||||
<JobsCreateVehicleInfoNewComponent />
|
<JobsCreateVehicleInfoNewComponent form={form}/>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</Row>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ export default function JobsCreateVehicleInfoContainer({ form }) {
|
|||||||
<JobsCreateVehicleInfoComponent
|
<JobsCreateVehicleInfoComponent
|
||||||
loading={loading}
|
loading={loading}
|
||||||
vehicles={data ? data.search_vehicles : null}
|
vehicles={data ? data.search_vehicles : null}
|
||||||
|
form={form}
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,8 +4,9 @@ import { useTranslation } from "react-i18next";
|
|||||||
import JobCreateContext from "../../pages/jobs-create/jobs-create.context";
|
import JobCreateContext from "../../pages/jobs-create/jobs-create.context";
|
||||||
import FormDatePicker from "../form-date-picker/form-date-picker.component";
|
import FormDatePicker from "../form-date-picker/form-date-picker.component";
|
||||||
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
import LayoutFormRow from "../layout-form-row/layout-form-row.component";
|
||||||
|
import JobsCreateVehicleInfoPredefined from "./jobs-create-vehicle-info.predefined.component";
|
||||||
|
|
||||||
export default function JobsCreateVehicleInfoNewComponent() {
|
export default function JobsCreateVehicleInfoNewComponent({ form }) {
|
||||||
const [state] = useContext(JobCreateContext);
|
const [state] = useContext(JobCreateContext);
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@@ -25,7 +26,7 @@ export default function JobsCreateVehicleInfoNewComponent() {
|
|||||||
<Input disabled={!state.vehicle.new} />
|
<Input disabled={!state.vehicle.new} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</LayoutFormRow>
|
</LayoutFormRow>
|
||||||
<LayoutFormRow grow>
|
<LayoutFormRow grow noDivider>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={t("vehicles.fields.v_color")}
|
label={t("vehicles.fields.v_color")}
|
||||||
name={["vehicle", "data", "v_color"]}
|
name={["vehicle", "data", "v_color"]}
|
||||||
@@ -52,8 +53,9 @@ export default function JobsCreateVehicleInfoNewComponent() {
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
</LayoutFormRow>
|
</LayoutFormRow>
|
||||||
|
|
||||||
<LayoutFormRow grow>
|
<LayoutFormRow grow noDivider>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
|
span={10}
|
||||||
label={t("vehicles.fields.v_make_desc")}
|
label={t("vehicles.fields.v_make_desc")}
|
||||||
name={["vehicle", "data", "v_make_desc"]}
|
name={["vehicle", "data", "v_make_desc"]}
|
||||||
rules={[
|
rules={[
|
||||||
@@ -66,6 +68,7 @@ export default function JobsCreateVehicleInfoNewComponent() {
|
|||||||
<Input disabled={!state.vehicle.new} />
|
<Input disabled={!state.vehicle.new} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
|
span={11}
|
||||||
label={t("vehicles.fields.v_model_desc")}
|
label={t("vehicles.fields.v_model_desc")}
|
||||||
name={["vehicle", "data", "v_model_desc"]}
|
name={["vehicle", "data", "v_model_desc"]}
|
||||||
rules={[
|
rules={[
|
||||||
@@ -77,6 +80,11 @@ export default function JobsCreateVehicleInfoNewComponent() {
|
|||||||
>
|
>
|
||||||
<Input disabled={!state.vehicle.new} />
|
<Input disabled={!state.vehicle.new} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<JobsCreateVehicleInfoPredefined
|
||||||
|
disabled={!state.vehicle.new}
|
||||||
|
form={form}
|
||||||
|
span={1}
|
||||||
|
/>
|
||||||
</LayoutFormRow>
|
</LayoutFormRow>
|
||||||
|
|
||||||
<LayoutFormRow header={t("vehicles.forms.registration")} grow>
|
<LayoutFormRow header={t("vehicles.forms.registration")} grow>
|
||||||
|
|||||||
@@ -0,0 +1,81 @@
|
|||||||
|
import { PlusOutlined, SearchOutlined } from "@ant-design/icons";
|
||||||
|
import { Button, Input, Popover, Table } from "antd";
|
||||||
|
import React, { useState } from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import PredefinedVehicles from "./predefined-vehicles.js";
|
||||||
|
|
||||||
|
export default function JobsCreateVehicleInfoPredefined({ disabled, form }) {
|
||||||
|
const [open, setOpen] = useState(false);
|
||||||
|
const [search, setSearch] = useState("");
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const handleOpenChange = (newOpen) => {
|
||||||
|
setOpen(newOpen);
|
||||||
|
setSearch("");
|
||||||
|
};
|
||||||
|
const filteredPredefinedVehicles =
|
||||||
|
search === ""
|
||||||
|
? PredefinedVehicles
|
||||||
|
: PredefinedVehicles.filter(
|
||||||
|
(v) =>
|
||||||
|
v.make.toLowerCase().includes(search.toLowerCase()) ||
|
||||||
|
v.model.toLowerCase().includes(search.toLowerCase())
|
||||||
|
);
|
||||||
|
|
||||||
|
const popContent = () => (
|
||||||
|
<div>
|
||||||
|
<Table
|
||||||
|
size="small"
|
||||||
|
title={() => <Input.Search onSearch={(value) => setSearch(value)} />}
|
||||||
|
dataSource={filteredPredefinedVehicles}
|
||||||
|
columns={[
|
||||||
|
{
|
||||||
|
dataIndex: "make",
|
||||||
|
key: "make",
|
||||||
|
title: t("vehicles.fields.v_make_desc"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dataIndex: "model",
|
||||||
|
key: "model",
|
||||||
|
title: t("vehicles.fields.v_model_desc"),
|
||||||
|
},
|
||||||
|
{
|
||||||
|
dataIndex: "select",
|
||||||
|
key: "select",
|
||||||
|
title: t("general.labels.actions"),
|
||||||
|
render: (value, record) => (
|
||||||
|
<Button
|
||||||
|
disabled={disabled}
|
||||||
|
onClick={() => {
|
||||||
|
form.setFieldsValue({
|
||||||
|
vehicle: {
|
||||||
|
data: {
|
||||||
|
v_make_desc: record.make,
|
||||||
|
v_model_desc: record.model,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
|
setOpen(false);
|
||||||
|
setSearch("");
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<PlusOutlined />
|
||||||
|
</Button>
|
||||||
|
),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
return (
|
||||||
|
<Popover
|
||||||
|
content={popContent}
|
||||||
|
trigger="click"
|
||||||
|
open={open}
|
||||||
|
placement="left"
|
||||||
|
onOpenChange={handleOpenChange}
|
||||||
|
destroyTooltipOnHide
|
||||||
|
>
|
||||||
|
<SearchOutlined style={{ cursor: "pointer" }} />
|
||||||
|
</Popover>
|
||||||
|
);
|
||||||
|
}
|
||||||
File diff suppressed because it is too large
Load Diff
@@ -256,7 +256,7 @@ export function JobsDetailGeneral({ bodyshop, jobRO, job, form }) {
|
|||||||
</FormRow>
|
</FormRow>
|
||||||
<FormRow header={t("jobs.forms.other")}>
|
<FormRow header={t("jobs.forms.other")}>
|
||||||
<Form.Item label={t("jobs.fields.category")} name="category">
|
<Form.Item label={t("jobs.fields.category")} name="category">
|
||||||
<Select disabled={jobRO}>
|
<Select disabled={jobRO} allowClear>
|
||||||
{bodyshop.md_categories.map((s) => (
|
{bodyshop.md_categories.map((s) => (
|
||||||
<Select.Option key={s} value={s}>
|
<Select.Option key={s} value={s}>
|
||||||
{s}
|
{s}
|
||||||
@@ -289,6 +289,12 @@ export function JobsDetailGeneral({ bodyshop, jobRO, job, form }) {
|
|||||||
>
|
>
|
||||||
<Input disabled={jobRO} />
|
<Input disabled={jobRO} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
label={t("jobs.fields.lost_sale_reason")}
|
||||||
|
name="lost_sale_reason"
|
||||||
|
>
|
||||||
|
<Input disabled={jobRO} allowClear />
|
||||||
|
</Form.Item>
|
||||||
</FormRow>
|
</FormRow>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,6 +1,15 @@
|
|||||||
import { DownCircleFilled } from "@ant-design/icons";
|
import { DownCircleFilled } from "@ant-design/icons";
|
||||||
import { useApolloClient, useMutation } from "@apollo/client";
|
import { useApolloClient, useMutation } from "@apollo/client";
|
||||||
import { Button, Dropdown, Menu, notification, Popconfirm } from "antd";
|
import {
|
||||||
|
Button,
|
||||||
|
Dropdown,
|
||||||
|
Form,
|
||||||
|
Menu,
|
||||||
|
notification,
|
||||||
|
Popconfirm,
|
||||||
|
Popover,
|
||||||
|
Select,
|
||||||
|
} from "antd";
|
||||||
import React, { useMemo } from "react";
|
import React, { useMemo } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
@@ -127,35 +136,63 @@ export function JobsDetailHeaderActions({
|
|||||||
<Menu.Item
|
<Menu.Item
|
||||||
disabled={job.status !== bodyshop.md_ro_statuses.default_scheduled}
|
disabled={job.status !== bodyshop.md_ro_statuses.default_scheduled}
|
||||||
>
|
>
|
||||||
<Popconfirm
|
<Popover
|
||||||
title={t("general.labels.areyousure")}
|
trigger="click"
|
||||||
okText="Yes"
|
|
||||||
cancelText="No"
|
|
||||||
onClick={(e) => e.stopPropagation()}
|
|
||||||
disabled={job.status !== bodyshop.md_ro_statuses.default_scheduled}
|
disabled={job.status !== bodyshop.md_ro_statuses.default_scheduled}
|
||||||
onConfirm={async () => {
|
content={
|
||||||
const jobUpdate = await cancelAllAppointments({
|
<Form
|
||||||
variables: {
|
layout="vertical"
|
||||||
jobid: job.id,
|
onFinish={async ({ lost_sale_reason }) => {
|
||||||
job: {
|
const jobUpdate = await cancelAllAppointments({
|
||||||
date_scheduled: null,
|
variables: {
|
||||||
scheduled_in: null,
|
jobid: job.id,
|
||||||
scheduled_completion: null,
|
job: {
|
||||||
status: bodyshop.md_ro_statuses.default_imported,
|
date_scheduled: null,
|
||||||
},
|
scheduled_in: null,
|
||||||
},
|
scheduled_completion: null,
|
||||||
});
|
lost_sale_reason,
|
||||||
if (!jobUpdate.errors) {
|
status: bodyshop.md_ro_statuses.default_imported,
|
||||||
notification["success"]({
|
},
|
||||||
message: t("appointments.successes.canceled"),
|
},
|
||||||
});
|
});
|
||||||
return;
|
if (!jobUpdate.errors) {
|
||||||
}
|
notification["success"]({
|
||||||
}}
|
message: t("appointments.successes.canceled"),
|
||||||
getPopupContainer={(trigger) => trigger.parentNode}
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Form.Item
|
||||||
|
name="lost_sale_reason"
|
||||||
|
label={t("jobs.fields.lost_sale_reason")}
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
>
|
||||||
|
<Select
|
||||||
|
options={bodyshop.md_lost_sale_reasons.map((lsr) => ({
|
||||||
|
label: lsr,
|
||||||
|
value: lsr,
|
||||||
|
}))}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
<Button
|
||||||
|
htmlType="submit"
|
||||||
|
disabled={
|
||||||
|
job.status !== bodyshop.md_ro_statuses.default_scheduled
|
||||||
|
}
|
||||||
|
>
|
||||||
|
{t("appointments.actions.cancel")}
|
||||||
|
</Button>
|
||||||
|
</Form>
|
||||||
|
}
|
||||||
>
|
>
|
||||||
{t("menus.jobsactions.cancelallappointments")}
|
{t("menus.jobsactions.cancelallappointments")}
|
||||||
</Popconfirm>
|
</Popover>
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
<Menu.Item
|
<Menu.Item
|
||||||
disabled={
|
disabled={
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import {
|
|||||||
BranchesOutlined,
|
BranchesOutlined,
|
||||||
} from "@ant-design/icons";
|
} from "@ant-design/icons";
|
||||||
import { Card, Col, Row, Space, Tag, Tooltip } from "antd";
|
import { Card, Col, Row, Space, Tag, Tooltip } from "antd";
|
||||||
import React from "react";
|
import React, { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
@@ -56,7 +56,7 @@ const colSpan = {
|
|||||||
|
|
||||||
export function JobsDetailHeader({ job, bodyshop, disabled }) {
|
export function JobsDetailHeader({ job, bodyshop, disabled }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const [notesClamped, setNotesClamped] = useState(true);
|
||||||
const vehicleTitle = `${job.v_model_yr || ""} ${job.v_color || ""}
|
const vehicleTitle = `${job.v_model_yr || ""} ${job.v_color || ""}
|
||||||
${job.v_make_desc || ""}
|
${job.v_make_desc || ""}
|
||||||
${job.v_model_desc || ""}`.trim();
|
${job.v_model_desc || ""}`.trim();
|
||||||
@@ -229,6 +229,8 @@ export function JobsDetailHeader({ job, bodyshop, disabled }) {
|
|||||||
<DataLabel
|
<DataLabel
|
||||||
label={t("vehicles.fields.notes")}
|
label={t("vehicles.fields.notes")}
|
||||||
valueStyle={{ whiteSpace: "pre-wrap" }}
|
valueStyle={{ whiteSpace: "pre-wrap" }}
|
||||||
|
valueClassName={notesClamped ? "clamp" : ""}
|
||||||
|
onValueClick={() => setNotesClamped(!notesClamped)}
|
||||||
>
|
>
|
||||||
{job.vehicle.notes}
|
{job.vehicle.notes}
|
||||||
</DataLabel>
|
</DataLabel>
|
||||||
|
|||||||
@@ -6,3 +6,12 @@
|
|||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.clamp {
|
||||||
|
-webkit-line-clamp: 3;
|
||||||
|
-webkit-box-orient: vertical;
|
||||||
|
display: -webkit-box;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
overflow-wrap: break-word;
|
||||||
|
}
|
||||||
|
|||||||
@@ -40,24 +40,26 @@ export function JobsDetailRates({ jobRO, form, job, bodyshop }) {
|
|||||||
>
|
>
|
||||||
<CurrencyInput disabled={jobRO} min={0} />
|
<CurrencyInput disabled={jobRO} min={0} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Tooltip title={t("jobs.labels.ca_gst_all_if_null")}>
|
{bodyshop.region_config.toLowerCase().startsWith("ca") && (
|
||||||
<Form.Item
|
<Tooltip title={t("jobs.labels.ca_gst_all_if_null")}>
|
||||||
label={t("jobs.fields.ca_customer_gst")}
|
<Form.Item
|
||||||
name="ca_customer_gst"
|
label={t("jobs.fields.ca_customer_gst")}
|
||||||
>
|
name="ca_customer_gst"
|
||||||
<CurrencyInput
|
>
|
||||||
disabled={jobRO}
|
<CurrencyInput
|
||||||
min={0}
|
disabled={jobRO}
|
||||||
max={
|
min={0}
|
||||||
Math.round(
|
max={
|
||||||
(job.job_totals &&
|
Math.round(
|
||||||
job.job_totals.totals.federal_tax.amount) ||
|
(job.job_totals &&
|
||||||
0
|
job.job_totals.totals.federal_tax.amount) ||
|
||||||
) / 100
|
0
|
||||||
}
|
) / 100
|
||||||
/>
|
}
|
||||||
</Form.Item>
|
/>
|
||||||
</Tooltip>
|
</Form.Item>
|
||||||
|
</Tooltip>
|
||||||
|
)}
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={t("jobs.fields.other_amount_payable")}
|
label={t("jobs.fields.other_amount_payable")}
|
||||||
name="other_amount_payable"
|
name="other_amount_payable"
|
||||||
@@ -82,12 +84,14 @@ export function JobsDetailRates({ jobRO, form, job, bodyshop }) {
|
|||||||
>
|
>
|
||||||
<CurrencyInput disabled={jobRO || bodyshop.cdk_dealerid} />
|
<CurrencyInput disabled={jobRO || bodyshop.cdk_dealerid} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Space align="end">
|
{bodyshop.region_config === "CA_BC" && (
|
||||||
<Form.Item label={t("jobs.fields.ca_bc_pvrt")} name="ca_bc_pvrt">
|
<Space align="center">
|
||||||
<CurrencyInput disabled={jobRO} min={0} />
|
<Form.Item label={t("jobs.fields.ca_bc_pvrt")} name="ca_bc_pvrt">
|
||||||
</Form.Item>
|
<CurrencyInput disabled={jobRO} min={0} />
|
||||||
<CABCpvrtCalculator form={form} disabled={jobRO} />
|
</Form.Item>
|
||||||
</Space>
|
<CABCpvrtCalculator form={form} disabled={jobRO} />
|
||||||
|
</Space>
|
||||||
|
)}
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={t("jobs.fields.auto_add_ats")}
|
label={t("jobs.fields.auto_add_ats")}
|
||||||
name="auto_add_ats"
|
name="auto_add_ats"
|
||||||
@@ -141,13 +145,15 @@ export function JobsDetailRates({ jobRO, form, job, bodyshop }) {
|
|||||||
>
|
>
|
||||||
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
<InputNumber min={0} max={1} precision={2} disabled={jobRO} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
{bodyshop.region_config.toLowerCase().startsWith("ca") && (
|
||||||
label={t("jobs.fields.ca_gst_registrant")}
|
<Form.Item
|
||||||
name="ca_gst_registrant"
|
label={t("jobs.fields.ca_gst_registrant")}
|
||||||
valuePropName="checked"
|
name="ca_gst_registrant"
|
||||||
>
|
valuePropName="checked"
|
||||||
<Switch disabled={jobRO} />
|
>
|
||||||
</Form.Item>
|
<Switch disabled={jobRO} />
|
||||||
|
</Form.Item>
|
||||||
|
)}
|
||||||
</FormRow>
|
</FormRow>
|
||||||
<Divider
|
<Divider
|
||||||
orientation="left"
|
orientation="left"
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import { useTranslation } from "react-i18next";
|
|||||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||||
import cleanAxios from "../../utils/CleanAxios";
|
import cleanAxios from "../../utils/CleanAxios";
|
||||||
import formatBytes from "../../utils/formatbytes";
|
import formatBytes from "../../utils/formatbytes";
|
||||||
import yauzl from "yauzl";
|
//import yauzl from "yauzl";
|
||||||
import { useTreatments } from "@splitsoftware/splitio-react";
|
import { useTreatments } from "@splitsoftware/splitio-react";
|
||||||
|
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
@@ -69,44 +69,44 @@ export function JobsDocumentsDownloadButton({
|
|||||||
setDownload(null);
|
setDownload(null);
|
||||||
if (Direct_Media_Download.treatment === "on") {
|
if (Direct_Media_Download.treatment === "on") {
|
||||||
try {
|
try {
|
||||||
const parentDir = await window.showDirectoryPicker({
|
// const parentDir = await window.showDirectoryPicker({
|
||||||
id: "media",
|
// id: "media",
|
||||||
startIn: "downloads",
|
// startIn: "downloads",
|
||||||
});
|
// });
|
||||||
|
|
||||||
const directory = await parentDir.getDirectoryHandle(identifier, {
|
// const directory = await parentDir.getDirectoryHandle(identifier, {
|
||||||
create: true,
|
// create: true,
|
||||||
});
|
// });
|
||||||
|
|
||||||
yauzl.fromBuffer(
|
// yauzl.fromBuffer(
|
||||||
Buffer.from(theDownloadedZip.data),
|
// Buffer.from(theDownloadedZip.data),
|
||||||
{},
|
// {},
|
||||||
(err, zipFile) => {
|
// (err, zipFile) => {
|
||||||
if (err) throw err;
|
// if (err) throw err;
|
||||||
zipFile.on("entry", (entry) => {
|
// zipFile.on("entry", (entry) => {
|
||||||
zipFile.openReadStream(entry, async (readErr, readStream) => {
|
// zipFile.openReadStream(entry, async (readErr, readStream) => {
|
||||||
if (readErr) {
|
// if (readErr) {
|
||||||
zipFile.close();
|
// zipFile.close();
|
||||||
throw readErr;
|
// throw readErr;
|
||||||
}
|
// }
|
||||||
if (err) throw err;
|
// if (err) throw err;
|
||||||
let fileSystemHandle = await directory.getFileHandle(
|
// let fileSystemHandle = await directory.getFileHandle(
|
||||||
entry.fileName,
|
// entry.fileName,
|
||||||
{
|
// {
|
||||||
create: true,
|
// create: true,
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
const writable = await fileSystemHandle.createWritable();
|
// const writable = await fileSystemHandle.createWritable();
|
||||||
readStream.on("data", async function (chunk) {
|
// readStream.on("data", async function (chunk) {
|
||||||
await writable.write(chunk);
|
// await writable.write(chunk);
|
||||||
});
|
// });
|
||||||
readStream.on("end", async function () {
|
// readStream.on("end", async function () {
|
||||||
await writable.close();
|
// await writable.close();
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
);
|
// );
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e);
|
console.log(e);
|
||||||
standardMediaDownload(theDownloadedZip.data);
|
standardMediaDownload(theDownloadedZip.data);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { EditFilled, FileExcelFilled, SyncOutlined } from "@ant-design/icons";
|
import { EditFilled, FileExcelFilled, SyncOutlined } from "@ant-design/icons";
|
||||||
import { Button, Card, Col, Row, Space } from "antd";
|
import { Button, Card, Col, Row, Space } from "antd";
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import Gallery from "react-grid-gallery";
|
import { Gallery } from "react-grid-gallery";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import DocumentsUploadComponent from "../documents-upload/documents-upload.component";
|
import DocumentsUploadComponent from "../documents-upload/documents-upload.component";
|
||||||
import { DetermineFileType } from "../documents-upload/documents-upload.utility";
|
import { DetermineFileType } from "../documents-upload/documents-upload.utility";
|
||||||
@@ -11,6 +11,9 @@ import JobsDocumentsGalleryReassign from "./jobs-document-gallery.reassign.compo
|
|||||||
import JobsDocumentsDeleteButton from "./jobs-documents-gallery.delete.component";
|
import JobsDocumentsDeleteButton from "./jobs-documents-gallery.delete.component";
|
||||||
import JobsDocumentsGallerySelectAllComponent from "./jobs-documents-gallery.selectall.component";
|
import JobsDocumentsGallerySelectAllComponent from "./jobs-documents-gallery.selectall.component";
|
||||||
|
|
||||||
|
import Lightbox from "react-image-lightbox";
|
||||||
|
import "react-image-lightbox/style.css";
|
||||||
|
|
||||||
function JobsDocumentsComponent({
|
function JobsDocumentsComponent({
|
||||||
data,
|
data,
|
||||||
jobId,
|
jobId,
|
||||||
@@ -23,11 +26,7 @@ function JobsDocumentsComponent({
|
|||||||
}) {
|
}) {
|
||||||
const [galleryImages, setgalleryImages] = useState({ images: [], other: [] });
|
const [galleryImages, setgalleryImages] = useState({ images: [], other: [] });
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [index, setIndex] = useState(0);
|
const [modalState, setModalState] = useState({ open: false, index: 0 });
|
||||||
|
|
||||||
const onCurrentImageChange = (index) => {
|
|
||||||
setIndex(index);
|
|
||||||
};
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
let documents = data.reduce(
|
let documents = data.reduce(
|
||||||
@@ -35,14 +34,16 @@ function JobsDocumentsComponent({
|
|||||||
const fileType = DetermineFileType(value.type);
|
const fileType = DetermineFileType(value.type);
|
||||||
if (value.type.startsWith("image")) {
|
if (value.type.startsWith("image")) {
|
||||||
acc.images.push({
|
acc.images.push({
|
||||||
src: GenerateSrcUrl(value),
|
// src: GenerateSrcUrl(value),
|
||||||
thumbnail: GenerateThumbUrl(value),
|
src: GenerateThumbUrl(value),
|
||||||
thumbnailHeight: 225,
|
// src: GenerateSrcUrl(value),
|
||||||
thumbnailWidth: 225,
|
// thumbnail: GenerateThumbUrl(value),
|
||||||
|
fullsize: GenerateSrcUrl(value),
|
||||||
|
height: 225,
|
||||||
|
width: 225,
|
||||||
isSelected: false,
|
isSelected: false,
|
||||||
key: value.key,
|
key: value.key,
|
||||||
extension: value.extension,
|
extension: value.extension,
|
||||||
|
|
||||||
id: value.id,
|
id: value.id,
|
||||||
type: value.type,
|
type: value.type,
|
||||||
size: value.size,
|
size: value.size,
|
||||||
@@ -62,7 +63,7 @@ function JobsDocumentsComponent({
|
|||||||
const fileName = value.key.split("/").pop();
|
const fileName = value.key.split("/").pop();
|
||||||
acc.other.push({
|
acc.other.push({
|
||||||
source: GenerateSrcUrl(value),
|
source: GenerateSrcUrl(value),
|
||||||
src: "",
|
src: thumb,
|
||||||
thumbnail: thumb,
|
thumbnail: thumb,
|
||||||
tags: [
|
tags: [
|
||||||
{
|
{
|
||||||
@@ -85,10 +86,9 @@ function JobsDocumentsComponent({
|
|||||||
]
|
]
|
||||||
: []),
|
: []),
|
||||||
],
|
],
|
||||||
thumbnailHeight: 225,
|
height: 225,
|
||||||
thumbnailWidth: 225,
|
width: 225,
|
||||||
isSelected: false,
|
isSelected: false,
|
||||||
|
|
||||||
extension: value.extension,
|
extension: value.extension,
|
||||||
key: value.key,
|
key: value.key,
|
||||||
id: value.id,
|
id: value.id,
|
||||||
@@ -148,35 +148,15 @@ function JobsDocumentsComponent({
|
|||||||
<Card title={t("jobs.labels.documents-images")}>
|
<Card title={t("jobs.labels.documents-images")}>
|
||||||
<Gallery
|
<Gallery
|
||||||
images={galleryImages.images}
|
images={galleryImages.images}
|
||||||
backdropClosesModal={true}
|
onClick={(index, item) => {
|
||||||
currentImageWillChange={onCurrentImageChange}
|
setModalState({ open: true, index: index });
|
||||||
customControls={[
|
// window.open(
|
||||||
<Button
|
// item.fullsize,
|
||||||
key="edit-button"
|
// "_blank",
|
||||||
style={{
|
// "toolbar=0,location=0,menubar=0"
|
||||||
float: "right",
|
// );
|
||||||
zIndex: "5",
|
|
||||||
}}
|
|
||||||
onClick={() => {
|
|
||||||
const newWindow = window.open(
|
|
||||||
`${window.location.protocol}//${window.location.host}/edit?documentId=${galleryImages.images[index].id}`,
|
|
||||||
"_blank",
|
|
||||||
"noopener,noreferrer"
|
|
||||||
);
|
|
||||||
if (newWindow) newWindow.opener = null;
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<EditFilled />
|
|
||||||
</Button>,
|
|
||||||
]}
|
|
||||||
onClickImage={(props) => {
|
|
||||||
window.open(
|
|
||||||
props.target.src,
|
|
||||||
"_blank",
|
|
||||||
"toolbar=0,location=0,menubar=0"
|
|
||||||
);
|
|
||||||
}}
|
}}
|
||||||
onSelectImage={(index, image) => {
|
onSelect={(index, image) => {
|
||||||
setgalleryImages({
|
setgalleryImages({
|
||||||
...galleryImages,
|
...galleryImages,
|
||||||
images: galleryImages.images.map((g, idx) =>
|
images: galleryImages.images.map((g, idx) =>
|
||||||
@@ -191,8 +171,6 @@ function JobsDocumentsComponent({
|
|||||||
<Card title={t("jobs.labels.documents-other")}>
|
<Card title={t("jobs.labels.documents-other")}>
|
||||||
<Gallery
|
<Gallery
|
||||||
images={galleryImages.other}
|
images={galleryImages.other}
|
||||||
backdropClosesModal={true}
|
|
||||||
enableLightbox={false}
|
|
||||||
thumbnailStyle={() => {
|
thumbnailStyle={() => {
|
||||||
return {
|
return {
|
||||||
backgroundImage: <FileExcelFilled />,
|
backgroundImage: <FileExcelFilled />,
|
||||||
@@ -201,14 +179,14 @@ function JobsDocumentsComponent({
|
|||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
onClickThumbnail={(index) => {
|
onClick={(index) => {
|
||||||
window.open(
|
window.open(
|
||||||
galleryImages.other[index].source,
|
galleryImages.other[index].source,
|
||||||
"_blank",
|
"_blank",
|
||||||
"toolbar=0,location=0,menubar=0"
|
"toolbar=0,location=0,menubar=0"
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
onSelectImage={(index) => {
|
onSelect={(index) => {
|
||||||
setgalleryImages({
|
setgalleryImages({
|
||||||
...galleryImages,
|
...galleryImages,
|
||||||
other: galleryImages.other.map((g, idx) =>
|
other: galleryImages.other.map((g, idx) =>
|
||||||
@@ -219,6 +197,53 @@ function JobsDocumentsComponent({
|
|||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
</Col>
|
</Col>
|
||||||
|
{modalState.open && (
|
||||||
|
<Lightbox
|
||||||
|
toolbarButtons={[
|
||||||
|
<EditFilled
|
||||||
|
onClick={() => {
|
||||||
|
const newWindow = window.open(
|
||||||
|
`${window.location.protocol}//${
|
||||||
|
window.location.host
|
||||||
|
}/edit?documentId=${
|
||||||
|
galleryImages.images[modalState.index].id
|
||||||
|
}`,
|
||||||
|
"_blank",
|
||||||
|
"noopener,noreferrer"
|
||||||
|
);
|
||||||
|
if (newWindow) newWindow.opener = null;
|
||||||
|
}}
|
||||||
|
/>,
|
||||||
|
]}
|
||||||
|
mainSrc={galleryImages.images[modalState.index].fullsize}
|
||||||
|
nextSrc={
|
||||||
|
galleryImages.images[
|
||||||
|
(modalState.index + 1) % galleryImages.images.length
|
||||||
|
].fullsize
|
||||||
|
}
|
||||||
|
prevSrc={
|
||||||
|
galleryImages.images[
|
||||||
|
(modalState.index + galleryImages.images.length - 1) %
|
||||||
|
galleryImages.images.length
|
||||||
|
].fullsize
|
||||||
|
}
|
||||||
|
onCloseRequest={() => setModalState({ open: false, index: 0 })}
|
||||||
|
onMovePrevRequest={() =>
|
||||||
|
setModalState({
|
||||||
|
...modalState,
|
||||||
|
index:
|
||||||
|
(modalState.index + galleryImages.images.length - 1) %
|
||||||
|
galleryImages.images.length,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
onMoveNextRequest={() =>
|
||||||
|
setModalState({
|
||||||
|
...modalState,
|
||||||
|
index: (modalState.index + 1) % galleryImages.images.length,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</Row>
|
</Row>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, { useEffect } from "react";
|
import React, { useEffect } from "react";
|
||||||
import Gallery from "react-grid-gallery";
|
import { Gallery } from "react-grid-gallery";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { GenerateSrcUrl, GenerateThumbUrl } from "./job-documents.utility";
|
import { GenerateThumbUrl } from "./job-documents.utility";
|
||||||
|
|
||||||
function JobsDocumentGalleryExternal({
|
function JobsDocumentGalleryExternal({
|
||||||
data,
|
data,
|
||||||
@@ -15,8 +15,8 @@ function JobsDocumentGalleryExternal({
|
|||||||
let documents = data.reduce((acc, value) => {
|
let documents = data.reduce((acc, value) => {
|
||||||
if (value.type.startsWith("image")) {
|
if (value.type.startsWith("image")) {
|
||||||
acc.push({
|
acc.push({
|
||||||
src: GenerateSrcUrl(value),
|
//src: GenerateSrcUrl(value),
|
||||||
thumbnail: GenerateThumbUrl(value),
|
src: GenerateThumbUrl(value),
|
||||||
thumbnailHeight: 225,
|
thumbnailHeight: 225,
|
||||||
thumbnailWidth: 225,
|
thumbnailWidth: 225,
|
||||||
isSelected: false,
|
isSelected: false,
|
||||||
@@ -39,7 +39,7 @@ function JobsDocumentGalleryExternal({
|
|||||||
<Gallery
|
<Gallery
|
||||||
images={galleryImages}
|
images={galleryImages}
|
||||||
backdropClosesModal={true}
|
backdropClosesModal={true}
|
||||||
onSelectImage={(index, image) => {
|
onSelect={(index, image) => {
|
||||||
setgalleryImages(
|
setgalleryImages(
|
||||||
galleryImages.map((g, idx) =>
|
galleryImages.map((g, idx) =>
|
||||||
index === idx ? { ...g, isSelected: !g.isSelected } : g
|
index === idx ? { ...g, isSelected: !g.isSelected } : g
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import { SyncOutlined, FileExcelFilled } from "@ant-design/icons";
|
import { SyncOutlined, FileExcelFilled } from "@ant-design/icons";
|
||||||
import { Alert, Button, Card, Space } from "antd";
|
import { Alert, Button, Card, Space } from "antd";
|
||||||
import React, { useEffect } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import Gallery from "react-grid-gallery";
|
import { Gallery } from "react-grid-gallery";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
@@ -19,6 +19,9 @@ import JobsLocalGalleryDownloadButton from "./jobs-documents-local-gallery.downl
|
|||||||
import JobsDocumentsLocalGalleryReassign from "./jobs-documents-local-gallery.reassign.component";
|
import JobsDocumentsLocalGalleryReassign from "./jobs-documents-local-gallery.reassign.component";
|
||||||
import JobsDocumentsLocalGallerySelectAllComponent from "./jobs-documents-local-gallery.selectall.component";
|
import JobsDocumentsLocalGallerySelectAllComponent from "./jobs-documents-local-gallery.selectall.component";
|
||||||
|
|
||||||
|
import Lightbox from "react-image-lightbox";
|
||||||
|
import "react-image-lightbox/style.css";
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
allMedia: selectAllMedia,
|
allMedia: selectAllMedia,
|
||||||
@@ -49,6 +52,7 @@ export function JobsDocumentsLocalGallery({
|
|||||||
vendorid,
|
vendorid,
|
||||||
}) {
|
}) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
const [modalState, setModalState] = useState({ open: false, index: 0 });
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (job) {
|
if (job) {
|
||||||
if (invoice_number) {
|
if (invoice_number) {
|
||||||
@@ -70,12 +74,20 @@ export function JobsDocumentsLocalGallery({
|
|||||||
) {
|
) {
|
||||||
acc.images.push({
|
acc.images.push({
|
||||||
...val,
|
...val,
|
||||||
|
fullsize: val.src,
|
||||||
|
src: val.thumbnail,
|
||||||
|
height: val.thumbnailHeight,
|
||||||
|
width: val.thumbnailWidth,
|
||||||
...(val.optimized && { src: val.optimized, fullsize: val.src }),
|
...(val.optimized && { src: val.optimized, fullsize: val.src }),
|
||||||
});
|
});
|
||||||
if (val.optimized) optimized = true;
|
if (val.optimized) optimized = true;
|
||||||
} else {
|
} else {
|
||||||
acc.other.push({
|
acc.other.push({
|
||||||
...val,
|
...val,
|
||||||
|
fullsize: val.src,
|
||||||
|
src: val.thumbnail,
|
||||||
|
height: val.thumbnailHeight,
|
||||||
|
width: val.thumbnailWidth,
|
||||||
tags: [{ value: val.filename, title: val.filename }],
|
tags: [{ value: val.filename, title: val.filename }],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -120,8 +132,7 @@ export function JobsDocumentsLocalGallery({
|
|||||||
<Card title={t("jobs.labels.documents-images")}>
|
<Card title={t("jobs.labels.documents-images")}>
|
||||||
<Gallery
|
<Gallery
|
||||||
images={jobMedia.images}
|
images={jobMedia.images}
|
||||||
backdropClosesModal={true}
|
onSelect={(index, image) => {
|
||||||
onSelectImage={(index, image) => {
|
|
||||||
toggleMediaSelected({ jobid: job.id, filename: image.filename });
|
toggleMediaSelected({ jobid: job.id, filename: image.filename });
|
||||||
}}
|
}}
|
||||||
{...(optimized && {
|
{...(optimized && {
|
||||||
@@ -133,24 +144,23 @@ export function JobsDocumentsLocalGallery({
|
|||||||
/>,
|
/>,
|
||||||
],
|
],
|
||||||
})}
|
})}
|
||||||
onClickImage={(props) => {
|
onClick={(index) => {
|
||||||
const media = allMedia[job.id].find(
|
setModalState({ open: true, index: index });
|
||||||
(m) => m.optimized === props.target.src
|
// const media = allMedia[job.id].find(
|
||||||
);
|
// (m) => m.optimized === item.src
|
||||||
|
// );
|
||||||
|
|
||||||
window.open(
|
// window.open(
|
||||||
media ? media.src : props.target.src,
|
// media ? media.fullsize : item.fullsize,
|
||||||
"_blank",
|
// "_blank",
|
||||||
"toolbar=0,location=0,menubar=0"
|
// "toolbar=0,location=0,menubar=0"
|
||||||
);
|
// );
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
<Card title={t("jobs.labels.documents-other")}>
|
<Card title={t("jobs.labels.documents-other")}>
|
||||||
<Gallery
|
<Gallery
|
||||||
images={jobMedia.other}
|
images={jobMedia.other}
|
||||||
backdropClosesModal={true}
|
|
||||||
enableLightbox={false}
|
|
||||||
thumbnailStyle={() => {
|
thumbnailStyle={() => {
|
||||||
return {
|
return {
|
||||||
backgroundImage: <FileExcelFilled />,
|
backgroundImage: <FileExcelFilled />,
|
||||||
@@ -159,18 +169,48 @@ export function JobsDocumentsLocalGallery({
|
|||||||
cursor: "pointer",
|
cursor: "pointer",
|
||||||
};
|
};
|
||||||
}}
|
}}
|
||||||
onClickThumbnail={(index) => {
|
onClick={(index) => {
|
||||||
window.open(
|
window.open(
|
||||||
jobMedia.other[index].src,
|
jobMedia.other[index].fullsize,
|
||||||
"_blank",
|
"_blank",
|
||||||
"toolbar=0,location=0,menubar=0"
|
"toolbar=0,location=0,menubar=0"
|
||||||
);
|
);
|
||||||
}}
|
}}
|
||||||
onSelectImage={(index, image) => {
|
onSelect={(index, image) => {
|
||||||
toggleMediaSelected({ jobid: job.id, filename: image.filename });
|
toggleMediaSelected({ jobid: job.id, filename: image.filename });
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
|
{modalState.open && (
|
||||||
|
<Lightbox
|
||||||
|
mainSrc={jobMedia.images[modalState.index].fullsize}
|
||||||
|
nextSrc={
|
||||||
|
jobMedia.images[(modalState.index + 1) % jobMedia.images.length]
|
||||||
|
.fullsize
|
||||||
|
}
|
||||||
|
prevSrc={
|
||||||
|
jobMedia.images[
|
||||||
|
(modalState.index + jobMedia.images.length - 1) %
|
||||||
|
jobMedia.images.length
|
||||||
|
].fullsize
|
||||||
|
}
|
||||||
|
onCloseRequest={() => setModalState({ open: false, index: 0 })}
|
||||||
|
onMovePrevRequest={() =>
|
||||||
|
setModalState({
|
||||||
|
...modalState,
|
||||||
|
index:
|
||||||
|
(modalState.index + jobMedia.images.length - 1) %
|
||||||
|
jobMedia.images.length,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
onMoveNextRequest={() =>
|
||||||
|
setModalState({
|
||||||
|
...modalState,
|
||||||
|
index: (modalState.index + 1) % jobMedia.images.length,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
import React, { useEffect } from "react";
|
import React, { useEffect } from "react";
|
||||||
import Gallery from "react-grid-gallery";
|
import { Gallery } from "react-grid-gallery";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
@@ -38,7 +38,7 @@ function JobDocumentsLocalGalleryExternal({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if ( jobId) {
|
if (jobId) {
|
||||||
getJobMedia(jobId);
|
getJobMedia(jobId);
|
||||||
}
|
}
|
||||||
}, [jobId, getJobMedia]);
|
}, [jobId, getJobMedia]);
|
||||||
@@ -52,11 +52,15 @@ function JobDocumentsLocalGalleryExternal({
|
|||||||
val.type.mime &&
|
val.type.mime &&
|
||||||
val.type.mime.startsWith("image")
|
val.type.mime.startsWith("image")
|
||||||
) {
|
) {
|
||||||
acc.push(val);
|
acc.push({ ...val, src: val.thumbnail });
|
||||||
}
|
}
|
||||||
return acc;
|
return acc;
|
||||||
}, [])
|
}, [])
|
||||||
: [];
|
: [];
|
||||||
|
console.log(
|
||||||
|
"🚀 ~ file: jobs-documents-local-gallery.external.component.jsx:48 ~ useEffect ~ documents:",
|
||||||
|
documents
|
||||||
|
);
|
||||||
|
|
||||||
setgalleryImages(documents);
|
setgalleryImages(documents);
|
||||||
}, [allMedia, jobId, setgalleryImages, t]);
|
}, [allMedia, jobId, setgalleryImages, t]);
|
||||||
@@ -65,8 +69,7 @@ function JobDocumentsLocalGalleryExternal({
|
|||||||
<div className="clearfix">
|
<div className="clearfix">
|
||||||
<Gallery
|
<Gallery
|
||||||
images={galleryImages}
|
images={galleryImages}
|
||||||
backdropClosesModal={true}
|
onSelect={(index, image) => {
|
||||||
onSelectImage={(index, image) => {
|
|
||||||
setgalleryImages(
|
setgalleryImages(
|
||||||
galleryImages.map((g, idx) =>
|
galleryImages.map((g, idx) =>
|
||||||
index === idx ? { ...g, isSelected: !g.isSelected } : g
|
index === idx ? { ...g, isSelected: !g.isSelected } : g
|
||||||
|
|||||||
@@ -182,7 +182,7 @@ export function JobsExportAllButton({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<Button onClick={handleQbxml} loading={loading} disabled={disabled}>
|
<Button onClick={handleQbxml} loading={loading} disabled={disabled}>
|
||||||
{t("jobs.actions.export")}
|
{t("jobs.actions.exportselected")}
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,9 @@
|
|||||||
import { SyncOutlined } from "@ant-design/icons";
|
import { SyncOutlined } from "@ant-design/icons";
|
||||||
import { Button, Card, Input, Space, Table, Typography } from "antd";
|
import { Button, Card, Input, Space, Table, Typography } from "antd";
|
||||||
|
import axios from "axios";
|
||||||
import _ from "lodash";
|
import _ from "lodash";
|
||||||
import queryString from "query-string";
|
import queryString from "query-string";
|
||||||
import React from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { Link, useHistory, useLocation } from "react-router-dom";
|
import { Link, useHistory, useLocation } from "react-router-dom";
|
||||||
@@ -21,6 +22,8 @@ const mapDispatchToProps = (dispatch) => ({
|
|||||||
|
|
||||||
export function JobsList({ bodyshop, refetch, loading, jobs, total }) {
|
export function JobsList({ bodyshop, refetch, loading, jobs, total }) {
|
||||||
const search = queryString.parse(useLocation().search);
|
const search = queryString.parse(useLocation().search);
|
||||||
|
const [openSearchResults, setOpenSearchResults] = useState([]);
|
||||||
|
const [searchLoading, setSearchLoading] = useState(false);
|
||||||
const { page, sortcolumn, sortorder } = search;
|
const { page, sortcolumn, sortorder } = search;
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
|
|
||||||
@@ -193,6 +196,28 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) {
|
|||||||
history.push({ search: queryString.stringify(search) });
|
history.push({ search: queryString.stringify(search) });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (search.search && search.search.trim() !== "") {
|
||||||
|
searchJobs();
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
async function searchJobs(value) {
|
||||||
|
try {
|
||||||
|
setSearchLoading(true);
|
||||||
|
const searchData = await axios.post("/search", {
|
||||||
|
search: value || search.search,
|
||||||
|
index: "jobs",
|
||||||
|
});
|
||||||
|
setOpenSearchResults(searchData.data.hits.hits.map((s) => s._source));
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error while fetching search results", error);
|
||||||
|
} finally {
|
||||||
|
setSearchLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
extra={
|
extra={
|
||||||
@@ -205,6 +230,7 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) {
|
|||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
delete search.search;
|
delete search.search;
|
||||||
|
delete search.page;
|
||||||
history.push({ search: queryString.stringify(search) });
|
history.push({ search: queryString.stringify(search) });
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -220,24 +246,32 @@ export function JobsList({ bodyshop, refetch, loading, jobs, total }) {
|
|||||||
onSearch={(value) => {
|
onSearch={(value) => {
|
||||||
search.search = value;
|
search.search = value;
|
||||||
history.push({ search: queryString.stringify(search) });
|
history.push({ search: queryString.stringify(search) });
|
||||||
|
searchJobs(value);
|
||||||
}}
|
}}
|
||||||
|
loading={loading || searchLoading}
|
||||||
enterButton
|
enterButton
|
||||||
/>
|
/>
|
||||||
</Space>
|
</Space>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Table
|
<Table
|
||||||
loading={loading}
|
loading={loading || searchLoading}
|
||||||
pagination={{
|
pagination={
|
||||||
position: "top",
|
search?.search
|
||||||
pageSize: 25,
|
? {
|
||||||
current: parseInt(page || 1),
|
pageSize: 25,
|
||||||
total: total,
|
showSizeChanger: false,
|
||||||
showSizeChanger: false,
|
}
|
||||||
}}
|
: {
|
||||||
|
pageSize: 25,
|
||||||
|
current: parseInt(page || 1),
|
||||||
|
total: total,
|
||||||
|
showSizeChanger: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
dataSource={jobs}
|
dataSource={search?.search ? openSearchResults : jobs}
|
||||||
onChange={handleTableChange}
|
onChange={handleTableChange}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -260,6 +260,19 @@ export function JobsList({ bodyshop }) {
|
|||||||
dataIndex: "ins_co_nm",
|
dataIndex: "ins_co_nm",
|
||||||
key: "ins_co_nm",
|
key: "ins_co_nm",
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
|
filters:
|
||||||
|
(jobs &&
|
||||||
|
jobs
|
||||||
|
.map((j) => j.ins_co_nm)
|
||||||
|
.filter(onlyUnique)
|
||||||
|
.map((s) => {
|
||||||
|
return {
|
||||||
|
text: s,
|
||||||
|
value: [s],
|
||||||
|
};
|
||||||
|
})) ||
|
||||||
|
[],
|
||||||
|
onFilter: (value, record) => value.includes(record.ins_co_nm),
|
||||||
responsive: ["md"],
|
responsive: ["md"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -75,6 +75,27 @@ export function JobNotesComponent({
|
|||||||
</span>
|
</span>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
title: t("notes.fields.type"),
|
||||||
|
dataIndex: "type",
|
||||||
|
key: "type",
|
||||||
|
width: 120,
|
||||||
|
filteredValue: filter?.type || null,
|
||||||
|
filters: [
|
||||||
|
{ value: "general", text: t("notes.fields.types.general") },
|
||||||
|
{ value: "customer", text: t("notes.fields.types.customer") },
|
||||||
|
{ value: "shop", text: t("notes.fields.types.shop") },
|
||||||
|
{ value: "office", text: t("notes.fields.types.office") },
|
||||||
|
{ value: "parts", text: t("notes.fields.types.parts") },
|
||||||
|
{ value: "paint", text: t("notes.fields.types.paint") },
|
||||||
|
{
|
||||||
|
value: "supplement",
|
||||||
|
text: t("notes.fields.types.supplement"),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
onFilter: (value, record) => value.includes(record.type),
|
||||||
|
render: (text, record) => t(`notes.fields.types.${record.type}`),
|
||||||
|
},
|
||||||
{
|
{
|
||||||
title: t("notes.fields.text"),
|
title: t("notes.fields.text"),
|
||||||
dataIndex: "text",
|
dataIndex: "text",
|
||||||
@@ -106,7 +127,7 @@ export function JobNotesComponent({
|
|||||||
title: t("notes.actions.actions"),
|
title: t("notes.actions.actions"),
|
||||||
dataIndex: "actions",
|
dataIndex: "actions",
|
||||||
key: "actions",
|
key: "actions",
|
||||||
width: 150,
|
width: 200,
|
||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<Space wrap>
|
<Space wrap>
|
||||||
<Button
|
<Button
|
||||||
|
|||||||
@@ -272,6 +272,19 @@ export function JobsReadyList({ bodyshop }) {
|
|||||||
dataIndex: "ins_co_nm",
|
dataIndex: "ins_co_nm",
|
||||||
key: "ins_co_nm",
|
key: "ins_co_nm",
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
|
filters:
|
||||||
|
(jobs &&
|
||||||
|
jobs
|
||||||
|
.map((j) => j.ins_co_nm)
|
||||||
|
.filter(onlyUnique)
|
||||||
|
.map((s) => {
|
||||||
|
return {
|
||||||
|
text: s,
|
||||||
|
value: [s],
|
||||||
|
};
|
||||||
|
})) ||
|
||||||
|
[],
|
||||||
|
onFilter: (value, record) => value.includes(record.ins_co_nm),
|
||||||
responsive: ["md"],
|
responsive: ["md"],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -207,7 +207,7 @@ export function LaborAllocationsTable({
|
|||||||
<Card title={t("jobs.labels.laborallocations")}>
|
<Card title={t("jobs.labels.laborallocations")}>
|
||||||
<Table
|
<Table
|
||||||
columns={columns}
|
columns={columns}
|
||||||
rowKey="cost_center"
|
rowKey={(record) => `${record.cost_center} ${record.mod_lbr_ty}`}
|
||||||
pagination={false}
|
pagination={false}
|
||||||
onChange={handleTableChange}
|
onChange={handleTableChange}
|
||||||
dataSource={totals}
|
dataSource={totals}
|
||||||
|
|||||||
@@ -6,10 +6,6 @@ export const CalculateAllocationsTotals = (
|
|||||||
timetickets,
|
timetickets,
|
||||||
adjustments = []
|
adjustments = []
|
||||||
) => {
|
) => {
|
||||||
console.log(
|
|
||||||
"🚀 ~ file: labor-allocations-table.utility.js ~ line 9 ~ adjustments",
|
|
||||||
adjustments
|
|
||||||
);
|
|
||||||
const responsibilitycenters = bodyshop.md_responsibility_centers;
|
const responsibilitycenters = bodyshop.md_responsibility_centers;
|
||||||
const jobCodes = joblines.map((item) => item.mod_lbr_ty);
|
const jobCodes = joblines.map((item) => item.mod_lbr_ty);
|
||||||
//.filter((value, index, self) => self.indexOf(value) === index && !!value);
|
//.filter((value, index, self) => self.indexOf(value) === index && !!value);
|
||||||
|
|||||||
@@ -1,4 +1,14 @@
|
|||||||
import { Checkbox, Col, Form, Input, Row, Space, Switch, Tag } from "antd";
|
import {
|
||||||
|
Checkbox,
|
||||||
|
Col,
|
||||||
|
Form,
|
||||||
|
Input,
|
||||||
|
Row,
|
||||||
|
Select,
|
||||||
|
Space,
|
||||||
|
Switch,
|
||||||
|
Tag,
|
||||||
|
} from "antd";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
@@ -46,6 +56,28 @@ export function NoteUpsertModalComponent({ form, noteUpsertModal }) {
|
|||||||
<Switch />
|
<Switch />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
</Col>
|
</Col>
|
||||||
|
<Col span={8}>
|
||||||
|
<Form.Item
|
||||||
|
label={t("notes.fields.type")}
|
||||||
|
name="type"
|
||||||
|
initialValue="general"
|
||||||
|
>
|
||||||
|
<Select
|
||||||
|
options={[
|
||||||
|
{ value: "general", label: t("notes.fields.types.general") },
|
||||||
|
{ value: "customer", label: t("notes.fields.types.customer") },
|
||||||
|
{ value: "shop", label: t("notes.fields.types.shop") },
|
||||||
|
{ value: "office", label: t("notes.fields.types.office") },
|
||||||
|
{ value: "parts", label: t("notes.fields.types.parts") },
|
||||||
|
{ value: "paint", label: t("notes.fields.types.paint") },
|
||||||
|
{
|
||||||
|
value: "supplement",
|
||||||
|
label: t("notes.fields.types.supplement"),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
/>
|
||||||
|
</Form.Item>
|
||||||
|
</Col>
|
||||||
<Col span={8}>
|
<Col span={8}>
|
||||||
<NotesPresetButton form={form} />
|
<NotesPresetButton form={form} />
|
||||||
</Col>
|
</Col>
|
||||||
|
|||||||
@@ -34,7 +34,7 @@ export function NoteUpsertModalContainer({
|
|||||||
const [updateNote] = useMutation(UPDATE_NOTE);
|
const [updateNote] = useMutation(UPDATE_NOTE);
|
||||||
|
|
||||||
const { visible, context, actions } = noteUpsertModal;
|
const { visible, context, actions } = noteUpsertModal;
|
||||||
const { jobId, existingNote } = context;
|
const { jobId, existingNote, text } = context;
|
||||||
const { refetch } = actions;
|
const { refetch } = actions;
|
||||||
|
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
@@ -45,8 +45,12 @@ export function NoteUpsertModalContainer({
|
|||||||
form.setFieldsValue(existingNote);
|
form.setFieldsValue(existingNote);
|
||||||
} else if (!existingNote && visible) {
|
} else if (!existingNote && visible) {
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
|
|
||||||
|
if (text) {
|
||||||
|
form.setFieldValue("text", text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [existingNote, form, visible]);
|
}, [existingNote, form, visible, text]);
|
||||||
|
|
||||||
const handleFinish = async (formValues) => {
|
const handleFinish = async (formValues) => {
|
||||||
const { relatedros, ...values } = formValues;
|
const { relatedros, ...values } = formValues;
|
||||||
@@ -82,6 +86,7 @@ export function NoteUpsertModalContainer({
|
|||||||
{ ...values, jobid: jobId, created_by: currentUser.email },
|
{ ...values, jobid: jobId, created_by: currentUser.email },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
|
refetchQueries: ["QUERY_NOTES_BY_JOB_PK"],
|
||||||
});
|
});
|
||||||
|
|
||||||
if (AdditionalNoteInserts.length > 0) {
|
if (AdditionalNoteInserts.length > 0) {
|
||||||
|
|||||||
@@ -1,15 +1,40 @@
|
|||||||
import { Button, Form, notification, PageHeader } from "antd";
|
import { Button, Form, notification, PageHeader, Popconfirm } from "antd";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
|
import { useHistory } from "react-router-dom";
|
||||||
import { useMutation } from "@apollo/client";
|
import { useMutation } from "@apollo/client";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { UPDATE_OWNER } from "../../graphql/owners.queries";
|
import { DELETE_OWNER, UPDATE_OWNER } from "../../graphql/owners.queries";
|
||||||
import OwnerDetailFormComponent from "./owner-detail-form.component";
|
import OwnerDetailFormComponent from "./owner-detail-form.component";
|
||||||
|
|
||||||
function OwnerDetailFormContainer({ owner, refetch }) {
|
function OwnerDetailFormContainer({ owner, refetch }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [form] = Form.useForm();
|
const [form] = Form.useForm();
|
||||||
|
const history = useHistory();
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const [updateOwner] = useMutation(UPDATE_OWNER);
|
const [updateOwner] = useMutation(UPDATE_OWNER);
|
||||||
|
const [deleteOwner] = useMutation(DELETE_OWNER);
|
||||||
|
|
||||||
|
const handleDelete = async () => {
|
||||||
|
setLoading(true);
|
||||||
|
const result = await deleteOwner({
|
||||||
|
variables: { id: owner.id },
|
||||||
|
});
|
||||||
|
console.log(result);
|
||||||
|
if (result.errors) {
|
||||||
|
notification["error"]({
|
||||||
|
message: t("owners.errors.deleting", {
|
||||||
|
error: JSON.stringify(result.errors),
|
||||||
|
}),
|
||||||
|
});
|
||||||
|
setLoading(false);
|
||||||
|
} else {
|
||||||
|
notification["success"]({
|
||||||
|
message: t("owners.successes.delete"),
|
||||||
|
});
|
||||||
|
setLoading(false);
|
||||||
|
history.push(`/manage/owners`);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const handleFinish = async (values) => {
|
const handleFinish = async (values) => {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
@@ -41,15 +66,29 @@ function OwnerDetailFormContainer({ owner, refetch }) {
|
|||||||
<>
|
<>
|
||||||
<PageHeader
|
<PageHeader
|
||||||
title={t("menus.header.owners")}
|
title={t("menus.header.owners")}
|
||||||
extra={
|
extra={[
|
||||||
|
<Popconfirm
|
||||||
|
trigger="click"
|
||||||
|
onConfirm={handleDelete}
|
||||||
|
disabled={owner.jobs.length !== 0}
|
||||||
|
title={t("owners.labels.deleteconfirm")}
|
||||||
|
>
|
||||||
|
<Button
|
||||||
|
type="danger"
|
||||||
|
loading={loading}
|
||||||
|
disabled={owner.jobs.length !== 0}
|
||||||
|
>
|
||||||
|
{t("general.actions.delete")}
|
||||||
|
</Button>
|
||||||
|
</Popconfirm>,
|
||||||
<Button
|
<Button
|
||||||
type="primary"
|
type="primary"
|
||||||
loading={loading}
|
loading={loading}
|
||||||
onClick={() => form.submit()}
|
onClick={() => form.submit()}
|
||||||
>
|
>
|
||||||
{t("general.actions.save")}
|
{t("general.actions.save")}
|
||||||
</Button>
|
</Button>,
|
||||||
}
|
]}
|
||||||
/>
|
/>
|
||||||
<Form
|
<Form
|
||||||
form={form}
|
form={form}
|
||||||
|
|||||||
@@ -34,7 +34,9 @@ function OwnerDetailJobsComponent({ bodyshop, owner }) {
|
|||||||
render: (text, record) =>
|
render: (text, record) =>
|
||||||
record.vehicleid ? (
|
record.vehicleid ? (
|
||||||
<Link to={`/manage/vehicles/${record.vehicleid}`}>
|
<Link to={`/manage/vehicles/${record.vehicleid}`}>
|
||||||
{`${record.v_model_yr} ${record.v_make_desc} ${record.v_model_desc}`}
|
{`${record.v_model_yr || ""} ${record.v_make_desc || ""} ${
|
||||||
|
record.v_model_desc || ""
|
||||||
|
}`.trim()}
|
||||||
</Link>
|
</Link>
|
||||||
) : (
|
) : (
|
||||||
t("jobs.errors.novehicle")
|
t("jobs.errors.novehicle")
|
||||||
|
|||||||
@@ -201,6 +201,7 @@ export function PartsOrderListTableComponent({
|
|||||||
subject: record.return
|
subject: record.return
|
||||||
? Templates.parts_return_slip.subject
|
? Templates.parts_return_slip.subject
|
||||||
: Templates.parts_order.subject,
|
: Templates.parts_order.subject,
|
||||||
|
to: record.vendor.email,
|
||||||
}}
|
}}
|
||||||
id={job.id}
|
id={job.id}
|
||||||
/>
|
/>
|
||||||
@@ -296,7 +297,6 @@ export function PartsOrderListTableComponent({
|
|||||||
sortOrder:
|
sortOrder:
|
||||||
state.sortedInfo.columnKey === "quantity" && state.sortedInfo.order,
|
state.sortedInfo.columnKey === "quantity" && state.sortedInfo.order,
|
||||||
},
|
},
|
||||||
|
|
||||||
{
|
{
|
||||||
title: t("parts_orders.fields.act_price"),
|
title: t("parts_orders.fields.act_price"),
|
||||||
dataIndex: "act_price",
|
dataIndex: "act_price",
|
||||||
|
|||||||
@@ -1,12 +1,10 @@
|
|||||||
import { useTreatments } from "@splitsoftware/splitio-react";
|
import { useTreatments } from "@splitsoftware/splitio-react";
|
||||||
import { CardElement } from "@stripe/react-stripe-js";
|
import { Form, Input, Radio, Select } from "antd";
|
||||||
import { Checkbox, Form, Input, Radio, Select } from "antd";
|
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
import Alert from "../alert/alert.component";
|
|
||||||
import DatePickerFormItem from "../form-date-picker/form-date-picker.component";
|
import DatePickerFormItem from "../form-date-picker/form-date-picker.component";
|
||||||
import CurrencyInput from "../form-items-formatted/currency-form-item.component";
|
import CurrencyInput from "../form-items-formatted/currency-form-item.component";
|
||||||
import JobSearchSelect from "../job-search-select/job-search-select.component";
|
import JobSearchSelect from "../job-search-select/job-search-select.component";
|
||||||
@@ -19,11 +17,9 @@ const mapStateToProps = createStructuredSelector({
|
|||||||
|
|
||||||
export function PaymentFormComponent({
|
export function PaymentFormComponent({
|
||||||
form,
|
form,
|
||||||
stripeStateArr,
|
|
||||||
bodyshop,
|
bodyshop,
|
||||||
disabled,
|
disabled,
|
||||||
}) {
|
}) {
|
||||||
const [stripeState, setStripeState] = stripeStateArr;
|
|
||||||
const { Qb_Multi_Ar } = useTreatments(
|
const { Qb_Multi_Ar } = useTreatments(
|
||||||
["Qb_Multi_Ar"],
|
["Qb_Multi_Ar"],
|
||||||
{},
|
{},
|
||||||
@@ -31,9 +27,6 @@ export function PaymentFormComponent({
|
|||||||
);
|
);
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const handleStripeChange = (e) => {
|
|
||||||
setStripeState({ error: e.error, cardComplete: e.complete });
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
@@ -150,57 +143,6 @@ export function PaymentFormComponent({
|
|||||||
</Form.Item>
|
</Form.Item>
|
||||||
</LayoutFormRow>
|
</LayoutFormRow>
|
||||||
<LayoutFormRow grow>
|
<LayoutFormRow grow>
|
||||||
<div>
|
|
||||||
<Form.Item
|
|
||||||
label={t("payments.labels.electronicpayment")}
|
|
||||||
name="useStripe"
|
|
||||||
valuePropName="checked"
|
|
||||||
>
|
|
||||||
<Checkbox
|
|
||||||
defaultChecked={!!bodyshop.stripe_acct_id}
|
|
||||||
disabled={!!!bodyshop.stripe_acct_id || disabled}
|
|
||||||
/>
|
|
||||||
</Form.Item>
|
|
||||||
|
|
||||||
{!bodyshop.stripe_acct_id ? (
|
|
||||||
<div style={{ fontStyle: "italic" }}>
|
|
||||||
{t("payments.labels.signup")}
|
|
||||||
</div>
|
|
||||||
) : null}
|
|
||||||
|
|
||||||
<Form.Item shouldUpdate>
|
|
||||||
{() => {
|
|
||||||
if (form.getFieldValue("useStripe"))
|
|
||||||
return (
|
|
||||||
<CardElement
|
|
||||||
options={{
|
|
||||||
style: {
|
|
||||||
base: {
|
|
||||||
color: "#32325d",
|
|
||||||
//fontFamily: '"Helvetica Neue", Helvetica, sans-serif',
|
|
||||||
fontSmoothing: "antialiased",
|
|
||||||
//fontSize: "16px",
|
|
||||||
"::placeholder": {
|
|
||||||
color: "#aab7c4",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
invalid: {
|
|
||||||
color: "#fa755a",
|
|
||||||
iconColor: "#fa755a",
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}}
|
|
||||||
onChange={handleStripeChange}
|
|
||||||
/>
|
|
||||||
);
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}}
|
|
||||||
</Form.Item>
|
|
||||||
{stripeState.error ? (
|
|
||||||
<Alert type="error" message={stripeState.error.message} />
|
|
||||||
) : null}
|
|
||||||
</div>
|
|
||||||
<Form.Item
|
<Form.Item
|
||||||
label={t("general.labels.sendby")}
|
label={t("general.labels.sendby")}
|
||||||
name="sendby"
|
name="sendby"
|
||||||
|
|||||||
@@ -1,13 +1,10 @@
|
|||||||
import { useApolloClient, useMutation } from "@apollo/client";
|
import { useMutation } from "@apollo/client";
|
||||||
import { CardElement, useElements, useStripe } from "@stripe/react-stripe-js";
|
|
||||||
import { Button, Form, Modal, notification } from "antd";
|
import { Button, Form, Modal, notification } from "antd";
|
||||||
import axios from "axios";
|
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
|
||||||
import { GET_JOB_INFO_FOR_STRIPE } from "../../graphql/jobs.queries";
|
|
||||||
import {
|
import {
|
||||||
INSERT_NEW_PAYMENT,
|
INSERT_NEW_PAYMENT,
|
||||||
UPDATE_PAYMENT,
|
UPDATE_PAYMENT,
|
||||||
@@ -45,82 +42,23 @@ function PaymentModalContainer({
|
|||||||
const [enterAgain, setEnterAgain] = useState(false);
|
const [enterAgain, setEnterAgain] = useState(false);
|
||||||
const [insertPayment] = useMutation(INSERT_NEW_PAYMENT);
|
const [insertPayment] = useMutation(INSERT_NEW_PAYMENT);
|
||||||
const [updatePayment] = useMutation(UPDATE_PAYMENT);
|
const [updatePayment] = useMutation(UPDATE_PAYMENT);
|
||||||
const client = useApolloClient();
|
|
||||||
const stripe = useStripe();
|
|
||||||
const elements = useElements();
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { context, actions, visible } = paymentModal;
|
const { context, actions, visible } = paymentModal;
|
||||||
|
|
||||||
const [loading, setLoading] = useState(false);
|
const [loading, setLoading] = useState(false);
|
||||||
const stripeStateArr = useState({
|
|
||||||
error: null,
|
|
||||||
cardComplete: false,
|
|
||||||
});
|
|
||||||
const stripeState = stripeStateArr[0];
|
|
||||||
|
|
||||||
const cardValid = !!!stripeState.error && stripeState.cardComplete;
|
|
||||||
|
|
||||||
const handleFinish = async (values) => {
|
const handleFinish = async (values) => {
|
||||||
const { useStripe, sendby, ...paymentObj } = values;
|
const { useStripe, sendby, ...paymentObj } = values;
|
||||||
if (useStripe && !cardValid) return;
|
|
||||||
|
|
||||||
if ((useStripe && !stripe) || !elements) {
|
|
||||||
// Stripe.js has not yet loaded.
|
|
||||||
// Make sure to disable form submission until Stripe.js has loaded.
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
let updatedPayment; //Moved up from if statement for greater scope.
|
||||||
try {
|
try {
|
||||||
let stripePayment;
|
|
||||||
if (useStripe && bodyshop.stripe_acct_id) {
|
|
||||||
logImEXEvent("payment_stripe_attempt");
|
|
||||||
|
|
||||||
const secretKey = await axios.post("/stripe/payment", {
|
|
||||||
amount: Math.round(values.amount * 100),
|
|
||||||
stripe_acct_id: bodyshop.stripe_acct_id,
|
|
||||||
});
|
|
||||||
|
|
||||||
const { data } = await client.query({
|
|
||||||
query: GET_JOB_INFO_FOR_STRIPE,
|
|
||||||
variables: { jobid: values.jobid },
|
|
||||||
});
|
|
||||||
|
|
||||||
stripePayment = await stripe.confirmCardPayment(
|
|
||||||
secretKey.data.clientSecret,
|
|
||||||
{
|
|
||||||
payment_method: {
|
|
||||||
card: elements.getElement(CardElement),
|
|
||||||
billing_details: {
|
|
||||||
name: `${data.jobs_by_pk.ownr_fn || ""} ${
|
|
||||||
data.jobs_by_pk.ownr_ln || ""
|
|
||||||
} ${data.jobs_by_pk.ownr_co_nm || ""}`,
|
|
||||||
email: data.jobs_by_pk.ownr_ea,
|
|
||||||
phone: data.jobs_by_pk.ownr_ph1,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
if (stripePayment.paymentIntent.status === "succeeded") {
|
|
||||||
notification["success"]({ message: t("payments.successes.stripe") });
|
|
||||||
} else {
|
|
||||||
notification["error"]({ message: t("payments.errors.stripe") });
|
|
||||||
throw new Error();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
logImEXEvent("payment_insert");
|
|
||||||
|
|
||||||
if (!context || (context && !context.id)) {
|
if (!context || (context && !context.id)) {
|
||||||
const newPayment = await insertPayment({
|
const newPayment = await insertPayment({
|
||||||
variables: {
|
variables: {
|
||||||
paymentInput: {
|
paymentInput: {
|
||||||
...paymentObj,
|
...paymentObj,
|
||||||
stripeid:
|
|
||||||
stripePayment &&
|
|
||||||
stripePayment.paymentIntent &&
|
|
||||||
stripePayment.paymentIntent.id,
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -149,7 +87,7 @@ function PaymentModalContainer({
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
const updatedPayment = await updatePayment({
|
updatedPayment = await updatePayment({
|
||||||
variables: {
|
variables: {
|
||||||
paymentId: context.id,
|
paymentId: context.id,
|
||||||
payment: paymentObj,
|
payment: paymentObj,
|
||||||
@@ -163,7 +101,11 @@ function PaymentModalContainer({
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (actions.refetch) actions.refetch();
|
if (actions.refetch)
|
||||||
|
actions.refetch(
|
||||||
|
updatedPayment && updatedPayment.data.update_payments.returning[0]
|
||||||
|
);
|
||||||
|
|
||||||
if (enterAgain) {
|
if (enterAgain) {
|
||||||
const prev = form.getFieldsValue(["date"]);
|
const prev = form.getFieldsValue(["date"]);
|
||||||
|
|
||||||
@@ -186,7 +128,11 @@ function PaymentModalContainer({
|
|||||||
};
|
};
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (visible) form.resetFields();
|
if (visible) {
|
||||||
|
form.resetFields();
|
||||||
|
form.resetFields();
|
||||||
|
form.setFieldsValue(context);
|
||||||
|
}
|
||||||
}, [visible, form, context]);
|
}, [visible, form, context]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@@ -201,6 +147,7 @@ function PaymentModalContainer({
|
|||||||
: t("payments.labels.edit")
|
: t("payments.labels.edit")
|
||||||
}
|
}
|
||||||
visible={visible}
|
visible={visible}
|
||||||
|
destroyOnClose
|
||||||
okText={t("general.actions.save")}
|
okText={t("general.actions.save")}
|
||||||
onOk={() => form.submit()}
|
onOk={() => form.submit()}
|
||||||
width="50%"
|
width="50%"
|
||||||
@@ -236,11 +183,7 @@ function PaymentModalContainer({
|
|||||||
layout="vertical"
|
layout="vertical"
|
||||||
initialValues={context || {}}
|
initialValues={context || {}}
|
||||||
>
|
>
|
||||||
<PaymentForm
|
<PaymentForm form={form} />
|
||||||
form={form}
|
|
||||||
stripeStateArr={stripeStateArr}
|
|
||||||
disabled={context && context.stripeid}
|
|
||||||
/>
|
|
||||||
</Form>
|
</Form>
|
||||||
</Modal>
|
</Modal>
|
||||||
);
|
);
|
||||||
@@ -250,15 +193,3 @@ export default connect(
|
|||||||
mapStateToProps,
|
mapStateToProps,
|
||||||
mapDispatchToProps
|
mapDispatchToProps
|
||||||
)(PaymentModalContainer);
|
)(PaymentModalContainer);
|
||||||
|
|
||||||
// const pr = stripe.paymentRequest({
|
|
||||||
// country: "CA",
|
|
||||||
// currency: "CAD",
|
|
||||||
// total: {
|
|
||||||
// label: "Demo total",
|
|
||||||
// amount: 1099,
|
|
||||||
// },
|
|
||||||
// requestPayerName: true,
|
|
||||||
// requestPayerEmail: true,
|
|
||||||
// });
|
|
||||||
// console.log("handleFinish -> pr", pr);
|
|
||||||
|
|||||||
@@ -1,22 +1,23 @@
|
|||||||
import { EditFilled, SyncOutlined } from "@ant-design/icons";
|
import { EditFilled, SyncOutlined } from "@ant-design/icons";
|
||||||
|
import { useApolloClient } from "@apollo/client";
|
||||||
import { Button, Card, Input, Space, Table, Typography } from "antd";
|
import { Button, Card, Input, Space, Table, Typography } from "antd";
|
||||||
|
import axios from "axios";
|
||||||
import queryString from "query-string";
|
import queryString from "query-string";
|
||||||
import React, { useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { Link, useHistory, useLocation } from "react-router-dom";
|
import { Link, useHistory, useLocation } from "react-router-dom";
|
||||||
import { createStructuredSelector } from "reselect";
|
import { createStructuredSelector } from "reselect";
|
||||||
|
import { QUERY_PAYMENT_BY_ID } from "../../graphql/payments.queries";
|
||||||
import { setModalContext } from "../../redux/modals/modals.actions";
|
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||||
import { selectBodyshop } from "../../redux/user/user.selectors";
|
import { selectBodyshop } from "../../redux/user/user.selectors";
|
||||||
import CurrencyFormatter from "../../utils/CurrencyFormatter";
|
import CurrencyFormatter from "../../utils/CurrencyFormatter";
|
||||||
import { DateFormatter, DateTimeFormatter } from "../../utils/DateFormatter";
|
import { DateFormatter, DateTimeFormatter } from "../../utils/DateFormatter";
|
||||||
import { alphaSort } from "../../utils/sorters";
|
|
||||||
import { TemplateList } from "../../utils/TemplateConstants";
|
import { TemplateList } from "../../utils/TemplateConstants";
|
||||||
|
import { alphaSort } from "../../utils/sorters";
|
||||||
import CaBcEtfTableModalContainer from "../ca-bc-etf-table-modal/ca-bc-etf-table-modal.container";
|
import CaBcEtfTableModalContainer from "../ca-bc-etf-table-modal/ca-bc-etf-table-modal.container";
|
||||||
import PrintWrapperComponent from "../print-wrapper/print-wrapper.component";
|
|
||||||
import OwnerNameDisplay from "../owner-name-display/owner-name-display.component";
|
import OwnerNameDisplay from "../owner-name-display/owner-name-display.component";
|
||||||
|
import PrintWrapperComponent from "../print-wrapper/print-wrapper.component";
|
||||||
const stripeTestEnv = process.env.REACT_APP_STRIPE_PUBLIC_KEY; //.includes("test");
|
|
||||||
|
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
//currentUser: selectCurrentUser
|
//currentUser: selectCurrentUser
|
||||||
@@ -41,7 +42,10 @@ export function PaymentsListPaginated({
|
|||||||
bodyshop,
|
bodyshop,
|
||||||
}) {
|
}) {
|
||||||
const search = queryString.parse(useLocation().search);
|
const search = queryString.parse(useLocation().search);
|
||||||
|
const [openSearchResults, setOpenSearchResults] = useState([]);
|
||||||
|
const [searchLoading, setSearchLoading] = useState(false);
|
||||||
const { page, sortcolumn, sortorder } = search;
|
const { page, sortcolumn, sortorder } = search;
|
||||||
|
const client = useApolloClient();
|
||||||
const history = useHistory();
|
const history = useHistory();
|
||||||
const [state, setState] = useState({
|
const [state, setState] = useState({
|
||||||
sortedInfo: {},
|
sortedInfo: {},
|
||||||
@@ -54,13 +58,17 @@ export function PaymentsListPaginated({
|
|||||||
title: t("jobs.fields.ro_number"),
|
title: t("jobs.fields.ro_number"),
|
||||||
dataIndex: "ro_number",
|
dataIndex: "ro_number",
|
||||||
key: "ro_number",
|
key: "ro_number",
|
||||||
sorter: (a, b) => alphaSort(a.job.ro_number, b.job.ro_number),
|
// sorter: (a, b) => alphaSort(a.job.ro_number, b.job.ro_number),
|
||||||
sortOrder: sortcolumn === "ro_number" && sortorder,
|
// sortOrder: sortcolumn === "ro_number" && sortorder,
|
||||||
render: (text, record) => (
|
render: (text, record) => {
|
||||||
<Link to={"/manage/jobs/" + record.job.id}>
|
return record.job ? (
|
||||||
{record.job.ro_number || t("general.labels.na")}
|
<Link to={"/manage/jobs/" + record.job.id}>
|
||||||
</Link>
|
{record.job.ro_number || t("general.labels.na")}
|
||||||
),
|
</Link>
|
||||||
|
) : (
|
||||||
|
<span>{t("general.labels.na")}</span>
|
||||||
|
);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
title: t("payments.fields.paymentnum"),
|
title: t("payments.fields.paymentnum"),
|
||||||
@@ -74,16 +82,16 @@ export function PaymentsListPaginated({
|
|||||||
dataIndex: "owner",
|
dataIndex: "owner",
|
||||||
key: "owner",
|
key: "owner",
|
||||||
ellipsis: true,
|
ellipsis: true,
|
||||||
sorter: (a, b) => alphaSort(a.job.ownr_ln, b.job.ownr_ln),
|
// sorter: (a, b) => alphaSort(a.job.ownr_ln, b.job.ownr_ln),
|
||||||
sortOrder: sortcolumn === "owner" && sortorder,
|
// sortOrder: sortcolumn === "owner" && sortorder,
|
||||||
render: (text, record) => {
|
render: (text, record) => {
|
||||||
return record.job.owner ? (
|
return record.job?.owner ? (
|
||||||
<Link to={"/manage/owners/" + record.job.owner.id}>
|
<Link to={"/manage/owners/" + record.job?.owner?.id}>
|
||||||
<OwnerNameDisplay ownerObject={record} />
|
<OwnerNameDisplay ownerObject={record.job} />
|
||||||
</Link>
|
</Link>
|
||||||
) : (
|
) : (
|
||||||
<span>
|
<span>
|
||||||
<OwnerNameDisplay ownerObject={record} />
|
<OwnerNameDisplay ownerObject={record.job} />
|
||||||
</span>
|
</span>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
@@ -125,23 +133,6 @@ export function PaymentsListPaginated({
|
|||||||
dataIndex: "transactionid",
|
dataIndex: "transactionid",
|
||||||
key: "transactionid",
|
key: "transactionid",
|
||||||
},
|
},
|
||||||
{
|
|
||||||
title: t("payments.fields.stripeid"),
|
|
||||||
dataIndex: "stripeid",
|
|
||||||
key: "stripeid",
|
|
||||||
render: (text, record) =>
|
|
||||||
record.stripeid ? (
|
|
||||||
<a
|
|
||||||
href={
|
|
||||||
stripeTestEnv
|
|
||||||
? `https://dashboard.stripe.com/${bodyshop.stripe_acct_id}/test/payments/${record.stripeid}`
|
|
||||||
: `https://dashboard.stripe.com/${bodyshop.stripe_acct_id}/payments/${record.stripeid}`
|
|
||||||
}
|
|
||||||
>
|
|
||||||
{record.stripeid}
|
|
||||||
</a>
|
|
||||||
) : null,
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
title: t("payments.fields.created_at"),
|
title: t("payments.fields.created_at"),
|
||||||
dataIndex: "created_at",
|
dataIndex: "created_at",
|
||||||
@@ -166,10 +157,33 @@ export function PaymentsListPaginated({
|
|||||||
<Space>
|
<Space>
|
||||||
<Button
|
<Button
|
||||||
disabled={record.exportedat}
|
disabled={record.exportedat}
|
||||||
onClick={() => {
|
onClick={async () => {
|
||||||
|
let apolloResults;
|
||||||
|
if (search.search) {
|
||||||
|
const { data } = await client.query({
|
||||||
|
query: QUERY_PAYMENT_BY_ID,
|
||||||
|
variables: {
|
||||||
|
paymentId: record.id,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
apolloResults = data.payments_by_pk;
|
||||||
|
}
|
||||||
setPaymentContext({
|
setPaymentContext({
|
||||||
actions: { refetch: refetch },
|
actions: {
|
||||||
context: record,
|
refetch: apolloResults
|
||||||
|
? (updatedRecord) => {
|
||||||
|
setOpenSearchResults((results) =>
|
||||||
|
results.map((result) => {
|
||||||
|
if (result.id !== record.id) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return updatedRecord;
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
: refetch,
|
||||||
|
},
|
||||||
|
context: apolloResults ? apolloResults : record,
|
||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -196,6 +210,28 @@ export function PaymentsListPaginated({
|
|||||||
history.push({ search: queryString.stringify(search) });
|
history.push({ search: queryString.stringify(search) });
|
||||||
};
|
};
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
if (search.search && search.search.trim() !== "") {
|
||||||
|
searchPayments();
|
||||||
|
}
|
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
async function searchPayments(value) {
|
||||||
|
try {
|
||||||
|
setSearchLoading(true);
|
||||||
|
const searchData = await axios.post("/search", {
|
||||||
|
search: value || search.search,
|
||||||
|
index: "payments",
|
||||||
|
});
|
||||||
|
setOpenSearchResults(searchData.data.hits.hits.map((s) => s._source));
|
||||||
|
} catch (error) {
|
||||||
|
console.log("Error while fetching search results", error);
|
||||||
|
} finally {
|
||||||
|
setSearchLoading(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
extra={
|
extra={
|
||||||
@@ -208,6 +244,7 @@ export function PaymentsListPaginated({
|
|||||||
<Button
|
<Button
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
delete search.search;
|
delete search.search;
|
||||||
|
delete search.page;
|
||||||
history.push({ search: queryString.stringify(search) });
|
history.push({ search: queryString.stringify(search) });
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
@@ -231,24 +268,33 @@ export function PaymentsListPaginated({
|
|||||||
onSearch={(value) => {
|
onSearch={(value) => {
|
||||||
search.search = value;
|
search.search = value;
|
||||||
history.push({ search: queryString.stringify(search) });
|
history.push({ search: queryString.stringify(search) });
|
||||||
|
searchPayments(value);
|
||||||
}}
|
}}
|
||||||
|
loading={loading || searchLoading}
|
||||||
enterButton
|
enterButton
|
||||||
/>
|
/>
|
||||||
</Space>
|
</Space>
|
||||||
}
|
}
|
||||||
>
|
>
|
||||||
<Table
|
<Table
|
||||||
loading={loading}
|
loading={loading || searchLoading}
|
||||||
scroll={{ x: true }}
|
scroll={{ x: true }}
|
||||||
pagination={{
|
pagination={
|
||||||
position: "top",
|
search?.search
|
||||||
pageSize: 25,
|
? {
|
||||||
current: parseInt(page || 1),
|
pageSize: 25,
|
||||||
total: total,
|
showSizeChanger: false,
|
||||||
}}
|
}
|
||||||
|
: {
|
||||||
|
pageSize: 25,
|
||||||
|
current: parseInt(page || 1),
|
||||||
|
total: total,
|
||||||
|
showSizeChanger: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
columns={columns}
|
columns={columns}
|
||||||
rowKey="id"
|
rowKey="id"
|
||||||
dataSource={payments}
|
dataSource={search?.search ? openSearchResults : payments}
|
||||||
onChange={handleTableChange}
|
onChange={handleTableChange}
|
||||||
/>
|
/>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -1,4 +1,12 @@
|
|||||||
import { Button, Card, Form, InputNumber, Popover, Radio } from "antd";
|
import {
|
||||||
|
Button,
|
||||||
|
Card,
|
||||||
|
Form,
|
||||||
|
InputNumber,
|
||||||
|
notification,
|
||||||
|
Popover,
|
||||||
|
Radio,
|
||||||
|
} from "antd";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
@@ -27,7 +35,6 @@ export function PrintCenterJobsLabels({ bodyshop, jobId }) {
|
|||||||
const handleOk = (e) => {
|
const handleOk = (e) => {
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
form.submit();
|
form.submit();
|
||||||
setIsModalVisible(false);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleCancel = () => {
|
const handleCancel = () => {
|
||||||
@@ -37,18 +44,24 @@ export function PrintCenterJobsLabels({ bodyshop, jobId }) {
|
|||||||
const handleFinish = async ({ template, ...values }) => {
|
const handleFinish = async ({ template, ...values }) => {
|
||||||
const { sendtype, ...restVals } = values;
|
const { sendtype, ...restVals } = values;
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
await GenerateDocument(
|
try {
|
||||||
{
|
await GenerateDocument(
|
||||||
name: TemplateList("job_special")[template].key,
|
{
|
||||||
variables: { id: jobId },
|
name: TemplateList("job_special")[template].key,
|
||||||
context: restVals,
|
variables: { id: jobId },
|
||||||
},
|
context: restVals,
|
||||||
{},
|
},
|
||||||
"p",
|
{},
|
||||||
jobId
|
"p",
|
||||||
);
|
jobId
|
||||||
setLoading(false);
|
);
|
||||||
setIsModalVisible(false);
|
setIsModalVisible(false);
|
||||||
|
} catch (error) {
|
||||||
|
notification.open({ type: "error", message: JSON.stringify(error) });
|
||||||
|
} finally {
|
||||||
|
setLoading(false);
|
||||||
|
}
|
||||||
|
|
||||||
form.resetFields();
|
form.resetFields();
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -60,7 +73,15 @@ export function PrintCenterJobsLabels({ bodyshop, jobId }) {
|
|||||||
layout="vertical"
|
layout="vertical"
|
||||||
form={form}
|
form={form}
|
||||||
>
|
>
|
||||||
<Form.Item required name="template">
|
<Form.Item
|
||||||
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
},
|
||||||
|
]}
|
||||||
|
name="template"
|
||||||
|
>
|
||||||
<Radio.Group>
|
<Radio.Group>
|
||||||
<Radio.Button value="parts_label_multiple">
|
<Radio.Button value="parts_label_multiple">
|
||||||
{t("printcenter.jobs.parts_label_multiple")}
|
{t("printcenter.jobs.parts_label_multiple")}
|
||||||
@@ -71,14 +92,24 @@ export function PrintCenterJobsLabels({ bodyshop, jobId }) {
|
|||||||
</Radio.Group>
|
</Radio.Group>
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
required
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
},
|
||||||
|
]}
|
||||||
label={t("printcenter.jobs.labels.position")}
|
label={t("printcenter.jobs.labels.position")}
|
||||||
name="position"
|
name="position"
|
||||||
>
|
>
|
||||||
<InputNumber min={1} precision={0} />
|
<InputNumber min={1} precision={0} />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
required
|
rules={[
|
||||||
|
{
|
||||||
|
required: true,
|
||||||
|
//message: t("general.validation.required"),
|
||||||
|
},
|
||||||
|
]}
|
||||||
label={t("printcenter.jobs.labels.count")}
|
label={t("printcenter.jobs.labels.count")}
|
||||||
name="count"
|
name="count"
|
||||||
>
|
>
|
||||||
|
|||||||
@@ -29,7 +29,10 @@ export function PrintCenterJobsComponent({ printCenterModal, bodyshop }) {
|
|||||||
})
|
})
|
||||||
.filter(
|
.filter(
|
||||||
(temp) =>
|
(temp) =>
|
||||||
!temp.regions || (temp.regions && temp.regions[bodyshop.region_config])
|
!temp.regions ||
|
||||||
|
(temp.regions && temp.regions[bodyshop.region_config]) ||
|
||||||
|
(temp.regions &&
|
||||||
|
bodyshop.region_config.includes(Object.keys(temp.regions)) === true)
|
||||||
);
|
);
|
||||||
|
|
||||||
const filteredJobsReportsList =
|
const filteredJobsReportsList =
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import { Col, List, Space, Typography } from "antd";
|
||||||
|
import React from "react";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
|
||||||
|
const CardColorLegend = ({ bodyshop }) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
const data = bodyshop.ssbuckets.map((bucket) => {
|
||||||
|
let color = { r: 255, g: 255, b: 255 };
|
||||||
|
|
||||||
|
if (bucket.color) {
|
||||||
|
color = bucket.color;
|
||||||
|
|
||||||
|
if (bucket.color.rgb) {
|
||||||
|
color = bucket.color.rgb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
label: bucket.label,
|
||||||
|
color,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Col>
|
||||||
|
<Typography>{t("production.labels.legend")}</Typography>
|
||||||
|
<List
|
||||||
|
grid={{
|
||||||
|
gutter: 16,
|
||||||
|
}}
|
||||||
|
dataSource={data}
|
||||||
|
renderItem={(item) => (
|
||||||
|
<List.Item>
|
||||||
|
<Space>
|
||||||
|
<div
|
||||||
|
style={{
|
||||||
|
width: "1.5rem",
|
||||||
|
aspectRatio: "1/1",
|
||||||
|
backgroundColor: `rgba(${item.color.r},${item.color.g},${item.color.b},${item.color.a})`,
|
||||||
|
}}
|
||||||
|
></div>
|
||||||
|
<div>{item.label}</div>
|
||||||
|
</Space>
|
||||||
|
</List.Item>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</Col>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
|
export default CardColorLegend;
|
||||||
@@ -18,6 +18,31 @@ import moment from "moment";
|
|||||||
import OwnerNameDisplay from "../owner-name-display/owner-name-display.component";
|
import OwnerNameDisplay from "../owner-name-display/owner-name-display.component";
|
||||||
import JobPartsQueueCount from "../job-parts-queue-count/job-parts-queue-count.component";
|
import JobPartsQueueCount from "../job-parts-queue-count/job-parts-queue-count.component";
|
||||||
|
|
||||||
|
const cardColor = (ssbuckets, totalHrs) => {
|
||||||
|
const bucket = ssbuckets.filter(
|
||||||
|
(bucket) =>
|
||||||
|
bucket.gte <= totalHrs && (!!bucket.lt ? bucket.lt > totalHrs : true)
|
||||||
|
)[0];
|
||||||
|
|
||||||
|
let color = { r: 255, g: 255, b: 255 };
|
||||||
|
|
||||||
|
if (bucket && bucket.color) {
|
||||||
|
color = bucket.color;
|
||||||
|
|
||||||
|
if (bucket.color.rgb) {
|
||||||
|
color = bucket.color.rgb;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return color;
|
||||||
|
};
|
||||||
|
|
||||||
|
function getContrastYIQ(bgColor) {
|
||||||
|
const yiq = (bgColor.r * 299 + bgColor.g * 587 + bgColor.b * 114) / 1000;
|
||||||
|
|
||||||
|
return yiq >= 128 ? "black" : "white";
|
||||||
|
}
|
||||||
|
|
||||||
export default function ProductionBoardCard(
|
export default function ProductionBoardCard(
|
||||||
technician,
|
technician,
|
||||||
card,
|
card,
|
||||||
@@ -54,10 +79,22 @@ export default function ProductionBoardCard(
|
|||||||
.isSame(moment(card.scheduled_completion), "day") &&
|
.isSame(moment(card.scheduled_completion), "day") &&
|
||||||
"production-completion-soon"));
|
"production-completion-soon"));
|
||||||
|
|
||||||
|
const totalHrs =
|
||||||
|
card.labhrs.aggregate.sum.mod_lb_hrs + card.larhrs.aggregate.sum.mod_lb_hrs;
|
||||||
|
const bgColor = cardColor(bodyshop.ssbuckets, totalHrs);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card
|
<Card
|
||||||
className="react-kanban-card imex-kanban-card"
|
className="react-kanban-card imex-kanban-card"
|
||||||
size="small"
|
size="small"
|
||||||
|
style={{
|
||||||
|
backgroundColor:
|
||||||
|
cardSettings &&
|
||||||
|
cardSettings.cardcolor &&
|
||||||
|
`rgba(${bgColor.r},${bgColor.g},${bgColor.b},${bgColor.a})`,
|
||||||
|
color:
|
||||||
|
cardSettings && cardSettings.cardcolor && getContrastYIQ(bgColor),
|
||||||
|
}}
|
||||||
title={
|
title={
|
||||||
<Space>
|
<Space>
|
||||||
<ProductionAlert record={card} key="alert" />
|
<ProductionAlert record={card} key="alert" />
|
||||||
|
|||||||
@@ -104,6 +104,13 @@ export default function ProductionBoardKanbanCardSettings({
|
|||||||
>
|
>
|
||||||
<Switch />
|
<Switch />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
<Form.Item
|
||||||
|
valuePropName="checked"
|
||||||
|
label={t("production.labels.cardcolor")}
|
||||||
|
name="cardcolor"
|
||||||
|
>
|
||||||
|
<Switch />
|
||||||
|
</Form.Item>
|
||||||
</Col>
|
</Col>
|
||||||
<Col span={12}>
|
<Col span={12}>
|
||||||
<Form.Item
|
<Form.Item
|
||||||
@@ -166,7 +173,7 @@ export default function ProductionBoardKanbanCardSettings({
|
|||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
return (
|
return (
|
||||||
<Popover content={overlay} visible={visible}>
|
<Popover content={overlay} visible={visible} placement="topRight">
|
||||||
<Button loading={loading} onClick={() => setVisible(true)}>
|
<Button loading={loading} onClick={() => setVisible(true)}>
|
||||||
{t("production.labels.cardsettings")}
|
{t("production.labels.cardsettings")}
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import ProductionBoardKanbanCardSettings from "./production-board-kanban.card-se
|
|||||||
//import "@asseinfo/react-kanban/dist/styles.css";
|
//import "@asseinfo/react-kanban/dist/styles.css";
|
||||||
import "./production-board-kanban.styles.scss";
|
import "./production-board-kanban.styles.scss";
|
||||||
import { createBoardData } from "./production-board-kanban.utils.js";
|
import { createBoardData } from "./production-board-kanban.utils.js";
|
||||||
|
import CardColorLegend from "../production-board-kanban-card/production-board-kanban-card-color-legend.component";
|
||||||
const mapStateToProps = createStructuredSelector({
|
const mapStateToProps = createStructuredSelector({
|
||||||
bodyshop: selectBodyshop,
|
bodyshop: selectBodyshop,
|
||||||
technician: selectTechnician,
|
technician: selectTechnician,
|
||||||
@@ -221,6 +222,7 @@ export function ProductionBoardKanbanComponent({
|
|||||||
employeeassignments: true,
|
employeeassignments: true,
|
||||||
scheduled_completion: true,
|
scheduled_completion: true,
|
||||||
stickyheader: false,
|
stickyheader: false,
|
||||||
|
cardcolor: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -256,6 +258,11 @@ export function ProductionBoardKanbanComponent({
|
|||||||
</Space>
|
</Space>
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
{cardSettings.cardcolor && (
|
||||||
|
<CardColorLegend cardSettings={cardSettings} bodyshop={bodyshop} />
|
||||||
|
)}
|
||||||
|
|
||||||
<ProductionListDetailComponent jobs={data} />
|
<ProductionListDetailComponent jobs={data} />
|
||||||
<StickyContainer>
|
<StickyContainer>
|
||||||
<Board
|
<Board
|
||||||
|
|||||||
@@ -91,11 +91,13 @@ const r = ({ technician, state, activeStatuses, bodyshop }) => {
|
|||||||
b.v_make_desc + b.v_model_desc
|
b.v_make_desc + b.v_model_desc
|
||||||
),
|
),
|
||||||
sortOrder:
|
sortOrder:
|
||||||
state.sortedInfo.columnKey === "ownr" && state.sortedInfo.order,
|
state.sortedInfo.columnKey === "vehicle" && state.sortedInfo.order,
|
||||||
render: (text, record) => (
|
render: (text, record) => (
|
||||||
<span>{`${record.v_model_yr || ""} ${record.v_make_desc || ""} ${
|
<Link to={`/manage/vehicles/${record.vehicleid}`}>{`${
|
||||||
record.v_model_desc || ""
|
record.v_model_yr || ""
|
||||||
} ${record.v_color || ""} ${record.plate_no || ""}`}</span>
|
} ${record.v_make_desc || ""} ${record.v_model_desc || ""} ${
|
||||||
|
record.v_color || ""
|
||||||
|
} ${record.plate_no || ""}`}</Link>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,12 +1,23 @@
|
|||||||
import Icon from "@ant-design/icons";
|
import Icon from "@ant-design/icons";
|
||||||
import { useMutation } from "@apollo/client";
|
import { useMutation } from "@apollo/client";
|
||||||
import { Button, Input, Popover } from "antd";
|
import { Button, Input, Popover, Space } from "antd";
|
||||||
import React, { useState } from "react";
|
import React, { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { FaRegStickyNote } from "react-icons/fa";
|
import { FaRegStickyNote } from "react-icons/fa";
|
||||||
import { logImEXEvent } from "../../firebase/firebase.utils";
|
import { logImEXEvent } from "../../firebase/firebase.utils";
|
||||||
import { UPDATE_JOB } from "../../graphql/jobs.queries";
|
import { UPDATE_JOB } from "../../graphql/jobs.queries";
|
||||||
export default function ProductionListColumnProductionNote({ record }) {
|
import { setModalContext } from "../../redux/modals/modals.actions";
|
||||||
|
import { connect } from "react-redux";
|
||||||
|
import { createStructuredSelector } from "reselect";
|
||||||
|
|
||||||
|
const mapStateToProps = createStructuredSelector({});
|
||||||
|
|
||||||
|
const mapDispatchToProps = (dispatch) => ({
|
||||||
|
setNoteUpsertContext: (context) =>
|
||||||
|
dispatch(setModalContext({ context: context, modal: "noteUpsert" })),
|
||||||
|
});
|
||||||
|
|
||||||
|
function ProductionListColumnProductionNote({ record, setNoteUpsertContext }) {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
|
|
||||||
const [note, setNote] = useState(
|
const [note, setNote] = useState(
|
||||||
@@ -60,12 +71,26 @@ export default function ProductionListColumnProductionNote({ record }) {
|
|||||||
// onPressEnter={handleSaveNote}
|
// onPressEnter={handleSaveNote}
|
||||||
autoFocus
|
autoFocus
|
||||||
allowClear
|
allowClear
|
||||||
|
style={{ marginBottom: "1em" }}
|
||||||
/>
|
/>
|
||||||
<div>
|
<Space>
|
||||||
<Button onClick={handleSaveNote}>
|
<Button onClick={handleSaveNote} type="primary">
|
||||||
{t("general.actions.save")}
|
{t("general.actions.save")}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
setVisible(false);
|
||||||
|
setNoteUpsertContext({
|
||||||
|
context: {
|
||||||
|
jobId: record.id,
|
||||||
|
text: note,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t("notes.actions.savetojobnotes")}
|
||||||
|
</Button>
|
||||||
|
</Space>
|
||||||
</div>
|
</div>
|
||||||
}
|
}
|
||||||
trigger={["click"]}
|
trigger={["click"]}
|
||||||
@@ -85,3 +110,8 @@ export default function ProductionListColumnProductionNote({ record }) {
|
|||||||
</Popover>
|
</Popover>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default connect(
|
||||||
|
mapStateToProps,
|
||||||
|
mapDispatchToProps
|
||||||
|
)(ProductionListColumnProductionNote);
|
||||||
|
|||||||
@@ -55,6 +55,7 @@ export function ProductionListTable({
|
|||||||
const assoc = bodyshop.associations.find(
|
const assoc = bodyshop.associations.find(
|
||||||
(a) => a.useremail === currentUser.email
|
(a) => a.useremail === currentUser.email
|
||||||
);
|
);
|
||||||
|
|
||||||
if (assoc) {
|
if (assoc) {
|
||||||
await updateDefaultProdView({
|
await updateDefaultProdView({
|
||||||
variables: { assocId: assoc.id, view: value },
|
variables: { assocId: assoc.id, view: value },
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ export function ProductionListTable({
|
|||||||
state,
|
state,
|
||||||
activeStatuses: bodyshop.md_ro_statuses.active_statuses,
|
activeStatuses: bodyshop.md_ro_statuses.active_statuses,
|
||||||
}).find((e) => e.key === k.key),
|
}).find((e) => e.key === k.key),
|
||||||
width: k.width,
|
width: k.width ?? 100,
|
||||||
};
|
};
|
||||||
})) ||
|
})) ||
|
||||||
[]
|
[]
|
||||||
@@ -267,6 +267,8 @@ export function ProductionListTable({
|
|||||||
sortOrder:
|
sortOrder:
|
||||||
state.sortedInfo.columnKey === c.key && state.sortedInfo.order,
|
state.sortedInfo.columnKey === c.key && state.sortedInfo.order,
|
||||||
title: headerItem(c),
|
title: headerItem(c),
|
||||||
|
ellipsis: true,
|
||||||
|
width: c.width ?? 100,
|
||||||
onHeaderCell: (column) => ({
|
onHeaderCell: (column) => ({
|
||||||
width: column.width,
|
width: column.width,
|
||||||
onResize: handleResize(index),
|
onResize: handleResize(index),
|
||||||
@@ -276,11 +278,12 @@ export function ProductionListTable({
|
|||||||
rowKey="id"
|
rowKey="id"
|
||||||
loading={loading}
|
loading={loading}
|
||||||
dataSource={dataSource}
|
dataSource={dataSource}
|
||||||
// scroll={{ x: true }}
|
scroll={{ x: 1000 }}
|
||||||
onChange={handleTableChange}
|
onChange={handleTableChange}
|
||||||
/>
|
/>
|
||||||
</ReactDragListView.DragColumn>
|
</ReactDragListView.DragColumn>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default connect(mapStateToProps, null)(ProductionListTable);
|
export default connect(mapStateToProps, null)(ProductionListTable);
|
||||||
|
|||||||
@@ -3,8 +3,26 @@ import { Resizable } from "react-resizable";
|
|||||||
|
|
||||||
export default function ResizableComponent(props) {
|
export default function ResizableComponent(props) {
|
||||||
const { onResize, width, ...restProps } = props;
|
const { onResize, width, ...restProps } = props;
|
||||||
|
|
||||||
|
if (!width) {
|
||||||
|
return <th {...restProps} />;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Resizable width={width || 200} height={0} onResize={onResize}>
|
<Resizable
|
||||||
|
width={width || 200}
|
||||||
|
height={0}
|
||||||
|
onResize={onResize}
|
||||||
|
draggableOpts={{ enableUserSelectHack: false }}
|
||||||
|
handle={
|
||||||
|
<span
|
||||||
|
className="react-resizable-handle"
|
||||||
|
onClick={(e) => {
|
||||||
|
e.stopPropagation();
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
<th {...restProps} />
|
<th {...restProps} />
|
||||||
</Resizable>
|
</Resizable>
|
||||||
);
|
);
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user