Shitty gadgets removed. Some useful gadgets added.

This commit is contained in:
2026-07-11 03:12:56 +03:30
parent 2f8c9f0f4d
commit ed8ff61205
31 changed files with 1489 additions and 170 deletions

View File

@@ -6,6 +6,9 @@ import { Link } from '@/i18n/navigation';
import { useAuth } from '@/lib/hooks/useAuth';
import {
canAccessAppointmentsSection,
canViewAppointmentsTab,
canViewCases,
canViewLabCasesOrTasks,
canViewTasks,
canViewTreatment,
} from '@/components/shared/permissions';
@@ -27,17 +30,26 @@ export default function TodayPage() {
const showNoSubscriptionNotice =
Boolean(currentOrganization?.isOwner) && !currentOrganization?.plan;
const showUpcoming = canAccessAppointmentsSection(currentOrganization);
const showCharts =
(currentOrganization?.type === 'CLINIC' && canViewTreatment(currentOrganization)) ||
(currentOrganization?.type === 'LAB' && canViewTasks(currentOrganization));
const showUpcoming =
currentOrganization?.type === 'CLINIC' && canViewTreatment(currentOrganization);
const showCharts = useMemo(() => {
const orgType = currentOrganization?.type;
if (!orgType) return false;
const actionLayoutClass = useMemo(() => {
if (showUpcoming && showCharts) {
return 'grid grid-cols-1 xl:grid-cols-2 gap-4 items-start';
if (orgType === 'CLINIC') {
return (
canAccessAppointmentsSection(currentOrganization) ||
canViewAppointmentsTab(currentOrganization) ||
canViewTreatment(currentOrganization)
);
}
return 'grid grid-cols-1 gap-4';
}, [showUpcoming, showCharts]);
return (
canViewCases(currentOrganization) ||
canViewTasks(currentOrganization) ||
canViewLabCasesOrTasks(currentOrganization)
);
}, [currentOrganization]);
const sectionErrorMessage = t('sectionLoadError');
@@ -89,33 +101,38 @@ export default function TodayPage() {
/>
</TodayWidgetErrorBoundary>
{(showUpcoming || showCharts) && (!error || data) ? (
<div className={actionLayoutClass}>
{showUpcoming ? (
<TodayWidgetErrorBoundary
fallback={<TodaySectionErrorFallback message={sectionErrorMessage} />}
>
<TodayUpcomingAppointments
actions={data?.actions ?? {}}
loading={loading}
isInitialLoad={isInitialLoad}
/>
</TodayWidgetErrorBoundary>
) : null}
{showCharts ? (
<TodayWidgetErrorBoundary
fallback={<TodaySectionErrorFallback message={sectionErrorMessage} />}
>
{showUpcoming && (!error || data) ? (
<TodayWidgetErrorBoundary
fallback={<TodaySectionErrorFallback message={sectionErrorMessage} />}
>
<div
className={`grid grid-cols-1 gap-4 lg:grid-cols-2 ${loading ? 'opacity-70 transition-opacity' : ''}`}
>
<TodayUpcomingAppointments
actions={data?.actions ?? {}}
loading={loading}
isInitialLoad={isInitialLoad}
/>
{showCharts ? (
<TodayChartsSection
charts={data?.charts ?? {}}
loading={loading}
isInitialLoad={isInitialLoad}
className={showUpcoming ? '' : 'max-w-none'}
embedded
/>
</TodayWidgetErrorBoundary>
) : null}
</div>
) : null}
</div>
</TodayWidgetErrorBoundary>
) : showCharts && (!error || data) ? (
<TodayWidgetErrorBoundary
fallback={<TodaySectionErrorFallback message={sectionErrorMessage} />}
>
<TodayChartsSection
charts={data?.charts ?? {}}
loading={loading}
isInitialLoad={isInitialLoad}
/>
</TodayWidgetErrorBoundary>
) : null}
</div>
);

View File

@@ -1,12 +1,15 @@
'use client';
import { useTranslations } from 'next-intl';
import { useSearchParams } from 'next/navigation';
import { TreatmentWorkspace } from '@/components/ui/treatment/TreatmentWorkspace';
import { useAuth } from '@/lib/hooks/useAuth';
export default function TreatmentPage() {
const t = useTranslations('treatment');
const { user, currentOrganization, isAuthReady } = useAuth();
const searchParams = useSearchParams();
const initialAppointmentId = searchParams.get('appointmentId');
if (!isAuthReady || !user) {
return (
@@ -15,6 +18,10 @@ export default function TreatmentPage() {
}
return (
<TreatmentWorkspace userId={user.id} currentOrganization={currentOrganization} />
<TreatmentWorkspace
userId={user.id}
currentOrganization={currentOrganization}
initialAppointmentId={initialAppointmentId}
/>
);
}