c2914c37e5
CI / verify (pull_request) Has been cancelled
Default new sub-accounts to store:create+store:manage, backfill empty permissions on /partner/me, and treat legacy store staff as allowed to mutate. Co-authored-by: Cursor <cursoragent@cursor.com>
44 lines
1.4 KiB
TypeScript
44 lines
1.4 KiB
TypeScript
import { PartnerStaffRole, DEFAULT_PARTNER_STORE_STAFF_PERMISSIONS } from '@dukang/shared-types';
|
|
import type { CreatePartnerStaffRequest, PartnerStaffItem, UpdatePartnerStaffRequest } from '@dukang/shared-types';
|
|
import { request } from './api';
|
|
|
|
export function listPartnerStaff() {
|
|
return request<PartnerStaffItem[]>('PARTNER_H5', '/partner/staff');
|
|
}
|
|
|
|
export function sendPartnerStaffPhoneSms(phone: string) {
|
|
return request<{ ok: boolean; maskedPhone: string }>('PARTNER_H5', '/partner/staff/send-phone-sms', {
|
|
method: 'POST',
|
|
body: JSON.stringify({ phone: phone.trim() }),
|
|
silent: true,
|
|
});
|
|
}
|
|
|
|
export function createPartnerStaff(body: CreatePartnerStaffRequest) {
|
|
return request<PartnerStaffItem>('PARTNER_H5', '/partner/staff', {
|
|
method: 'POST',
|
|
body: JSON.stringify({
|
|
name: body.name,
|
|
phone: body.phone,
|
|
smsCode: body.smsCode,
|
|
staffRole: body.staffRole ?? PartnerStaffRole.INTERNAL,
|
|
permissions: body.permissions?.length
|
|
? body.permissions
|
|
: [...DEFAULT_PARTNER_STORE_STAFF_PERMISSIONS],
|
|
}),
|
|
});
|
|
}
|
|
|
|
export function updatePartnerStaff(id: string, body: UpdatePartnerStaffRequest) {
|
|
return request<PartnerStaffItem>('PARTNER_H5', `/partner/staff/${id}`, {
|
|
method: 'PUT',
|
|
body: JSON.stringify(body),
|
|
});
|
|
}
|
|
|
|
export function deletePartnerStaff(id: string) {
|
|
return request<{ ok: boolean }>('PARTNER_H5', `/partner/staff/${id}`, {
|
|
method: 'DELETE',
|
|
});
|
|
}
|