feat(web): add prior archive promote actions
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -497,6 +497,33 @@ function onOpenDeal(dealId: string) {
|
||||
void router.push({ name: 'deal-detail', params: { id: dealId } });
|
||||
}
|
||||
|
||||
function findDeal(dealId: string | null) {
|
||||
if (!dealId) return null;
|
||||
for (const stage of stages.value) {
|
||||
const deal = stage.deals.find((d) => d.id === dealId);
|
||||
if (deal) return deal;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function canPromotePrior(deal: PipelineDeal | null) {
|
||||
const pa = auth.user?.priorArchive;
|
||||
if (!deal || !pa || pa.lens !== 'archive' || !pa.cutoffAt || !deal.createdAt) return false;
|
||||
if (deal.promotedFromPriorAt) return false;
|
||||
return new Date(deal.createdAt).getTime() < new Date(pa.cutoffAt).getTime();
|
||||
}
|
||||
|
||||
async function promotePriorDeal(dealId: string) {
|
||||
menuOpenId.value = null;
|
||||
error.value = '';
|
||||
try {
|
||||
await api.post(`/deals/${dealId}/promote-from-prior`);
|
||||
await load();
|
||||
} catch (e) {
|
||||
error.value = apiMessage(e, 'انتقال معامله به کار جاری ناموفق بود.');
|
||||
}
|
||||
}
|
||||
|
||||
const pageBusy = ref(false);
|
||||
const busyMessage = ref('لطفاً صبر کنید…');
|
||||
|
||||
@@ -721,6 +748,14 @@ defineExpose({ updateDealStage: applyUpdateDealStage });
|
||||
>
|
||||
ویرایش
|
||||
</button>
|
||||
<button
|
||||
v-if="canPromotePrior(findDeal(menuOpenId))"
|
||||
type="button"
|
||||
role="menuitem"
|
||||
@click="promotePriorDeal(menuOpenId)"
|
||||
>
|
||||
انتقال به کار جاری
|
||||
</button>
|
||||
<button type="button" role="menuitem" class="danger" @click="askDeleteDeal(menuOpenId)">
|
||||
حذف
|
||||
</button>
|
||||
|
||||
Reference in New Issue
Block a user