feat: separate prior records behind an owner switch and count last-period questions
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -13,6 +13,7 @@ import GamificationToaster from '@/components/gamification/GamificationToaster.v
|
||||
import { NAV_HUBS, type NavHubDef, type NavHubKey } from '@/lib/nav-hubs';
|
||||
import type {
|
||||
ActivitySummaryDto,
|
||||
AuthUserDto,
|
||||
NotificationDto,
|
||||
NotificationsListDto,
|
||||
} from '@mento/shared';
|
||||
@@ -40,6 +41,20 @@ const isMobileNav = ref(false);
|
||||
const globalSearch = ref('');
|
||||
const activityBadge = ref(0);
|
||||
const routineBadge = ref(0);
|
||||
const priorSaving = ref(false);
|
||||
const priorLens = computed(() => auth.user?.priorArchive?.lens ?? 'current');
|
||||
|
||||
async function setPriorLens(lens: 'current' | 'archive') {
|
||||
if (!auth.user?.priorArchive || priorLens.value === lens || priorSaving.value) return;
|
||||
priorSaving.value = true;
|
||||
try {
|
||||
const { data } = await api.patch<AuthUserDto>('/auth/me/prior-archive', { lens });
|
||||
auth.setUser(data);
|
||||
window.location.reload();
|
||||
} finally {
|
||||
priorSaving.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
function pathIn(prefixes: string[]) {
|
||||
return prefixes.some(
|
||||
@@ -665,6 +680,24 @@ onUnmounted(() => {
|
||||
</p>
|
||||
|
||||
<div class="sidebar-foot">
|
||||
<div v-if="auth.user?.priorArchive" class="prior-switch" role="group" aria-label="بایگانی اطلاعات قبل">
|
||||
<button
|
||||
type="button"
|
||||
:class="{ on: priorLens === 'current' }"
|
||||
:disabled="priorSaving"
|
||||
@click="setPriorLens('current')"
|
||||
>
|
||||
کار جاری
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
:class="{ on: priorLens === 'archive' }"
|
||||
:disabled="priorSaving"
|
||||
@click="setPriorLens('archive')"
|
||||
>
|
||||
بایگانی اطلاعات قبل
|
||||
</button>
|
||||
</div>
|
||||
<div class="foot-actions">
|
||||
<RouterLink
|
||||
class="profile-card profile-foot"
|
||||
@@ -1312,6 +1345,35 @@ onUnmounted(() => {
|
||||
gap: 0.55rem;
|
||||
}
|
||||
|
||||
.prior-switch {
|
||||
display: grid;
|
||||
grid-template-columns: 1fr 1fr;
|
||||
gap: 0.3rem;
|
||||
}
|
||||
|
||||
.prior-switch button {
|
||||
border: 1px solid #e2e8f0;
|
||||
background: #fff;
|
||||
color: #475569;
|
||||
border-radius: 8px;
|
||||
padding: 0.35rem 0.3rem;
|
||||
font: inherit;
|
||||
font-size: 0.68rem;
|
||||
font-weight: 700;
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.prior-switch button.on {
|
||||
background: #f0fdfa;
|
||||
border-color: #99f6e4;
|
||||
color: #0f766e;
|
||||
}
|
||||
|
||||
.prior-switch button:disabled {
|
||||
opacity: 0.6;
|
||||
cursor: wait;
|
||||
}
|
||||
|
||||
.foot-meta {
|
||||
display: grid;
|
||||
gap: 0.15rem;
|
||||
@@ -1769,6 +1831,10 @@ onUnmounted(() => {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.sidebar.collapsed .prior-switch {
|
||||
display: none;
|
||||
}
|
||||
|
||||
.sidebar.collapsed .logout-link {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
|
||||
Reference in New Issue
Block a user