@quesmed/types 2.2.96 → 2.2.98
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/dist/cjs/resolvers/mutation/restricted/todo.d.ts +4 -2
- package/dist/cjs/resolvers/mutation/restricted/todo.js +101 -30
- package/dist/cjs/resolvers/mutation/sample.d.ts +2 -1
- package/dist/cjs/resolvers/mutation/sample.js +19 -1
- package/dist/mjs/resolvers/mutation/restricted/todo.d.ts +4 -2
- package/dist/mjs/resolvers/mutation/restricted/todo.js +97 -28
- package/dist/mjs/resolvers/mutation/sample.d.ts +2 -1
- package/dist/mjs/resolvers/mutation/sample.js +17 -0
- package/package.json +1 -1
|
@@ -24,7 +24,9 @@ export interface ISaveTodosVar {
|
|
|
24
24
|
todos: ITodoInput[];
|
|
25
25
|
}
|
|
26
26
|
export declare type ISaveTodosData = RestrictedData<(graphqlNormalize & ITodo)[], 'saveTodos'>;
|
|
27
|
+
export declare const optimisticUpdatedSaveTodo: (todo: ITodo, cardIndex: number, todoInput: ITodoInput) => ISaveTodosData;
|
|
27
28
|
export declare function saveTodosCache(cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<ISaveTodosData>, options: ApolloUpdateOptions): void;
|
|
29
|
+
export declare const optimisticSaveTodos: (todo: ITodo, cardIndex: number, todoInput: ITodoInput) => ISaveTodosData;
|
|
28
30
|
export declare const ADD_TO_DAILY_STACK: import("@apollo/client").DocumentNode;
|
|
29
31
|
export interface IAddToDailyStackVar {
|
|
30
32
|
conceptIds: Id[];
|
|
@@ -37,8 +39,8 @@ export interface IRemoveFromDailyStackVar {
|
|
|
37
39
|
conceptId?: Id;
|
|
38
40
|
}
|
|
39
41
|
export declare type IRemoveFromDailyStackData = RestrictedData<(graphqlNormalize & IUserCompletedCard)[], 'removeFromDailyStack'>;
|
|
40
|
-
export declare const
|
|
41
|
-
export declare const
|
|
42
|
+
export declare const updateCacheOnRemoveFromDailyStack: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IRemoveFromDailyStackData>, options: ApolloUpdateOptions) => void;
|
|
43
|
+
export declare const updateCacheOnAddToDailyStack: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddToDailyStackData>) => void;
|
|
42
44
|
export declare const REFRESH_DAILY_TASK: import("@apollo/client").DocumentNode;
|
|
43
45
|
export declare type IRefreshDailyTaskVar = null;
|
|
44
46
|
export declare type IRefreshDailyTaskData = RestrictedData<graphqlNormalize & ITodo, 'refreshDailyTask'>;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.REFRESH_DAILY_TASK = exports.
|
|
3
|
+
exports.REFRESH_DAILY_TASK = exports.updateCacheOnAddToDailyStack = exports.updateCacheOnRemoveFromDailyStack = exports.REMOVE_FROM_DAILY_STACK = exports.ADD_TO_DAILY_STACK = exports.optimisticSaveTodos = exports.saveTodosCache = exports.optimisticUpdatedSaveTodo = exports.SAVE_TODO = exports.BUILD_TODO = void 0;
|
|
4
4
|
const client_1 = require("@apollo/client");
|
|
5
5
|
const fragments_1 = require("../../fragments");
|
|
6
|
+
const restricted_1 = require("../../query/restricted");
|
|
6
7
|
exports.BUILD_TODO = (0, client_1.gql) `
|
|
7
8
|
mutation BuildTodo($buildTodo: BuildTodoInput!) {
|
|
8
9
|
restricted {
|
|
@@ -54,6 +55,23 @@ exports.SAVE_TODO = (0, client_1.gql) `
|
|
|
54
55
|
}
|
|
55
56
|
}
|
|
56
57
|
`;
|
|
58
|
+
const optimisticUpdatedSaveTodo = (todo, cardIndex, todoInput) => {
|
|
59
|
+
const { score, timeTaken } = todoInput;
|
|
60
|
+
const { marks } = todo;
|
|
61
|
+
const newMarks = [...marks];
|
|
62
|
+
newMarks[cardIndex] = { ...marks[cardIndex], score, timeTaken };
|
|
63
|
+
return {
|
|
64
|
+
restricted: {
|
|
65
|
+
saveTodos: [
|
|
66
|
+
{
|
|
67
|
+
...todo,
|
|
68
|
+
marks: newMarks,
|
|
69
|
+
},
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
exports.optimisticUpdatedSaveTodo = optimisticUpdatedSaveTodo;
|
|
57
75
|
function saveTodosCache(cache, result, options) {
|
|
58
76
|
const { saveTodos } = result?.data?.restricted || {};
|
|
59
77
|
if (!options.variables || !saveTodos) {
|
|
@@ -78,6 +96,23 @@ function saveTodosCache(cache, result, options) {
|
|
|
78
96
|
}
|
|
79
97
|
}
|
|
80
98
|
exports.saveTodosCache = saveTodosCache;
|
|
99
|
+
const optimisticSaveTodos = (todo, cardIndex, todoInput) => {
|
|
100
|
+
const { score, timeTaken } = todoInput;
|
|
101
|
+
const { marks } = todo;
|
|
102
|
+
const newMarks = [...marks];
|
|
103
|
+
newMarks[cardIndex] = { ...marks[cardIndex], score, timeTaken };
|
|
104
|
+
return {
|
|
105
|
+
restricted: {
|
|
106
|
+
saveTodos: [
|
|
107
|
+
{
|
|
108
|
+
...todo,
|
|
109
|
+
marks: newMarks,
|
|
110
|
+
},
|
|
111
|
+
],
|
|
112
|
+
},
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
exports.optimisticSaveTodos = optimisticSaveTodos;
|
|
81
116
|
exports.ADD_TO_DAILY_STACK = (0, client_1.gql) `
|
|
82
117
|
${fragments_1.PICTURE_FIELDS}
|
|
83
118
|
mutation AddToDailyStack($conceptIds: [Int!]!) {
|
|
@@ -135,49 +170,85 @@ exports.REMOVE_FROM_DAILY_STACK = (0, client_1.gql) `
|
|
|
135
170
|
}
|
|
136
171
|
}
|
|
137
172
|
`;
|
|
138
|
-
const
|
|
173
|
+
const updateCacheOnRemoveFromDailyStack = (cache, result, options) => {
|
|
139
174
|
const { removeFromDailyStack } = result.data?.restricted || {};
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
175
|
+
const { variables } = options || {};
|
|
176
|
+
const { todoId } = variables || {};
|
|
177
|
+
if (!removeFromDailyStack || !removeFromDailyStack.length) {
|
|
178
|
+
return;
|
|
179
|
+
}
|
|
180
|
+
const toRemove = new Set(removeFromDailyStack.map(({ cardId }) => cardId));
|
|
181
|
+
const prevData = cache.readQuery({
|
|
182
|
+
query: restricted_1.USER_COMPLETED_DATA,
|
|
143
183
|
});
|
|
144
|
-
if (prevData
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
}
|
|
149
|
-
const newCompletedCards = prevData.completedCards.filter(({ id }) => !toRemove.has(id));
|
|
150
|
-
cache.writeFragment({
|
|
151
|
-
id: cache.identify({ id: userId, __typename: 'User' }),
|
|
184
|
+
if (prevData) {
|
|
185
|
+
const newCompletedCards = prevData.restricted.user.completedCards.filter(({ cardId }) => !toRemove.has(cardId));
|
|
186
|
+
cache.writeQuery({
|
|
187
|
+
query: restricted_1.USER_COMPLETED_DATA,
|
|
152
188
|
data: {
|
|
153
|
-
|
|
154
|
-
|
|
189
|
+
...prevData,
|
|
190
|
+
restricted: {
|
|
191
|
+
...prevData.restricted,
|
|
192
|
+
user: {
|
|
193
|
+
...prevData.restricted.user,
|
|
194
|
+
completedCards: newCompletedCards,
|
|
195
|
+
completedCardsCount: newCompletedCards.length,
|
|
196
|
+
},
|
|
197
|
+
},
|
|
155
198
|
},
|
|
156
|
-
fragment: fragments_1.COMPLETED_CARDS,
|
|
157
199
|
});
|
|
158
200
|
}
|
|
201
|
+
if (todoId) {
|
|
202
|
+
const prevData = cache.readQuery({
|
|
203
|
+
variables: { id: todoId },
|
|
204
|
+
query: restricted_1.TODO,
|
|
205
|
+
});
|
|
206
|
+
if (prevData) {
|
|
207
|
+
const { marks } = prevData.restricted.todo;
|
|
208
|
+
cache.writeQuery({
|
|
209
|
+
query: restricted_1.TODO,
|
|
210
|
+
data: {
|
|
211
|
+
...prevData,
|
|
212
|
+
restricted: {
|
|
213
|
+
...prevData.restricted,
|
|
214
|
+
todo: {
|
|
215
|
+
...prevData.restricted.todo,
|
|
216
|
+
marks: marks.filter(({ cardId }) => !toRemove.has(Number(cardId))),
|
|
217
|
+
},
|
|
218
|
+
},
|
|
219
|
+
},
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
}
|
|
159
223
|
};
|
|
160
|
-
exports.
|
|
161
|
-
const
|
|
224
|
+
exports.updateCacheOnRemoveFromDailyStack = updateCacheOnRemoveFromDailyStack;
|
|
225
|
+
const updateCacheOnAddToDailyStack = (cache, result) => {
|
|
162
226
|
const { addToDailyStack } = result.data?.restricted || {};
|
|
163
|
-
const prevData = cache.
|
|
164
|
-
|
|
165
|
-
fragment: fragments_1.COMPLETED_CARDS,
|
|
227
|
+
const prevData = cache.readQuery({
|
|
228
|
+
query: restricted_1.USER_COMPLETED_DATA,
|
|
166
229
|
});
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
230
|
+
if (prevData && addToDailyStack) {
|
|
231
|
+
const newCompletedCards = [
|
|
232
|
+
...prevData.restricted.user.completedCards,
|
|
233
|
+
...addToDailyStack,
|
|
234
|
+
];
|
|
235
|
+
cache.writeQuery({
|
|
236
|
+
query: restricted_1.USER_COMPLETED_DATA,
|
|
172
237
|
data: {
|
|
173
|
-
|
|
174
|
-
|
|
238
|
+
...prevData,
|
|
239
|
+
restricted: {
|
|
240
|
+
...prevData.restricted,
|
|
241
|
+
user: {
|
|
242
|
+
...prevData.restricted.user,
|
|
243
|
+
completedCards: newCompletedCards,
|
|
244
|
+
completedCardsCount: newCompletedCards.length,
|
|
245
|
+
},
|
|
246
|
+
},
|
|
175
247
|
},
|
|
176
|
-
fragment: fragments_1.COMPLETED_CARDS,
|
|
177
248
|
});
|
|
178
249
|
}
|
|
179
250
|
};
|
|
180
|
-
exports.
|
|
251
|
+
exports.updateCacheOnAddToDailyStack = updateCacheOnAddToDailyStack;
|
|
181
252
|
exports.REFRESH_DAILY_TASK = (0, client_1.gql) `
|
|
182
253
|
${fragments_1.PICTURE_FIELDS}
|
|
183
254
|
mutation RefreshDailyTask {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { ApolloClient } from '@apollo/client';
|
|
2
|
-
import { IMarksheetInput } from './restricted';
|
|
2
|
+
import { IMarksheetInput, ITodoInput } from './restricted';
|
|
3
3
|
export declare const saveSampleMarksheets: (client: ApolloClient<any>, marksheetInput: IMarksheetInput, questionIndex: number) => void;
|
|
4
|
+
export declare const saveSampleTodoMark: (client: ApolloClient<any>, todoInput: ITodoInput, markId: number) => void;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.saveSampleMarksheets = void 0;
|
|
3
|
+
exports.saveSampleTodoMark = exports.saveSampleMarksheets = void 0;
|
|
4
|
+
const client_1 = require("@apollo/client");
|
|
4
5
|
const query_1 = require("../query");
|
|
5
6
|
const saveSampleMarksheets = (client, marksheetInput, questionIndex) => {
|
|
6
7
|
const { timeTaken, choiceId, mark, marksheetId } = marksheetInput;
|
|
@@ -35,3 +36,20 @@ const saveSampleMarksheets = (client, marksheetInput, questionIndex) => {
|
|
|
35
36
|
}
|
|
36
37
|
};
|
|
37
38
|
exports.saveSampleMarksheets = saveSampleMarksheets;
|
|
39
|
+
const saveSampleTodoMark = (client, todoInput, markId) => {
|
|
40
|
+
const { timeTaken, score } = todoInput;
|
|
41
|
+
client.writeFragment({
|
|
42
|
+
id: `TodoMark:${markId}`,
|
|
43
|
+
data: {
|
|
44
|
+
score,
|
|
45
|
+
timeTaken: timeTaken,
|
|
46
|
+
},
|
|
47
|
+
fragment: (0, client_1.gql) `
|
|
48
|
+
fragment UpdatedTodoMark on TodoMark {
|
|
49
|
+
score
|
|
50
|
+
timeTaken
|
|
51
|
+
}
|
|
52
|
+
`,
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
exports.saveSampleTodoMark = saveSampleTodoMark;
|
|
@@ -24,7 +24,9 @@ export interface ISaveTodosVar {
|
|
|
24
24
|
todos: ITodoInput[];
|
|
25
25
|
}
|
|
26
26
|
export declare type ISaveTodosData = RestrictedData<(graphqlNormalize & ITodo)[], 'saveTodos'>;
|
|
27
|
+
export declare const optimisticUpdatedSaveTodo: (todo: ITodo, cardIndex: number, todoInput: ITodoInput) => ISaveTodosData;
|
|
27
28
|
export declare function saveTodosCache(cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<ISaveTodosData>, options: ApolloUpdateOptions): void;
|
|
29
|
+
export declare const optimisticSaveTodos: (todo: ITodo, cardIndex: number, todoInput: ITodoInput) => ISaveTodosData;
|
|
28
30
|
export declare const ADD_TO_DAILY_STACK: import("@apollo/client").DocumentNode;
|
|
29
31
|
export interface IAddToDailyStackVar {
|
|
30
32
|
conceptIds: Id[];
|
|
@@ -37,8 +39,8 @@ export interface IRemoveFromDailyStackVar {
|
|
|
37
39
|
conceptId?: Id;
|
|
38
40
|
}
|
|
39
41
|
export declare type IRemoveFromDailyStackData = RestrictedData<(graphqlNormalize & IUserCompletedCard)[], 'removeFromDailyStack'>;
|
|
40
|
-
export declare const
|
|
41
|
-
export declare const
|
|
42
|
+
export declare const updateCacheOnRemoveFromDailyStack: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IRemoveFromDailyStackData>, options: ApolloUpdateOptions) => void;
|
|
43
|
+
export declare const updateCacheOnAddToDailyStack: (cache: ApolloCache<any>, result: ApolloUpdateResultRestricted<IAddToDailyStackData>) => void;
|
|
42
44
|
export declare const REFRESH_DAILY_TASK: import("@apollo/client").DocumentNode;
|
|
43
45
|
export declare type IRefreshDailyTaskVar = null;
|
|
44
46
|
export declare type IRefreshDailyTaskData = RestrictedData<graphqlNormalize & ITodo, 'refreshDailyTask'>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { gql } from '@apollo/client';
|
|
2
|
-
import {
|
|
2
|
+
import { PICTURE_FIELDS } from '../../fragments';
|
|
3
|
+
import { TODO, USER_COMPLETED_DATA, } from '../../query/restricted';
|
|
3
4
|
export const BUILD_TODO = gql `
|
|
4
5
|
mutation BuildTodo($buildTodo: BuildTodoInput!) {
|
|
5
6
|
restricted {
|
|
@@ -51,6 +52,22 @@ export const SAVE_TODO = gql `
|
|
|
51
52
|
}
|
|
52
53
|
}
|
|
53
54
|
`;
|
|
55
|
+
export const optimisticUpdatedSaveTodo = (todo, cardIndex, todoInput) => {
|
|
56
|
+
const { score, timeTaken } = todoInput;
|
|
57
|
+
const { marks } = todo;
|
|
58
|
+
const newMarks = [...marks];
|
|
59
|
+
newMarks[cardIndex] = { ...marks[cardIndex], score, timeTaken };
|
|
60
|
+
return {
|
|
61
|
+
restricted: {
|
|
62
|
+
saveTodos: [
|
|
63
|
+
{
|
|
64
|
+
...todo,
|
|
65
|
+
marks: newMarks,
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
};
|
|
70
|
+
};
|
|
54
71
|
export function saveTodosCache(cache, result, options) {
|
|
55
72
|
const { saveTodos } = result?.data?.restricted || {};
|
|
56
73
|
if (!options.variables || !saveTodos) {
|
|
@@ -74,6 +91,22 @@ export function saveTodosCache(cache, result, options) {
|
|
|
74
91
|
});
|
|
75
92
|
}
|
|
76
93
|
}
|
|
94
|
+
export const optimisticSaveTodos = (todo, cardIndex, todoInput) => {
|
|
95
|
+
const { score, timeTaken } = todoInput;
|
|
96
|
+
const { marks } = todo;
|
|
97
|
+
const newMarks = [...marks];
|
|
98
|
+
newMarks[cardIndex] = { ...marks[cardIndex], score, timeTaken };
|
|
99
|
+
return {
|
|
100
|
+
restricted: {
|
|
101
|
+
saveTodos: [
|
|
102
|
+
{
|
|
103
|
+
...todo,
|
|
104
|
+
marks: newMarks,
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
};
|
|
77
110
|
export const ADD_TO_DAILY_STACK = gql `
|
|
78
111
|
${PICTURE_FIELDS}
|
|
79
112
|
mutation AddToDailyStack($conceptIds: [Int!]!) {
|
|
@@ -131,44 +164,80 @@ export const REMOVE_FROM_DAILY_STACK = gql `
|
|
|
131
164
|
}
|
|
132
165
|
}
|
|
133
166
|
`;
|
|
134
|
-
export const
|
|
167
|
+
export const updateCacheOnRemoveFromDailyStack = (cache, result, options) => {
|
|
135
168
|
const { removeFromDailyStack } = result.data?.restricted || {};
|
|
136
|
-
const
|
|
137
|
-
|
|
138
|
-
|
|
169
|
+
const { variables } = options || {};
|
|
170
|
+
const { todoId } = variables || {};
|
|
171
|
+
if (!removeFromDailyStack || !removeFromDailyStack.length) {
|
|
172
|
+
return;
|
|
173
|
+
}
|
|
174
|
+
const toRemove = new Set(removeFromDailyStack.map(({ cardId }) => cardId));
|
|
175
|
+
const prevData = cache.readQuery({
|
|
176
|
+
query: USER_COMPLETED_DATA,
|
|
139
177
|
});
|
|
140
|
-
if (prevData
|
|
141
|
-
const
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
}
|
|
145
|
-
const newCompletedCards = prevData.completedCards.filter(({ id }) => !toRemove.has(id));
|
|
146
|
-
cache.writeFragment({
|
|
147
|
-
id: cache.identify({ id: userId, __typename: 'User' }),
|
|
178
|
+
if (prevData) {
|
|
179
|
+
const newCompletedCards = prevData.restricted.user.completedCards.filter(({ cardId }) => !toRemove.has(cardId));
|
|
180
|
+
cache.writeQuery({
|
|
181
|
+
query: USER_COMPLETED_DATA,
|
|
148
182
|
data: {
|
|
149
|
-
|
|
150
|
-
|
|
183
|
+
...prevData,
|
|
184
|
+
restricted: {
|
|
185
|
+
...prevData.restricted,
|
|
186
|
+
user: {
|
|
187
|
+
...prevData.restricted.user,
|
|
188
|
+
completedCards: newCompletedCards,
|
|
189
|
+
completedCardsCount: newCompletedCards.length,
|
|
190
|
+
},
|
|
191
|
+
},
|
|
151
192
|
},
|
|
152
|
-
fragment: COMPLETED_CARDS,
|
|
153
193
|
});
|
|
154
194
|
}
|
|
195
|
+
if (todoId) {
|
|
196
|
+
const prevData = cache.readQuery({
|
|
197
|
+
variables: { id: todoId },
|
|
198
|
+
query: TODO,
|
|
199
|
+
});
|
|
200
|
+
if (prevData) {
|
|
201
|
+
const { marks } = prevData.restricted.todo;
|
|
202
|
+
cache.writeQuery({
|
|
203
|
+
query: TODO,
|
|
204
|
+
data: {
|
|
205
|
+
...prevData,
|
|
206
|
+
restricted: {
|
|
207
|
+
...prevData.restricted,
|
|
208
|
+
todo: {
|
|
209
|
+
...prevData.restricted.todo,
|
|
210
|
+
marks: marks.filter(({ cardId }) => !toRemove.has(Number(cardId))),
|
|
211
|
+
},
|
|
212
|
+
},
|
|
213
|
+
},
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
}
|
|
155
217
|
};
|
|
156
|
-
export const
|
|
218
|
+
export const updateCacheOnAddToDailyStack = (cache, result) => {
|
|
157
219
|
const { addToDailyStack } = result.data?.restricted || {};
|
|
158
|
-
const prevData = cache.
|
|
159
|
-
|
|
160
|
-
fragment: COMPLETED_CARDS,
|
|
220
|
+
const prevData = cache.readQuery({
|
|
221
|
+
query: USER_COMPLETED_DATA,
|
|
161
222
|
});
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
223
|
+
if (prevData && addToDailyStack) {
|
|
224
|
+
const newCompletedCards = [
|
|
225
|
+
...prevData.restricted.user.completedCards,
|
|
226
|
+
...addToDailyStack,
|
|
227
|
+
];
|
|
228
|
+
cache.writeQuery({
|
|
229
|
+
query: USER_COMPLETED_DATA,
|
|
167
230
|
data: {
|
|
168
|
-
|
|
169
|
-
|
|
231
|
+
...prevData,
|
|
232
|
+
restricted: {
|
|
233
|
+
...prevData.restricted,
|
|
234
|
+
user: {
|
|
235
|
+
...prevData.restricted.user,
|
|
236
|
+
completedCards: newCompletedCards,
|
|
237
|
+
completedCardsCount: newCompletedCards.length,
|
|
238
|
+
},
|
|
239
|
+
},
|
|
170
240
|
},
|
|
171
|
-
fragment: COMPLETED_CARDS,
|
|
172
241
|
});
|
|
173
242
|
}
|
|
174
243
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import { ApolloClient } from '@apollo/client';
|
|
2
|
-
import { IMarksheetInput } from './restricted';
|
|
2
|
+
import { IMarksheetInput, ITodoInput } from './restricted';
|
|
3
3
|
export declare const saveSampleMarksheets: (client: ApolloClient<any>, marksheetInput: IMarksheetInput, questionIndex: number) => void;
|
|
4
|
+
export declare const saveSampleTodoMark: (client: ApolloClient<any>, todoInput: ITodoInput, markId: number) => void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
1
2
|
import { SAMPLE_MARKSHEET, } from '../query';
|
|
2
3
|
export const saveSampleMarksheets = (client, marksheetInput, questionIndex) => {
|
|
3
4
|
const { timeTaken, choiceId, mark, marksheetId } = marksheetInput;
|
|
@@ -31,3 +32,19 @@ export const saveSampleMarksheets = (client, marksheetInput, questionIndex) => {
|
|
|
31
32
|
});
|
|
32
33
|
}
|
|
33
34
|
};
|
|
35
|
+
export const saveSampleTodoMark = (client, todoInput, markId) => {
|
|
36
|
+
const { timeTaken, score } = todoInput;
|
|
37
|
+
client.writeFragment({
|
|
38
|
+
id: `TodoMark:${markId}`,
|
|
39
|
+
data: {
|
|
40
|
+
score,
|
|
41
|
+
timeTaken: timeTaken,
|
|
42
|
+
},
|
|
43
|
+
fragment: gql `
|
|
44
|
+
fragment UpdatedTodoMark on TodoMark {
|
|
45
|
+
score
|
|
46
|
+
timeTaken
|
|
47
|
+
}
|
|
48
|
+
`,
|
|
49
|
+
});
|
|
50
|
+
};
|