apps/web: pass device info to create-kp
This commit is contained in:
parent
8f53187a3c
commit
88b7501b4d
@ -6,6 +6,7 @@ import ValuesSchema from '@/config/schema/values';
|
||||
import { z } from 'zod';
|
||||
|
||||
export const RequestCreateKPSchema = z.object({
|
||||
__info: z.record(z.any()).optional(),
|
||||
calculation: z
|
||||
.object({
|
||||
calculationValues: ValuesSchema,
|
||||
|
||||
@ -37,6 +37,7 @@
|
||||
"styled-components": "^5.3.11",
|
||||
"superjson": "^2.2.1",
|
||||
"tools": "workspace:*",
|
||||
"ua-parser-js": "^1.0.38",
|
||||
"ui": "workspace:*",
|
||||
"use-debounce": "^9.0.4",
|
||||
"zod": "^3.22.4"
|
||||
@ -54,6 +55,7 @@
|
||||
"@types/react": "^18.2.14",
|
||||
"@types/react-dom": "^18.2.6",
|
||||
"@types/styled-components": "^5.1.26",
|
||||
"@types/ua-parser-js": "^0.7.39",
|
||||
"@vchikalkin/eslint-config-awesome": "^1.1.6",
|
||||
"antd": "^5.14.2",
|
||||
"eslint": "^8.52.0",
|
||||
|
||||
@ -4,7 +4,7 @@ import type { inferAsyncReturnType } from '@trpc/server';
|
||||
import type { CreateNextContextOptions } from '@trpc/server/adapters/next';
|
||||
|
||||
export async function createContext({ req }: CreateNextContextOptions) {
|
||||
const { cookie = '', authorization } = req.headers;
|
||||
const { cookie = '', authorization, 'user-agent': userAgent } = req.headers;
|
||||
|
||||
const user = await getUser({
|
||||
headers: {
|
||||
@ -18,6 +18,7 @@ export async function createContext({ req }: CreateNextContextOptions) {
|
||||
return {
|
||||
headers: { authorization },
|
||||
user,
|
||||
userAgent,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@ -42,6 +42,7 @@ import type { CalculationValues } from '@/stores/calculation/values/types';
|
||||
import { HttpError } from '@/utils/error';
|
||||
import { createTRPCError } from '@/utils/trpc';
|
||||
import { QueryClient } from '@tanstack/react-query';
|
||||
import { UAParser } from 'ua-parser-js';
|
||||
|
||||
const defaultInsurance = {
|
||||
values: {
|
||||
@ -184,6 +185,7 @@ export const quoteRouter = router({
|
||||
additionalData: requestData.additionalData,
|
||||
},
|
||||
elt: input.elt,
|
||||
__info: new UAParser(ctx.userAgent).getResult(),
|
||||
});
|
||||
|
||||
const createKPResult = await createKP(requestCreateKP);
|
||||
|
||||
25
pnpm-lock.yaml
generated
25
pnpm-lock.yaml
generated
@ -189,6 +189,9 @@ importers:
|
||||
tools:
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/tools
|
||||
ua-parser-js:
|
||||
specifier: ^1.0.38
|
||||
version: 1.0.38
|
||||
ui:
|
||||
specifier: workspace:*
|
||||
version: link:../../packages/ui
|
||||
@ -235,6 +238,9 @@ importers:
|
||||
'@types/styled-components':
|
||||
specifier: ^5.1.26
|
||||
version: 5.1.34
|
||||
'@types/ua-parser-js':
|
||||
specifier: ^0.7.39
|
||||
version: 0.7.39
|
||||
'@vchikalkin/eslint-config-awesome':
|
||||
specifier: ^1.1.6
|
||||
version: 1.1.6(@babel/eslint-plugin@7.23.5)(@babel/plugin-syntax-flow@7.23.3)(@babel/plugin-transform-react-jsx@7.23.4)(@types/node@18.19.18)(eslint-plugin-import@2.29.1)(eslint@8.57.0)(graphql@16.8.1)(jest@29.7.0)(prettier@3.2.5)(typescript@5.3.3)
|
||||
@ -3953,6 +3959,10 @@ packages:
|
||||
resolution: {integrity: sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==}
|
||||
dev: true
|
||||
|
||||
/@types/ua-parser-js@0.7.39:
|
||||
resolution: {integrity: sha512-P/oDfpofrdtF5xw433SPALpdSchtJmY7nsJItf8h3KXqOslkbySh8zq4dSWXH2oTjRvJ5PczVEoCZPow6GicLg==}
|
||||
dev: true
|
||||
|
||||
/@types/ws@8.5.10:
|
||||
resolution: {integrity: sha512-vmQSUcfalpIq0R9q7uTo2lXs6eGIpt9wtnLdMv9LVpIjCA/+ufZRozlVoVelIYixx1ugCBKDhn89vnsEGOCx9A==}
|
||||
dependencies:
|
||||
@ -6973,7 +6983,7 @@ packages:
|
||||
'@typescript-eslint/eslint-plugin': 6.21.0(@typescript-eslint/parser@6.21.0)(eslint@8.57.0)(typescript@5.3.3)
|
||||
'@typescript-eslint/utils': 5.62.0(eslint@8.57.0)(typescript@5.3.3)
|
||||
eslint: 8.57.0
|
||||
jest: 29.7.0(@types/node@20.11.20)(ts-node@10.9.2)
|
||||
jest: 29.7.0(@types/node@18.19.18)(ts-node@10.9.2)
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
- typescript
|
||||
@ -7715,7 +7725,7 @@ packages:
|
||||
object-assign: 4.1.1
|
||||
promise: 7.3.1
|
||||
setimmediate: 1.0.5
|
||||
ua-parser-js: 1.0.37
|
||||
ua-parser-js: 1.0.38
|
||||
transitivePeerDependencies:
|
||||
- encoding
|
||||
dev: true
|
||||
@ -8217,7 +8227,7 @@ packages:
|
||||
'@graphql-tools/json-file-loader': 7.4.18(graphql@16.8.1)
|
||||
'@graphql-tools/load': 7.8.14(graphql@16.8.1)
|
||||
'@graphql-tools/merge': 8.4.2(graphql@16.8.1)
|
||||
'@graphql-tools/url-loader': 7.17.18(@types/node@18.19.18)(graphql@16.8.1)
|
||||
'@graphql-tools/url-loader': 7.17.18(@types/node@20.11.20)(graphql@16.8.1)
|
||||
'@graphql-tools/utils': 9.2.1(graphql@16.8.1)
|
||||
cosmiconfig: 8.0.0
|
||||
graphql: 16.8.1
|
||||
@ -9337,7 +9347,7 @@ packages:
|
||||
pretty-format: 29.7.0
|
||||
slash: 3.0.0
|
||||
strip-json-comments: 3.1.1
|
||||
ts-node: 10.9.2(@types/node@20.11.20)(typescript@5.3.3)
|
||||
ts-node: 10.9.2(@types/node@18.19.18)(typescript@5.3.3)
|
||||
transitivePeerDependencies:
|
||||
- babel-plugin-macros
|
||||
- supports-color
|
||||
@ -13261,7 +13271,7 @@ packages:
|
||||
'@babel/core': 7.23.9
|
||||
bs-logger: 0.2.6
|
||||
fast-json-stable-stringify: 2.1.0
|
||||
jest: 29.7.0(@types/node@20.11.20)(ts-node@10.9.2)
|
||||
jest: 29.7.0(@types/node@18.19.18)(ts-node@10.9.2)
|
||||
jest-util: 29.7.0
|
||||
json5: 2.2.3
|
||||
lodash.memoize: 4.1.2
|
||||
@ -13570,9 +13580,8 @@ packages:
|
||||
hasBin: true
|
||||
dev: true
|
||||
|
||||
/ua-parser-js@1.0.37:
|
||||
resolution: {integrity: sha512-bhTyI94tZofjo+Dn8SN6Zv8nBDvyXTymAdM3LDI/0IboIUwTu1rEhW7v2TfiVsoYWgkQ4kOVqnI8APUFbIQIFQ==}
|
||||
dev: true
|
||||
/ua-parser-js@1.0.38:
|
||||
resolution: {integrity: sha512-Aq5ppTOfvrCMgAPneW1HfWj66Xi7XL+/mIy996R1/CLS/rcyJQm6QZdsKrUeivDFQ+Oc9Wyuwor8Ze8peEoUoQ==}
|
||||
|
||||
/uid@2.0.2:
|
||||
resolution: {integrity: sha512-u3xV3X7uzvi5b1MncmZo3i2Aw222Zk1keqLA1YkHldREkAhAqi65wuPfe7lHx8H/Wzy+8CE7S7uS3jekIM5s8g==}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user