@quesmed/types-rn 2.5.80 → 2.5.82
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/models/User.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { ApolloCache } from '@apollo/client';
|
|
2
|
+
import { ApolloUpdateOptions, ApolloUpdateResultRestricted } from '../..';
|
|
1
3
|
import { ETopicType, Id } from '../../../models';
|
|
2
4
|
import { IPreset } from '../../../models/Preset';
|
|
3
5
|
import { RestrictedData } from '../../types';
|
|
@@ -6,11 +8,13 @@ export type IDeletePresetData = RestrictedData<boolean, 'deletePreset'>;
|
|
|
6
8
|
export interface IDeletePresetVar {
|
|
7
9
|
presetId: number;
|
|
8
10
|
}
|
|
11
|
+
export declare const updateCacheOnDeletePrest: (userId: number) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IDeletePresetData>, options: ApolloUpdateOptions) => void;
|
|
9
12
|
export declare const DUPLICATE_PRESET: import("@apollo/client").DocumentNode;
|
|
10
13
|
export type IDuplicatePresetData = RestrictedData<IPreset, 'duplicatePreset'>;
|
|
11
14
|
export interface IDuplicatePresetVar {
|
|
12
15
|
presetId: number;
|
|
13
16
|
}
|
|
17
|
+
export declare const updateCacheOnDuplicatePreset: (userId: number) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IDuplicatePresetData>) => void;
|
|
14
18
|
export declare const EDIT_PRESET: import("@apollo/client").DocumentNode;
|
|
15
19
|
export type IEditPresetData = RestrictedData<IPreset, 'editPreset'>;
|
|
16
20
|
export interface IEditPresetVar {
|
|
@@ -30,3 +34,4 @@ export interface ICreatePresetVar {
|
|
|
30
34
|
conceptIds: Id[];
|
|
31
35
|
};
|
|
32
36
|
}
|
|
37
|
+
export declare const updateCacheOnCreatePreset: (userId: number) => (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<ICreatePresetData>) => void;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CREATE_PRESET = exports.EDIT_PRESET = exports.DUPLICATE_PRESET = exports.DELETE_PRESET = void 0;
|
|
3
|
+
exports.updateCacheOnCreatePreset = exports.CREATE_PRESET = exports.EDIT_PRESET = exports.updateCacheOnDuplicatePreset = exports.DUPLICATE_PRESET = exports.updateCacheOnDeletePrest = exports.DELETE_PRESET = void 0;
|
|
4
4
|
const client_1 = require("@apollo/client");
|
|
5
|
+
const __1 = require("../..");
|
|
6
|
+
const restricted_1 = require("../../query/restricted");
|
|
5
7
|
exports.DELETE_PRESET = (0, client_1.gql) `
|
|
6
8
|
mutation DeletePreset($presetId: Int!) {
|
|
7
9
|
restricted {
|
|
@@ -9,6 +11,39 @@ exports.DELETE_PRESET = (0, client_1.gql) `
|
|
|
9
11
|
}
|
|
10
12
|
}
|
|
11
13
|
`;
|
|
14
|
+
const updateCacheOnDeletePrest = (userId) => (cache, result, options) => {
|
|
15
|
+
const { deletePreset } = result?.data?.restricted || {};
|
|
16
|
+
const { variables } = options || {};
|
|
17
|
+
const { presetId } = variables || {};
|
|
18
|
+
if (deletePreset && presetId) {
|
|
19
|
+
const prevData = cache.readQuery({
|
|
20
|
+
variables: { userId: Number(userId), order: __1.ESortOrder.DESC },
|
|
21
|
+
query: restricted_1.PRESETS,
|
|
22
|
+
});
|
|
23
|
+
if (prevData) {
|
|
24
|
+
const { presets } = prevData.restricted || {};
|
|
25
|
+
const removedPresetIndex = presets.findIndex(({ id }) => Number(id) === Number(presetId));
|
|
26
|
+
if (removedPresetIndex >= 0) {
|
|
27
|
+
const updatedPresets = [
|
|
28
|
+
...presets.slice(0, removedPresetIndex),
|
|
29
|
+
...presets.slice(removedPresetIndex + 1),
|
|
30
|
+
];
|
|
31
|
+
cache.writeQuery({
|
|
32
|
+
query: restricted_1.PRESETS,
|
|
33
|
+
variables: { userId: Number(userId), order: __1.ESortOrder.DESC },
|
|
34
|
+
data: {
|
|
35
|
+
...prevData,
|
|
36
|
+
restricted: {
|
|
37
|
+
...prevData.restricted,
|
|
38
|
+
presets: [...updatedPresets],
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
exports.updateCacheOnDeletePrest = updateCacheOnDeletePrest;
|
|
12
47
|
exports.DUPLICATE_PRESET = (0, client_1.gql) `
|
|
13
48
|
mutation DuplicatePreset($presetId: Int!) {
|
|
14
49
|
restricted {
|
|
@@ -40,6 +75,30 @@ exports.DUPLICATE_PRESET = (0, client_1.gql) `
|
|
|
40
75
|
}
|
|
41
76
|
}
|
|
42
77
|
`;
|
|
78
|
+
const updateCacheOnDuplicatePreset = (userId) => (cache, result) => {
|
|
79
|
+
const { duplicatePreset } = result?.data?.restricted || {};
|
|
80
|
+
if (duplicatePreset) {
|
|
81
|
+
const prevData = cache.readQuery({
|
|
82
|
+
variables: { userId: Number(userId), order: __1.ESortOrder.DESC },
|
|
83
|
+
query: restricted_1.PRESETS,
|
|
84
|
+
});
|
|
85
|
+
if (prevData) {
|
|
86
|
+
const { presets } = prevData.restricted || {};
|
|
87
|
+
cache.writeQuery({
|
|
88
|
+
query: restricted_1.PRESETS,
|
|
89
|
+
variables: { userId: Number(userId), order: __1.ESortOrder.DESC },
|
|
90
|
+
data: {
|
|
91
|
+
...prevData,
|
|
92
|
+
restricted: {
|
|
93
|
+
...prevData.restricted,
|
|
94
|
+
presets: [{ ...duplicatePreset }, ...presets],
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
exports.updateCacheOnDuplicatePreset = updateCacheOnDuplicatePreset;
|
|
43
102
|
exports.EDIT_PRESET = (0, client_1.gql) `
|
|
44
103
|
mutation EditPreset($presetId: Int!, $data: EditPresetInput!) {
|
|
45
104
|
restricted {
|
|
@@ -102,3 +161,27 @@ exports.CREATE_PRESET = (0, client_1.gql) `
|
|
|
102
161
|
}
|
|
103
162
|
}
|
|
104
163
|
`;
|
|
164
|
+
const updateCacheOnCreatePreset = (userId) => (cache, result) => {
|
|
165
|
+
const { createPreset } = result?.data?.restricted || {};
|
|
166
|
+
if (createPreset) {
|
|
167
|
+
const prevData = cache.readQuery({
|
|
168
|
+
variables: { userId },
|
|
169
|
+
query: restricted_1.PRESETS,
|
|
170
|
+
});
|
|
171
|
+
if (prevData) {
|
|
172
|
+
const { presets } = prevData.restricted || {};
|
|
173
|
+
cache.writeQuery({
|
|
174
|
+
query: restricted_1.PRESETS,
|
|
175
|
+
variables: { userId: Number(userId) },
|
|
176
|
+
data: {
|
|
177
|
+
...prevData,
|
|
178
|
+
restricted: {
|
|
179
|
+
...prevData.restricted,
|
|
180
|
+
presets: [{ ...createPreset }, ...presets],
|
|
181
|
+
},
|
|
182
|
+
},
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
exports.updateCacheOnCreatePreset = updateCacheOnCreatePreset;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { EDifficultyType, EOsceType, Id, IDashboardOsce, IOsceMarksheet, IOsceStation, IOsceStats } from '../../../models';
|
|
1
|
+
import { EDifficultyType, EOsceType, Id, IDashboardOsce, IOsceMarksheet, IOsceStation, IOsceStats, IUser } from '../../../models';
|
|
2
|
+
import { ESortOrder } from '../../enums';
|
|
2
3
|
import { graphqlNormalize, RestrictedData } from '../../types';
|
|
3
4
|
import { ITopic } from './../../../models/Topic';
|
|
4
|
-
import { ESortOrder } from '../../enums';
|
|
5
5
|
export interface IOsceStatsVar {
|
|
6
6
|
typeId?: EOsceType[];
|
|
7
7
|
solo: boolean;
|
|
@@ -14,6 +14,12 @@ export interface IDashboardOsceVar {
|
|
|
14
14
|
order?: ESortOrder;
|
|
15
15
|
}
|
|
16
16
|
export type IDashboardOsceData = RestrictedData<graphqlNormalize & IDashboardOsce, 'dashboardOsce'>;
|
|
17
|
+
export interface IDashboardOsceQueryData {
|
|
18
|
+
restricted: {
|
|
19
|
+
dashboardOsce: IDashboardOsce;
|
|
20
|
+
user: IUser;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
17
23
|
export declare const OSCE_MARKSHEETS: import("@apollo/client").DocumentNode;
|
|
18
24
|
export interface IOsceMarksheetsVar {
|
|
19
25
|
solo?: boolean;
|
|
@@ -71,12 +71,22 @@ exports.OSCE_MARKSHEET_WINDOW = (0, client_1.gql) `
|
|
|
71
71
|
osceStation {
|
|
72
72
|
...OsceStationFields
|
|
73
73
|
__typename
|
|
74
|
-
}
|
|
74
|
+
}
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
score
|
|
78
78
|
total
|
|
79
79
|
}
|
|
80
|
+
user {
|
|
81
|
+
examDate
|
|
82
|
+
userProgress {
|
|
83
|
+
marksheetCount
|
|
84
|
+
stationsCount
|
|
85
|
+
daysInCurrentStreak
|
|
86
|
+
daysInPreviousStreak
|
|
87
|
+
daysInLongestStreak
|
|
88
|
+
}
|
|
89
|
+
}
|
|
80
90
|
}
|
|
81
91
|
}
|
|
82
92
|
`;
|