feat(api): complete M5 swap and dispatch backend slice
This commit is contained in:
@@ -46,6 +46,8 @@ async function main() {
|
||||
const checkedOutAt = hoursFromNow(-20.25);
|
||||
const assignedStartsAt = hoursFromNow(0.1);
|
||||
const assignedEndsAt = hoursFromNow(8.1);
|
||||
const swapEligibleStartsAt = hoursFromNow(26);
|
||||
const swapEligibleEndsAt = hoursFromNow(34);
|
||||
const availableStartsAt = hoursFromNow(30);
|
||||
const availableEndsAt = hoursFromNow(38);
|
||||
const cancelledStartsAt = hoursFromNow(20);
|
||||
@@ -58,6 +60,7 @@ async function main() {
|
||||
await upsertUser(client, fixture.users.operationsManager);
|
||||
await upsertUser(client, fixture.users.vendorManager);
|
||||
await upsertUser(client, fixture.users.staffAna);
|
||||
await upsertUser(client, fixture.users.staffBen);
|
||||
|
||||
await client.query(
|
||||
`
|
||||
@@ -74,7 +77,8 @@ async function main() {
|
||||
($1, $2, 'ACTIVE', 'admin', '{"persona":"business_owner"}'::jsonb),
|
||||
($1, $3, 'ACTIVE', 'manager', '{"persona":"ops_manager"}'::jsonb),
|
||||
($1, $4, 'ACTIVE', 'manager', '{"persona":"vendor_manager"}'::jsonb),
|
||||
($1, $5, 'ACTIVE', 'member', '{"persona":"staff"}'::jsonb)
|
||||
($1, $5, 'ACTIVE', 'member', '{"persona":"staff"}'::jsonb),
|
||||
($1, $6, 'ACTIVE', 'member', '{"persona":"staff"}'::jsonb)
|
||||
`,
|
||||
[
|
||||
fixture.tenant.id,
|
||||
@@ -82,6 +86,7 @@ async function main() {
|
||||
fixture.users.operationsManager.id,
|
||||
fixture.users.vendorManager.id,
|
||||
fixture.users.staffAna.id,
|
||||
fixture.users.staffBen.id,
|
||||
]
|
||||
);
|
||||
|
||||
@@ -177,10 +182,13 @@ async function main() {
|
||||
id, tenant_id, user_id, full_name, email, phone, status, primary_role, onboarding_status,
|
||||
average_rating, rating_count, metadata
|
||||
)
|
||||
VALUES ($1, $2, $3, $4, $5, $6, 'ACTIVE', $7, 'COMPLETED', 4.50, 1, $8::jsonb)
|
||||
VALUES
|
||||
($1, $3, $4, $5, $6, $7, 'ACTIVE', $8, 'COMPLETED', 4.50, 1, $9::jsonb),
|
||||
($2, $3, $10, $11, $12, $13, 'ACTIVE', $14, 'COMPLETED', 4.90, 3, $15::jsonb)
|
||||
`,
|
||||
[
|
||||
fixture.staff.ana.id,
|
||||
fixture.staff.ben.id,
|
||||
fixture.tenant.id,
|
||||
fixture.users.staffAna.id,
|
||||
fixture.staff.ana.fullName,
|
||||
@@ -208,29 +216,63 @@ async function main() {
|
||||
phone: '+15550007777',
|
||||
},
|
||||
}),
|
||||
fixture.users.staffBen.id,
|
||||
fixture.staff.ben.fullName,
|
||||
fixture.staff.ben.email,
|
||||
fixture.staff.ben.phone,
|
||||
fixture.staff.ben.primaryRole,
|
||||
JSON.stringify({
|
||||
favoriteCandidate: false,
|
||||
seeded: true,
|
||||
firstName: 'Ben',
|
||||
lastName: 'Barista',
|
||||
bio: 'Reliable event barista used for swap coverage and dispatch team ranking.',
|
||||
preferredLocations: [
|
||||
{
|
||||
city: 'Mountain View',
|
||||
latitude: fixture.clockPoint.latitude,
|
||||
longitude: fixture.clockPoint.longitude,
|
||||
},
|
||||
],
|
||||
maxDistanceMiles: 15,
|
||||
industries: ['CATERING', 'CAFE'],
|
||||
skills: ['BARISTA', 'CUSTOMER_SERVICE'],
|
||||
emergencyContact: {
|
||||
name: 'Noah Barista',
|
||||
phone: '+15550008888',
|
||||
},
|
||||
}),
|
||||
]
|
||||
);
|
||||
|
||||
await client.query(
|
||||
`
|
||||
INSERT INTO staff_roles (staff_id, role_id, is_primary)
|
||||
VALUES ($1, $2, TRUE)
|
||||
VALUES
|
||||
($1, $3, TRUE),
|
||||
($2, $3, TRUE)
|
||||
`,
|
||||
[fixture.staff.ana.id, fixture.roles.barista.id]
|
||||
[fixture.staff.ana.id, fixture.staff.ben.id, fixture.roles.barista.id]
|
||||
);
|
||||
|
||||
await client.query(
|
||||
`
|
||||
INSERT INTO workforce (id, tenant_id, vendor_id, staff_id, workforce_number, employment_type, status, metadata)
|
||||
VALUES ($1, $2, $3, $4, $5, 'TEMP', 'ACTIVE', $6::jsonb)
|
||||
VALUES
|
||||
($1, $3, $4, $5, $6, 'TEMP', 'ACTIVE', $7::jsonb),
|
||||
($2, $3, $4, $8, $9, 'TEMP', 'ACTIVE', $10::jsonb)
|
||||
`,
|
||||
[
|
||||
fixture.workforce.ana.id,
|
||||
fixture.workforce.ben.id,
|
||||
fixture.tenant.id,
|
||||
fixture.vendor.id,
|
||||
fixture.staff.ana.id,
|
||||
fixture.workforce.ana.workforceNumber,
|
||||
JSON.stringify({ source: 'seed-v2-demo' }),
|
||||
fixture.staff.ben.id,
|
||||
fixture.workforce.ben.workforceNumber,
|
||||
JSON.stringify({ source: 'seed-v2-demo' }),
|
||||
]
|
||||
);
|
||||
|
||||
@@ -338,6 +380,29 @@ async function main() {
|
||||
]
|
||||
);
|
||||
|
||||
await client.query(
|
||||
`
|
||||
INSERT INTO dispatch_team_memberships (
|
||||
id, tenant_id, business_id, hub_id, staff_id, team_type, source, status, reason, effective_at, created_by_user_id, metadata
|
||||
)
|
||||
VALUES
|
||||
($1, $4, $5, NULL, $6, 'CORE', 'MANUAL', 'ACTIVE', 'Seeded core team member', NOW() - INTERVAL '7 days', $7, '{"seeded":true}'::jsonb),
|
||||
($2, $4, $5, $8, $9, 'CERTIFIED_LOCATION', 'MANUAL', 'ACTIVE', 'Seeded location-certified member', NOW() - INTERVAL '2 days', $7, '{"seeded":true}'::jsonb),
|
||||
($3, $4, $5, NULL, $9, 'MARKETPLACE', 'SYSTEM', 'ACTIVE', 'Seeded marketplace fallback member', NOW() - INTERVAL '2 days', $7, '{"seeded":true}'::jsonb)
|
||||
`,
|
||||
[
|
||||
fixture.dispatchTeamMemberships.anaCore.id,
|
||||
fixture.dispatchTeamMemberships.benCertifiedLocation.id,
|
||||
fixture.dispatchTeamMemberships.benMarketplace.id,
|
||||
fixture.tenant.id,
|
||||
fixture.business.id,
|
||||
fixture.staff.ana.id,
|
||||
fixture.users.operationsManager.id,
|
||||
fixture.clockPoint.id,
|
||||
fixture.staff.ben.id,
|
||||
]
|
||||
);
|
||||
|
||||
await client.query(
|
||||
`
|
||||
INSERT INTO orders (
|
||||
@@ -445,9 +510,10 @@ async function main() {
|
||||
)
|
||||
VALUES
|
||||
($1, $2, $3, $4, $5, $6, $7, $8, 'OPEN', $9, $10, 'America/Los_Angeles', 'Google Cafe', $11, $12, $13, $14, NULL, NULL, 1, 0, 'Available shift for staff marketplace', '{"slice":"available"}'::jsonb),
|
||||
($15, $2, $3, $4, $5, $6, $16, $17, 'ASSIGNED', $18, $19, 'America/Los_Angeles', 'Google Cafe', $11, $12, $13, $14, $30, $31, 1, 1, 'Assigned shift waiting for staff confirmation', '{"slice":"assigned"}'::jsonb),
|
||||
($20, $2, $3, $4, $5, $6, $21, $22, 'CANCELLED', $23, $24, 'America/Los_Angeles', 'Google Cafe', $11, $12, $13, $14, NULL, NULL, 1, 0, 'Cancelled shift history sample', '{"slice":"cancelled"}'::jsonb),
|
||||
($25, $2, $3, $4, $5, $6, $26, $27, 'COMPLETED', $28, $29, 'America/Los_Angeles', 'Google Cafe', $11, $12, $13, $14, 'GEO_REQUIRED', TRUE, 1, 0, 'No-show historical sample', '{"slice":"no_show"}'::jsonb)
|
||||
($15, $2, $3, $4, $5, $6, $16, $17, 'ASSIGNED', $18, $19, 'America/Los_Angeles', 'Google Cafe', $11, $12, $13, $14, $35, $36, 1, 1, 'Assigned shift waiting for staff confirmation', '{"slice":"assigned"}'::jsonb),
|
||||
($20, $2, $3, $4, $5, $6, $21, $22, 'ASSIGNED', $23, $24, 'America/Los_Angeles', 'Google Cafe', $11, $12, $13, $14, $35, $36, 1, 1, 'Future swap-eligible shift for workflow smoke coverage', '{"slice":"swap_eligible"}'::jsonb),
|
||||
($25, $2, $3, $4, $5, $6, $26, $27, 'CANCELLED', $28, $29, 'America/Los_Angeles', 'Google Cafe', $11, $12, $13, $14, NULL, NULL, 1, 0, 'Cancelled shift history sample', '{"slice":"cancelled"}'::jsonb),
|
||||
($30, $2, $3, $4, $5, $6, $31, $32, 'COMPLETED', $33, $34, 'America/Los_Angeles', 'Google Cafe', $11, $12, $13, $14, $35, $36, 1, 0, 'No-show historical sample', '{"slice":"no_show"}'::jsonb)
|
||||
`,
|
||||
[
|
||||
fixture.shifts.available.id,
|
||||
@@ -469,6 +535,11 @@ async function main() {
|
||||
fixture.shifts.assigned.title,
|
||||
assignedStartsAt,
|
||||
assignedEndsAt,
|
||||
fixture.shifts.swapEligible.id,
|
||||
fixture.shifts.swapEligible.code,
|
||||
fixture.shifts.swapEligible.title,
|
||||
swapEligibleStartsAt,
|
||||
swapEligibleEndsAt,
|
||||
fixture.shifts.cancelled.id,
|
||||
fixture.shifts.cancelled.code,
|
||||
fixture.shifts.cancelled.title,
|
||||
@@ -512,19 +583,22 @@ async function main() {
|
||||
VALUES
|
||||
($1, $2, $7, $8, $9, 1, 0, 2200, 3500, '{"slice":"available"}'::jsonb),
|
||||
($3, $4, $7, $8, $9, 1, 1, 2300, 3600, '{"slice":"assigned"}'::jsonb),
|
||||
($5, $6, $7, $8, $9, 1, 0, 2200, 3500, '{"slice":"cancelled"}'::jsonb),
|
||||
($10, $11, $7, $8, $9, 1, 0, 2200, 3500, '{"slice":"no_show"}'::jsonb)
|
||||
($5, $6, $7, $8, $9, 1, 1, 2400, 3700, '{"slice":"swap_eligible"}'::jsonb),
|
||||
($10, $11, $7, $8, $9, 1, 0, 2200, 3500, '{"slice":"cancelled"}'::jsonb),
|
||||
($12, $13, $7, $8, $9, 1, 0, 2200, 3500, '{"slice":"no_show"}'::jsonb)
|
||||
`,
|
||||
[
|
||||
fixture.shiftRoles.availableBarista.id,
|
||||
fixture.shifts.available.id,
|
||||
fixture.shiftRoles.assignedBarista.id,
|
||||
fixture.shifts.assigned.id,
|
||||
fixture.shiftRoles.cancelledBarista.id,
|
||||
fixture.shifts.cancelled.id,
|
||||
fixture.shiftRoles.swapEligibleBarista.id,
|
||||
fixture.shifts.swapEligible.id,
|
||||
fixture.roles.barista.id,
|
||||
fixture.roles.barista.code,
|
||||
fixture.roles.barista.name,
|
||||
fixture.shiftRoles.cancelledBarista.id,
|
||||
fixture.shifts.cancelled.id,
|
||||
fixture.shiftRoles.noShowBarista.id,
|
||||
fixture.shifts.noShow.id,
|
||||
]
|
||||
@@ -578,8 +652,9 @@ async function main() {
|
||||
)
|
||||
VALUES
|
||||
($1, $2, $3, $4, $5, $6, $7, $8, 'ASSIGNED', NOW(), NULL, NULL, NULL, '{"slice":"assigned"}'::jsonb),
|
||||
($9, $2, $3, $4, $10, $11, $7, $8, 'CANCELLED', NOW(), NULL, NULL, NULL, '{"slice":"cancelled","cancellationReason":"Client cancelled"}'::jsonb),
|
||||
($12, $2, $3, $4, $13, $14, $7, $8, 'NO_SHOW', $15, NULL, NULL, NULL, '{"slice":"no_show"}'::jsonb)
|
||||
($9, $2, $3, $4, $10, $11, $7, $8, 'ACCEPTED', NOW(), NOW(), NULL, NULL, '{"slice":"swap_eligible"}'::jsonb),
|
||||
($12, $2, $3, $4, $13, $14, $7, $8, 'CANCELLED', NOW(), NULL, NULL, NULL, '{"slice":"cancelled","cancellationReason":"Client cancelled"}'::jsonb),
|
||||
($15, $2, $3, $4, $16, $17, $7, $8, 'NO_SHOW', $18, NULL, NULL, NULL, '{"slice":"no_show"}'::jsonb)
|
||||
`,
|
||||
[
|
||||
fixture.assignments.assignedAna.id,
|
||||
@@ -590,6 +665,9 @@ async function main() {
|
||||
fixture.shiftRoles.assignedBarista.id,
|
||||
fixture.workforce.ana.id,
|
||||
fixture.staff.ana.id,
|
||||
fixture.assignments.swapEligibleAna.id,
|
||||
fixture.shifts.swapEligible.id,
|
||||
fixture.shiftRoles.swapEligibleBarista.id,
|
||||
fixture.assignments.cancelledAna.id,
|
||||
fixture.shifts.cancelled.id,
|
||||
fixture.shiftRoles.cancelledBarista.id,
|
||||
|
||||
@@ -25,6 +25,11 @@ export const V2DemoFixture = {
|
||||
email: process.env.V2_DEMO_STAFF_EMAIL || 'ana.barista+v2@krowd.com',
|
||||
displayName: 'Ana Barista',
|
||||
},
|
||||
staffBen: {
|
||||
id: process.env.V2_DEMO_STAFF_BEN_UID || 'demo-staff-ben-v2',
|
||||
email: process.env.V2_DEMO_STAFF_BEN_EMAIL || 'ben.barista+v2@krowd.com',
|
||||
displayName: 'Ben Barista',
|
||||
},
|
||||
},
|
||||
business: {
|
||||
id: '14f4fcfb-f21f-4ba9-9328-90f794a56001',
|
||||
@@ -62,12 +67,23 @@ export const V2DemoFixture = {
|
||||
phone: '+15557654321',
|
||||
primaryRole: 'BARISTA',
|
||||
},
|
||||
ben: {
|
||||
id: '4b7dff1a-1856-4d59-b450-5a6736461002',
|
||||
fullName: 'Ben Barista',
|
||||
email: 'ben.barista+v2@krowd.com',
|
||||
phone: '+15557654322',
|
||||
primaryRole: 'BARISTA',
|
||||
},
|
||||
},
|
||||
workforce: {
|
||||
ana: {
|
||||
id: '4cc1d34a-87c3-4426-8ee0-a24c8bcfa001',
|
||||
workforceNumber: 'WF-V2-ANA-001',
|
||||
},
|
||||
ben: {
|
||||
id: '4cc1d34a-87c3-4426-8ee0-a24c8bcfa002',
|
||||
workforceNumber: 'WF-V2-BEN-001',
|
||||
},
|
||||
},
|
||||
clockPoint: {
|
||||
id: 'efb80ccf-3361-49c8-bc74-ff8cd4d2e001',
|
||||
@@ -147,6 +163,13 @@ export const V2DemoFixture = {
|
||||
clockInMode: 'GEO_REQUIRED',
|
||||
allowClockInOverride: true,
|
||||
},
|
||||
swapEligible: {
|
||||
id: '6e7dadad-99e4-45bb-b0da-7bb617954007',
|
||||
code: 'SHIFT-V2-SWAP-1',
|
||||
title: 'Swap eligible barista shift',
|
||||
clockInMode: 'GEO_REQUIRED',
|
||||
allowClockInOverride: true,
|
||||
},
|
||||
cancelled: {
|
||||
id: '6e7dadad-99e4-45bb-b0da-7bb617954005',
|
||||
code: 'SHIFT-V2-CANCELLED-1',
|
||||
@@ -171,6 +194,9 @@ export const V2DemoFixture = {
|
||||
assignedBarista: {
|
||||
id: '4dd35b2b-4aaf-4c28-a91f-7bda05e2b004',
|
||||
},
|
||||
swapEligibleBarista: {
|
||||
id: '4dd35b2b-4aaf-4c28-a91f-7bda05e2b007',
|
||||
},
|
||||
cancelledBarista: {
|
||||
id: '4dd35b2b-4aaf-4c28-a91f-7bda05e2b005',
|
||||
},
|
||||
@@ -182,6 +208,9 @@ export const V2DemoFixture = {
|
||||
openAna: {
|
||||
id: 'd70d6441-6d0c-4fdb-9a29-c9d9e0c34001',
|
||||
},
|
||||
swapBen: {
|
||||
id: 'd70d6441-6d0c-4fdb-9a29-c9d9e0c34002',
|
||||
},
|
||||
},
|
||||
assignments: {
|
||||
completedAna: {
|
||||
@@ -190,6 +219,9 @@ export const V2DemoFixture = {
|
||||
assignedAna: {
|
||||
id: 'f1d3f738-a132-4863-b222-4f9cb25aa002',
|
||||
},
|
||||
swapEligibleAna: {
|
||||
id: 'f1d3f738-a132-4863-b222-4f9cb25aa005',
|
||||
},
|
||||
cancelledAna: {
|
||||
id: 'f1d3f738-a132-4863-b222-4f9cb25aa003',
|
||||
},
|
||||
@@ -223,6 +255,17 @@ export const V2DemoFixture = {
|
||||
id: '9b6bc737-fd69-4855-b425-6f0c2c4fd001',
|
||||
},
|
||||
},
|
||||
dispatchTeamMemberships: {
|
||||
anaCore: {
|
||||
id: '7e211d49-0b72-40bd-a79f-a1158d8a1001',
|
||||
},
|
||||
benMarketplace: {
|
||||
id: '7e211d49-0b72-40bd-a79f-a1158d8a1002',
|
||||
},
|
||||
benCertifiedLocation: {
|
||||
id: '7e211d49-0b72-40bd-a79f-a1158d8a1003',
|
||||
},
|
||||
},
|
||||
documents: {
|
||||
governmentId: {
|
||||
id: 'e6fd0183-34d9-4c23-9a9a-bf98da995000',
|
||||
|
||||
Reference in New Issue
Block a user