From 79e352037b68269a38207d8092d13283b2d836ba Mon Sep 17 00:00:00 2001 From: andrei Date: Thu, 3 Jul 2025 15:00:12 +0500 Subject: [PATCH] =?UTF-8?q?feat:=20=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB?= =?UTF-8?q?=D0=B5=D0=BD=D1=8B=20=D0=BA=D0=B0=D1=81=D0=BA=D0=B0=D0=B4=D0=BD?= =?UTF-8?q?=D1=8B=D0=B5=20=D1=83=D0=B4=D0=B0=D0=BB=D0=B5=D0=BD=D0=B8=D1=8F?= =?UTF-8?q?=20=D0=B2=20=D0=91=D0=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...a676b_0009_расставил_каскадные_удаления.py | 148 ++++++++++++++++++ api/app/domain/models/appointment_files.py | 5 +- api/app/domain/models/appointments.py | 6 +- api/app/domain/models/backups.py | 2 +- api/app/domain/models/lens.py | 2 +- api/app/domain/models/lens_issues.py | 6 +- api/app/domain/models/mailing.py | 2 +- api/app/domain/models/mailing_options.py | 5 +- api/app/domain/models/recipients.py | 4 +- .../domain/models/scheduled_appointments.py | 6 +- api/app/domain/models/sessions.py | 2 +- api/app/domain/models/set_contents.py | 4 +- web-app/src/Api/patientsApi.js | 11 +- web-app/src/App/AppRouter.jsx | 2 + 14 files changed, 182 insertions(+), 23 deletions(-) create mode 100644 api/app/database/migrations/versions/4e6d875a676b_0009_расставил_каскадные_удаления.py diff --git a/api/app/database/migrations/versions/4e6d875a676b_0009_расставил_каскадные_удаления.py b/api/app/database/migrations/versions/4e6d875a676b_0009_расставил_каскадные_удаления.py new file mode 100644 index 0000000..f5ac4d7 --- /dev/null +++ b/api/app/database/migrations/versions/4e6d875a676b_0009_расставил_каскадные_удаления.py @@ -0,0 +1,148 @@ +"""0009 расставил каскадные удаления + +Revision ID: 4e6d875a676b +Revises: b013393cef10 +Create Date: 2025-07-03 14:59:33.778959 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa + + +# revision identifiers, used by Alembic. +revision: str = '4e6d875a676b' +down_revision: Union[str, None] = 'b013393cef10' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint('appointment_files_appointment_id_fkey', 'appointment_files', type_='foreignkey') + op.create_foreign_key(None, 'appointment_files', 'appointments', ['appointment_id'], ['id'], source_schema='public', referent_schema='public', ondelete='CASCADE') + op.alter_column('appointments', 'doctor_id', + existing_type=sa.INTEGER(), + nullable=True) + op.drop_constraint('appointments_type_id_fkey', 'appointments', type_='foreignkey') + op.drop_constraint('appointments_doctor_id_fkey', 'appointments', type_='foreignkey') + op.drop_constraint('appointments_patient_id_fkey', 'appointments', type_='foreignkey') + op.create_foreign_key(None, 'appointments', 'patients', ['patient_id'], ['id'], source_schema='public', referent_schema='public', ondelete='CASCADE') + op.create_foreign_key(None, 'appointments', 'users', ['doctor_id'], ['id'], source_schema='public', referent_schema='public', ondelete='SET NULL') + op.create_foreign_key(None, 'appointments', 'appointment_types', ['type_id'], ['id'], source_schema='public', referent_schema='public', ondelete='CASCADE') + op.alter_column('backups', 'user_id', + existing_type=sa.INTEGER(), + nullable=True) + op.drop_constraint('backups_user_id_fkey', 'backups', type_='foreignkey') + op.create_foreign_key(None, 'backups', 'users', ['user_id'], ['id'], source_schema='public', referent_schema='public', ondelete='SET NULL') + op.drop_constraint('lens_type_id_fkey', 'lens', type_='foreignkey') + op.create_foreign_key(None, 'lens', 'lens_types', ['type_id'], ['id'], source_schema='public', referent_schema='public', ondelete='CASCADE') + op.alter_column('lens_issues', 'doctor_id', + existing_type=sa.INTEGER(), + nullable=True) + op.drop_constraint('lens_issues_patient_id_fkey', 'lens_issues', type_='foreignkey') + op.drop_constraint('lens_issues_lens_id_fkey', 'lens_issues', type_='foreignkey') + op.drop_constraint('lens_issues_doctor_id_fkey', 'lens_issues', type_='foreignkey') + op.create_foreign_key(None, 'lens_issues', 'users', ['doctor_id'], ['id'], source_schema='public', referent_schema='public', ondelete='SET NULL') + op.create_foreign_key(None, 'lens_issues', 'patients', ['patient_id'], ['id'], source_schema='public', referent_schema='public', ondelete='CASCADE') + op.create_foreign_key(None, 'lens_issues', 'lens', ['lens_id'], ['id'], source_schema='public', referent_schema='public', ondelete='CASCADE') + op.alter_column('mailing', 'user_id', + existing_type=sa.INTEGER(), + nullable=True) + op.drop_constraint('mailing_user_id_fkey', 'mailing', type_='foreignkey') + op.create_foreign_key(None, 'mailing', 'users', ['user_id'], ['id'], source_schema='public', referent_schema='public', ondelete='SET NULL') + op.drop_constraint('mailing_options_mailing_id_fkey', 'mailing_options', type_='foreignkey') + op.drop_constraint('mailing_options_option_id_fkey', 'mailing_options', type_='foreignkey') + op.create_foreign_key(None, 'mailing_options', 'mailing_delivery_methods', ['option_id'], ['id'], source_schema='public', referent_schema='public', ondelete='CASCADE') + op.create_foreign_key(None, 'mailing_options', 'mailing', ['mailing_id'], ['id'], source_schema='public', referent_schema='public', ondelete='CASCADE') + op.drop_constraint('recipients_patient_id_fkey', 'recipients', type_='foreignkey') + op.drop_constraint('recipients_mailing_id_fkey', 'recipients', type_='foreignkey') + op.create_foreign_key(None, 'recipients', 'patients', ['patient_id'], ['id'], source_schema='public', referent_schema='public', ondelete='CASCADE') + op.create_foreign_key(None, 'recipients', 'mailing', ['mailing_id'], ['id'], source_schema='public', referent_schema='public', ondelete='CASCADE') + op.alter_column('scheduled_appointments', 'doctor_id', + existing_type=sa.INTEGER(), + nullable=True) + op.drop_constraint('scheduled_appointments_doctor_id_fkey', 'scheduled_appointments', type_='foreignkey') + op.drop_constraint('scheduled_appointments_patient_id_fkey', 'scheduled_appointments', type_='foreignkey') + op.drop_constraint('scheduled_appointments_type_id_fkey', 'scheduled_appointments', type_='foreignkey') + op.create_foreign_key(None, 'scheduled_appointments', 'users', ['doctor_id'], ['id'], source_schema='public', referent_schema='public', ondelete='SET NULL') + op.create_foreign_key(None, 'scheduled_appointments', 'appointment_types', ['type_id'], ['id'], source_schema='public', referent_schema='public', ondelete='CASCADE') + op.create_foreign_key(None, 'scheduled_appointments', 'patients', ['patient_id'], ['id'], source_schema='public', referent_schema='public', ondelete='CASCADE') + op.alter_column('sessions', 'user_id', + existing_type=sa.INTEGER(), + nullable=True) + op.drop_constraint('sessions_user_id_fkey', 'sessions', type_='foreignkey') + op.create_foreign_key(None, 'sessions', 'users', ['user_id'], ['id'], source_schema='public', referent_schema='public', ondelete='SET NULL') + op.drop_constraint('set_contents_type_id_fkey', 'set_contents', type_='foreignkey') + op.drop_constraint('set_contents_set_id_fkey', 'set_contents', type_='foreignkey') + op.create_foreign_key(None, 'set_contents', 'lens_types', ['type_id'], ['id'], source_schema='public', referent_schema='public', ondelete='CASCADE') + op.create_foreign_key(None, 'set_contents', 'sets', ['set_id'], ['id'], source_schema='public', referent_schema='public', ondelete='CASCADE') + op.drop_constraint('users_role_id_fkey', 'users', type_='foreignkey') + op.create_foreign_key(None, 'users', 'roles', ['role_id'], ['id'], source_schema='public', referent_schema='public') + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.drop_constraint(None, 'users', schema='public', type_='foreignkey') + op.create_foreign_key('users_role_id_fkey', 'users', 'roles', ['role_id'], ['id']) + op.drop_constraint(None, 'set_contents', schema='public', type_='foreignkey') + op.drop_constraint(None, 'set_contents', schema='public', type_='foreignkey') + op.create_foreign_key('set_contents_set_id_fkey', 'set_contents', 'sets', ['set_id'], ['id']) + op.create_foreign_key('set_contents_type_id_fkey', 'set_contents', 'lens_types', ['type_id'], ['id']) + op.drop_constraint(None, 'sessions', schema='public', type_='foreignkey') + op.create_foreign_key('sessions_user_id_fkey', 'sessions', 'users', ['user_id'], ['id']) + op.alter_column('sessions', 'user_id', + existing_type=sa.INTEGER(), + nullable=False) + op.drop_constraint(None, 'scheduled_appointments', schema='public', type_='foreignkey') + op.drop_constraint(None, 'scheduled_appointments', schema='public', type_='foreignkey') + op.drop_constraint(None, 'scheduled_appointments', schema='public', type_='foreignkey') + op.create_foreign_key('scheduled_appointments_type_id_fkey', 'scheduled_appointments', 'appointment_types', ['type_id'], ['id']) + op.create_foreign_key('scheduled_appointments_patient_id_fkey', 'scheduled_appointments', 'patients', ['patient_id'], ['id']) + op.create_foreign_key('scheduled_appointments_doctor_id_fkey', 'scheduled_appointments', 'users', ['doctor_id'], ['id']) + op.alter_column('scheduled_appointments', 'doctor_id', + existing_type=sa.INTEGER(), + nullable=False) + op.drop_constraint(None, 'recipients', schema='public', type_='foreignkey') + op.drop_constraint(None, 'recipients', schema='public', type_='foreignkey') + op.create_foreign_key('recipients_mailing_id_fkey', 'recipients', 'mailing', ['mailing_id'], ['id']) + op.create_foreign_key('recipients_patient_id_fkey', 'recipients', 'patients', ['patient_id'], ['id']) + op.drop_constraint(None, 'mailing_options', schema='public', type_='foreignkey') + op.drop_constraint(None, 'mailing_options', schema='public', type_='foreignkey') + op.create_foreign_key('mailing_options_option_id_fkey', 'mailing_options', 'mailing_delivery_methods', ['option_id'], ['id']) + op.create_foreign_key('mailing_options_mailing_id_fkey', 'mailing_options', 'mailing', ['mailing_id'], ['id']) + op.drop_constraint(None, 'mailing', schema='public', type_='foreignkey') + op.create_foreign_key('mailing_user_id_fkey', 'mailing', 'users', ['user_id'], ['id']) + op.alter_column('mailing', 'user_id', + existing_type=sa.INTEGER(), + nullable=False) + op.drop_constraint(None, 'lens_issues', schema='public', type_='foreignkey') + op.drop_constraint(None, 'lens_issues', schema='public', type_='foreignkey') + op.drop_constraint(None, 'lens_issues', schema='public', type_='foreignkey') + op.create_foreign_key('lens_issues_doctor_id_fkey', 'lens_issues', 'users', ['doctor_id'], ['id']) + op.create_foreign_key('lens_issues_lens_id_fkey', 'lens_issues', 'lens', ['lens_id'], ['id']) + op.create_foreign_key('lens_issues_patient_id_fkey', 'lens_issues', 'patients', ['patient_id'], ['id']) + op.alter_column('lens_issues', 'doctor_id', + existing_type=sa.INTEGER(), + nullable=False) + op.drop_constraint(None, 'lens', schema='public', type_='foreignkey') + op.create_foreign_key('lens_type_id_fkey', 'lens', 'lens_types', ['type_id'], ['id']) + op.drop_constraint(None, 'backups', schema='public', type_='foreignkey') + op.create_foreign_key('backups_user_id_fkey', 'backups', 'users', ['user_id'], ['id']) + op.alter_column('backups', 'user_id', + existing_type=sa.INTEGER(), + nullable=False) + op.drop_constraint(None, 'appointments', schema='public', type_='foreignkey') + op.drop_constraint(None, 'appointments', schema='public', type_='foreignkey') + op.drop_constraint(None, 'appointments', schema='public', type_='foreignkey') + op.create_foreign_key('appointments_patient_id_fkey', 'appointments', 'patients', ['patient_id'], ['id']) + op.create_foreign_key('appointments_doctor_id_fkey', 'appointments', 'users', ['doctor_id'], ['id']) + op.create_foreign_key('appointments_type_id_fkey', 'appointments', 'appointment_types', ['type_id'], ['id']) + op.alter_column('appointments', 'doctor_id', + existing_type=sa.INTEGER(), + nullable=False) + op.drop_constraint(None, 'appointment_files', schema='public', type_='foreignkey') + op.create_foreign_key('appointment_files_appointment_id_fkey', 'appointment_files', 'appointments', ['appointment_id'], ['id']) + # ### end Alembic commands ### diff --git a/api/app/domain/models/appointment_files.py b/api/app/domain/models/appointment_files.py index c9ba32f..b3ad62e 100644 --- a/api/app/domain/models/appointment_files.py +++ b/api/app/domain/models/appointment_files.py @@ -12,6 +12,7 @@ class AppointmentFile(BaseModel): file_path = Column(String, nullable=False) file_title = Column(String, nullable=False) - appointment_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.appointments.id'), nullable=False) + appointment_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.appointments.id', ondelete='CASCADE'), + nullable=False) - appointment = relationship('Appointment', back_populates='files') \ No newline at end of file + appointment = relationship('Appointment', back_populates='files') diff --git a/api/app/domain/models/appointments.py b/api/app/domain/models/appointments.py index 43ed4b8..65a7b4b 100644 --- a/api/app/domain/models/appointments.py +++ b/api/app/domain/models/appointments.py @@ -14,9 +14,9 @@ class Appointment(BaseModel): days_until_the_next_appointment = Column(Integer) appointment_datetime = Column(DateTime, nullable=False, server_default=func.now()) - patient_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.patients.id'), nullable=False) - doctor_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.users.id'), nullable=False) - type_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.appointment_types.id'), nullable=False) + patient_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.patients.id', ondelete='CASCADE'), nullable=False) + doctor_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.users.id', ondelete='SET NULL'), nullable=True) + type_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.appointment_types.id', ondelete='CASCADE'), nullable=False) patient = relationship('Patient', back_populates='appointments') doctor = relationship('User', back_populates='appointments') diff --git a/api/app/domain/models/backups.py b/api/app/domain/models/backups.py index 07058f2..5f814c8 100644 --- a/api/app/domain/models/backups.py +++ b/api/app/domain/models/backups.py @@ -15,4 +15,4 @@ class Backup(BaseModel): filename = Column(String, nullable=False) is_by_user = Column(Boolean, nullable=False, default=False) - user_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.users.id'), nullable=False) + user_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.users.id', ondelete='SET NULL'), nullable=True) \ No newline at end of file diff --git a/api/app/domain/models/lens.py b/api/app/domain/models/lens.py index 8a94c5d..010d0d0 100644 --- a/api/app/domain/models/lens.py +++ b/api/app/domain/models/lens.py @@ -26,7 +26,7 @@ class Lens(BaseModel): side = Column(Enum(SideEnum), nullable=False) issued = Column(Boolean, nullable=False, default=False) - type_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.lens_types.id'), nullable=False) + type_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.lens_types.id', ondelete='CASCADE'), nullable=False) type = relationship('LensType', back_populates='lenses') diff --git a/api/app/domain/models/lens_issues.py b/api/app/domain/models/lens_issues.py index 23a0712..9b0c5dc 100644 --- a/api/app/domain/models/lens_issues.py +++ b/api/app/domain/models/lens_issues.py @@ -11,9 +11,9 @@ class LensIssue(BaseModel): issue_date = Column(Date, nullable=False) - patient_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.patients.id'), nullable=False) - doctor_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.users.id'), nullable=False) - lens_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.lens.id'), nullable=False) + patient_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.patients.id', ondelete='CASCADE'), nullable=False) + doctor_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.users.id', ondelete='SET NULL'), nullable=True) + lens_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.lens.id', ondelete='CASCADE'), nullable=False) patient = relationship('Patient', back_populates='lens_issues') doctor = relationship('User', back_populates='lens_issues') diff --git a/api/app/domain/models/mailing.py b/api/app/domain/models/mailing.py index dda55d7..a9e64a1 100644 --- a/api/app/domain/models/mailing.py +++ b/api/app/domain/models/mailing.py @@ -14,7 +14,7 @@ class Mailing(BaseModel): title = Column(String, nullable=False) datetime = Column(DateTime, nullable=False, default=func.utcnow) - user_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.users.id'), nullable=False) + user_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.users.id', ondelete='SET NULL'), nullable=True) user = relationship('User', back_populates='mailing') diff --git a/api/app/domain/models/mailing_options.py b/api/app/domain/models/mailing_options.py index 7e68412..d93eeb8 100644 --- a/api/app/domain/models/mailing_options.py +++ b/api/app/domain/models/mailing_options.py @@ -9,8 +9,9 @@ class MailingOption(BaseModel): __tablename__ = 'mailing_options' __table_args__ = {"schema": settings.SCHEMA} - option_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.mailing_delivery_methods.id'), nullable=False) - mailing_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.mailing.id'), nullable=False) + option_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.mailing_delivery_methods.id', ondelete='CASCADE'), + nullable=False) + mailing_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.mailing.id', ondelete='CASCADE'), nullable=False) method = relationship('MailingDeliveryMethod', back_populates='mailing') mailing = relationship('Mailing', back_populates='mailing_options') diff --git a/api/app/domain/models/recipients.py b/api/app/domain/models/recipients.py index 65c8cc2..e38c4ea 100644 --- a/api/app/domain/models/recipients.py +++ b/api/app/domain/models/recipients.py @@ -9,8 +9,8 @@ class Recipient(BaseModel): __tablename__ = 'recipients' __table_args__ = {"schema": settings.SCHEMA} - patient_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.patients.id'), nullable=False) - mailing_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.mailing.id'), nullable=False) + patient_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.patients.id', ondelete='CASCADE'), nullable=False) + mailing_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.mailing.id', ondelete='CASCADE'), nullable=False) patient = relationship('Patient', back_populates='mailing') mailing = relationship('Mailing', back_populates='recipients') diff --git a/api/app/domain/models/scheduled_appointments.py b/api/app/domain/models/scheduled_appointments.py index 62e53ee..0659665 100644 --- a/api/app/domain/models/scheduled_appointments.py +++ b/api/app/domain/models/scheduled_appointments.py @@ -13,9 +13,9 @@ class ScheduledAppointment(BaseModel): scheduled_datetime = Column(DateTime, nullable=False, server_default=func.now()) is_canceled = Column(Boolean, nullable=False, default=False, server_default='false') - patient_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.patients.id'), nullable=False) - doctor_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.users.id'), nullable=False) - type_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.appointment_types.id'), nullable=False) + patient_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.patients.id', ondelete='CASCADE'), nullable=False) + doctor_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.users.id', ondelete='SET NULL'), nullable=True) + type_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.appointment_types.id', ondelete='CASCADE'), nullable=False) patient = relationship('Patient', back_populates='scheduled_appointments') doctor = relationship('User', back_populates='scheduled_appointments') diff --git a/api/app/domain/models/sessions.py b/api/app/domain/models/sessions.py index c470251..1dde44f 100644 --- a/api/app/domain/models/sessions.py +++ b/api/app/domain/models/sessions.py @@ -15,6 +15,6 @@ class Session(BaseModel): expires_at = Column(DateTime, nullable=False) is_active = Column(Boolean, default=True, nullable=False) - user_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.users.id'), nullable=False) + user_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.users.id', ondelete='SET NULL'), nullable=True) user = relationship("User", back_populates="sessions") diff --git a/api/app/domain/models/set_contents.py b/api/app/domain/models/set_contents.py index 6bee858..f38221f 100644 --- a/api/app/domain/models/set_contents.py +++ b/api/app/domain/models/set_contents.py @@ -20,8 +20,8 @@ class SetContent(BaseModel): side = Column(Enum(SideEnum), nullable=False) count = Column(Integer, nullable=False) - type_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.lens_types.id'), nullable=False) - set_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.sets.id'), nullable=False) + type_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.lens_types.id', ondelete='CASCADE'), nullable=False) + set_id = Column(Integer, ForeignKey(f'{settings.SCHEMA}.sets.id', ondelete='CASCADE'), nullable=False) type = relationship('LensType', back_populates='contents') set = relationship('Set', back_populates='contents') diff --git a/web-app/src/Api/patientsApi.js b/web-app/src/Api/patientsApi.js index 3a88710..20340bc 100644 --- a/web-app/src/Api/patientsApi.js +++ b/web-app/src/Api/patientsApi.js @@ -7,7 +7,7 @@ export const patientsApi = createApi({ tagTypes: ['Patient'], endpoints: (builder) => ({ getPatients: builder.query({ - query: ({ page, pageSize, search, sortOrder }) => ({ + query: ({page, pageSize, search, sortOrder}) => ({ url: '/patients/', params: { page, @@ -21,7 +21,7 @@ export const patientsApi = createApi({ getAllPatients: builder.query({ query: () => ({ url: '/patients/', - params: { all_params: true }, + params: {all_params: true}, }), providesTags: ['Patients'], transformResponse: (response) => { @@ -55,6 +55,12 @@ export const patientsApi = createApi({ }), invalidatesTags: ['Patients'] }), + getPatientsWithEmail: builder.query({ + query: () => ({ + url: `/patients/email/`, + }), + providesTags: ['Patients'], + }), }), }); @@ -64,4 +70,5 @@ export const { useAddPatientMutation, useUpdatePatientMutation, useDeletePatientMutation, + useGetPatientsWithEmailQuery, } = patientsApi; \ No newline at end of file diff --git a/web-app/src/App/AppRouter.jsx b/web-app/src/App/AppRouter.jsx index 8bef81c..3ba929d 100644 --- a/web-app/src/App/AppRouter.jsx +++ b/web-app/src/App/AppRouter.jsx @@ -10,6 +10,7 @@ import AppointmentsPage from "../Components/Pages/AppointmentsPage/AppointmentsP import ProfilePage from "../Components/Pages/ProfilePage/ProfilePage.jsx"; import AdminRoute from "./AdminRoute.jsx"; import AdminPage from "../Components/Pages/AdminPage/AdminPage.jsx"; +import MailingPage from "../Components/Pages/MailingPage/MailingPage.jsx"; const AppRouter = () => ( @@ -23,6 +24,7 @@ const AppRouter = () => ( }/> }/> }/> + }/> }/>