@startsimpli/ui 0.4.72 → 0.4.73
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@startsimpli/ui",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.73",
|
|
4
4
|
"description": "Shared UI components package for StartSimpli applications",
|
|
5
5
|
"main": "./src/index.ts",
|
|
6
6
|
"types": "./src/index.ts",
|
|
@@ -42,8 +42,8 @@
|
|
|
42
42
|
"next": "^14.0.0 || ^15.0.0 || ^16.0.0",
|
|
43
43
|
"react": "^18.0.0 || ^19.0.0",
|
|
44
44
|
"react-dom": "^18.0.0 || ^19.0.0",
|
|
45
|
-
"@startsimpli/
|
|
46
|
-
"@startsimpli/
|
|
45
|
+
"@startsimpli/api": "^0.5.45",
|
|
46
|
+
"@startsimpli/auth": "^0.4.31"
|
|
47
47
|
},
|
|
48
48
|
"peerDependenciesMeta": {
|
|
49
49
|
"@startsimpli/api": {
|
|
@@ -27,6 +27,7 @@ import {
|
|
|
27
27
|
gradeWords,
|
|
28
28
|
wordTargets,
|
|
29
29
|
sourceOverlapCheck,
|
|
30
|
+
pickChanges,
|
|
30
31
|
type DraftGroup,
|
|
31
32
|
type DraftSource,
|
|
32
33
|
type CheckStatus,
|
|
@@ -93,14 +94,7 @@ export function DraftReviewWorkspace({ client }: DraftReviewWorkspaceProps) {
|
|
|
93
94
|
async function pick(group: DraftGroup, cand: EntityRecord) {
|
|
94
95
|
setBusyKey(group.key);
|
|
95
96
|
try {
|
|
96
|
-
await Promise.all(
|
|
97
|
-
group.candidates.map((c) =>
|
|
98
|
-
writeEntity(c, {
|
|
99
|
-
chosen: String(c.id) === String(cand.id),
|
|
100
|
-
status: String(c.id) === String(cand.id) ? 'selected' : field(c, 'status') === 'ready' ? 'ready' : '',
|
|
101
|
-
}),
|
|
102
|
-
),
|
|
103
|
-
);
|
|
97
|
+
await Promise.all(group.candidates.map((c) => writeEntity(c, pickChanges(c.id, cand.id))));
|
|
104
98
|
await qc.invalidateQueries({ queryKey: ['entities', 'draft'] });
|
|
105
99
|
} catch (err) {
|
|
106
100
|
notify.error(err instanceof Error ? err.message : 'Could not save the pick.');
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { parseSources, normUrl, groupKeyOf, groupDrafts, candidateTitle, gradeWords, wordTargets, sourceOverlapCheck } from '../drafts';
|
|
1
|
+
import { parseSources, normUrl, groupKeyOf, groupDrafts, candidateTitle, gradeWords, wordTargets, sourceOverlapCheck, pickChanges } from '../drafts';
|
|
2
2
|
import type { EntityRecord } from '../types';
|
|
3
3
|
|
|
4
4
|
function rec(id: string, name: string, data: Record<string, unknown>): EntityRecord {
|
|
@@ -121,3 +121,16 @@ describe('sourceOverlapCheck (768w.18.16.2 wiring)', () => {
|
|
|
121
121
|
expect(check!.status).toBe('fail');
|
|
122
122
|
});
|
|
123
123
|
});
|
|
124
|
+
|
|
125
|
+
describe('pickChanges (startsim-yvd3 — pick must not write an invalid status)', () => {
|
|
126
|
+
it('marks the picked candidate chosen and writes NO status key', () => {
|
|
127
|
+
const picked = pickChanges('a', 'a');
|
|
128
|
+
expect(picked).toEqual({ chosen: true });
|
|
129
|
+
expect('status' in picked).toBe(false); // status enum is the tenant's; picking must not touch it
|
|
130
|
+
expect(pickChanges('b', 'a')).toEqual({ chosen: false });
|
|
131
|
+
});
|
|
132
|
+
it('compares ids as strings (handles number vs string ids)', () => {
|
|
133
|
+
expect(pickChanges(7 as unknown as string, '7')).toEqual({ chosen: true });
|
|
134
|
+
expect(pickChanges(7 as unknown as string, 8 as unknown as string)).toEqual({ chosen: false });
|
|
135
|
+
});
|
|
136
|
+
});
|
|
@@ -160,6 +160,17 @@ export function gradeWords(count: number, [lo, hi]: [number, number]): CheckStat
|
|
|
160
160
|
return 'ok';
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
/**
|
|
164
|
+
* The record change a Pick applies to ONE candidate: mark it chosen (true for the
|
|
165
|
+
* picked candidate, false for the rest). Picking is a selection flag — it must NOT
|
|
166
|
+
* write a lifecycle `status`. The tenant constrains draft `status` to an enum, so
|
|
167
|
+
* writing 'selected' (or '') 400s the whole pick (startsim-yvd3); the "picked"
|
|
168
|
+
* badge already keys off `chosen` via isChosen(). Pure, so it's unit-tested.
|
|
169
|
+
*/
|
|
170
|
+
export function pickChanges(candidateId: EntityRecord['id'], pickedId: EntityRecord['id']): { chosen: boolean } {
|
|
171
|
+
return { chosen: String(candidateId) === String(pickedId) };
|
|
172
|
+
}
|
|
173
|
+
|
|
163
174
|
/**
|
|
164
175
|
* The verbatim-overlap guardrail (768w.18.16.2) for a single draft. Runs the
|
|
165
176
|
* shared `source-overlap` check over the draft's blog + linkedin against the
|