improvement: newly created organization's subscriptions flow improved.
This commit is contained in:
@@ -4,6 +4,8 @@ import { useEffect, useMemo, useState } from 'react';
|
||||
import { Plus } from 'lucide-react';
|
||||
import { Button } from '@/components/ui/common/Button';
|
||||
import { patientsApi } from '@/lib/api/patients';
|
||||
import { useAuth } from '@/lib/hooks/useAuth';
|
||||
import { hasPermission } from '@/shared/permissions';
|
||||
import {
|
||||
CreatePatientInput,
|
||||
CreateTreatmentHistoryInput,
|
||||
@@ -23,6 +25,7 @@ const EMPTY_PATIENT_FORM: CreatePatientInput = {
|
||||
};
|
||||
|
||||
export default function PatientsPage() {
|
||||
const { currentOrganization } = useAuth();
|
||||
const [search, setSearch] = useState('');
|
||||
const [patients, setPatients] = useState<Patient[]>([]);
|
||||
const [selectedPatient, setSelectedPatient] = useState<Patient | undefined>();
|
||||
@@ -35,6 +38,7 @@ export default function PatientsPage() {
|
||||
const [patientForm, setPatientForm] = useState<CreatePatientInput>(EMPTY_PATIENT_FORM);
|
||||
const [errorMessage, setErrorMessage] = useState<string>('');
|
||||
const [successMessage, setSuccessMessage] = useState<string>('');
|
||||
const canEditPatients = hasPermission(currentOrganization, 'TAB_PATIENTS_EDIT');
|
||||
|
||||
const sortedPatients = useMemo(
|
||||
() =>
|
||||
@@ -154,7 +158,16 @@ export default function PatientsPage() {
|
||||
<div className="relative space-y-6 pb-20">
|
||||
<div className="flex items-center justify-between">
|
||||
<h1 className="text-2xl font-semibold text-text-primary">Patients</h1>
|
||||
<Button variant="primary" className="flex items-center gap-2" onClick={() => setIsCreateOpen(true)}>
|
||||
<Button
|
||||
variant="primary"
|
||||
className="flex items-center gap-2"
|
||||
disabled={!canEditPatients}
|
||||
onClick={() => {
|
||||
if (!canEditPatients) return;
|
||||
setIsCreateOpen(true);
|
||||
}}
|
||||
title={!canEditPatients ? 'Read-only access for this organization.' : undefined}
|
||||
>
|
||||
<Plus className="h-4 w-4 icon-flat" />
|
||||
New Patient
|
||||
</Button>
|
||||
@@ -189,9 +202,13 @@ export default function PatientsPage() {
|
||||
<div className="flex">
|
||||
<Button
|
||||
variant="secondary"
|
||||
disabled={!selectedPatient}
|
||||
disabled={!selectedPatient || !canEditPatients}
|
||||
isLoading={savingTreatment}
|
||||
onClick={handleQuickAddTreatment}
|
||||
onClick={() => {
|
||||
if (!canEditPatients) return;
|
||||
void handleQuickAddTreatment();
|
||||
}}
|
||||
title={!canEditPatients ? 'Read-only access for this organization.' : undefined}
|
||||
>
|
||||
Add Quick Treatment Entry
|
||||
</Button>
|
||||
|
||||
Reference in New Issue
Block a user