Skip to content

Commit eb668bb

Browse files
author
GitHub Copilot
committed
feat: integrate phone campaign feature
- Update client/shared and server/shared submodules to include phone campaign - Add phone_template and phone_campaign resources to App.jsx (isPhoneCampaign guard) - Add YemotSettingsInput to Settings.jsx - Register phoneTemplateConfig and phoneCampaignConfig in entities.module.ts - Add migration 1780185600000-AddPhoneCampaign for phone_templates and phone_campaigns tables
1 parent 4532afc commit eb668bb

6 files changed

Lines changed: 70 additions & 3 deletions

File tree

‎client/src/App.jsx‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ import teacher from 'src/entities/teacher';
3232
import transportation from 'src/entities/transportation';
3333
import absenceType from 'src/entities/absenceType';
3434
import uploadedFile from '@shared/components/common-entities/uploaded-file';
35+
import phoneCampaign from '@shared/components/common-entities/phone-campaign';
36+
import phoneTemplate from '@shared/components/common-entities/phone-template';
3537
import studentKlassesReport from 'src/entities/student-klasses-report';
3638
import StudentEventReport from 'src/components/StudentView/student-event-report';
3739
import reportMonth from 'src/entities/report-month';
@@ -50,7 +52,7 @@ import StudentAttendanceList from 'src/pivots/StudentAttendanceList';
5052
import StudentAttendanceByKlassList from 'src/pivots/StudentAttendanceByKlassList';
5153
import PercentReportWithDatesList from 'src/pivots/PercentReportWithDatesList';
5254

53-
import { isUploadedFiles, isAdmin } from '@shared/utils/permissionsUtil';
55+
import { isUploadedFiles, isAdmin, isPhoneCampaign } from '@shared/utils/permissionsUtil';
5456
import {
5557
isLessonSignature,
5658
isOnlyInLessonReport,
@@ -81,6 +83,7 @@ import DateRangeIcon from '@mui/icons-material/DateRange';
8183
import LabelIcon from '@mui/icons-material/Label';
8284
import CalculateIcon from '@mui/icons-material/Calculate';
8385
import UploadFileIcon from '@mui/icons-material/UploadFile';
86+
import PhoneIcon from '@mui/icons-material/Phone';
8487
import PermContactCalendarIcon from '@mui/icons-material/PermContactCalendar';
8588
import LocalAtmIcon from '@mui/icons-material/LocalAtm';
8689
import AdminPanelSettingsIcon from '@mui/icons-material/AdminPanelSettings';
@@ -242,6 +245,12 @@ const App = () => (
242245
icon={UploadFileIcon}
243246
/>
244247
)}
248+
{isPhoneCampaign(permissions) && (
249+
<>
250+
<Resource name="phone_template" {...phoneTemplate} options={{ menuGroup: 'phone' }} icon={PhoneIcon} />
251+
<Resource name="phone_campaign" {...phoneCampaign} options={{ menuGroup: 'phone' }} icon={PhoneIcon} />
252+
</>
253+
)}
245254
<Resource
246255
name="att_report"
247256
{...attReport}

‎client/src/settings/Settings.jsx‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { DashboardItemsInput } from './DashboardItemsInput';
1818
import { ReportStylesInput } from './ReportStylesInput';
1919
import { GeneralSettingsInput } from './GeneralSettingsInput';
2020
import { ReportCardSettingsInput } from './ReportCardSettingsInput';
21+
import { YemotSettingsInput } from '@shared/components/phone/YemotSettingsInput';
2122

2223
const SettingsToolbar = () => (
2324
<Toolbar>
@@ -62,6 +63,7 @@ export default function Settings() {
6263
<DashboardItemsInput />
6364
<ReportStylesInput />
6465
<ReportCardSettingsInput />
66+
<YemotSettingsInput />
6567
</SimpleForm>
6668
</ResourceContextProvider>
6769
</CardContent>

‎server/src/entities.module.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ import reportGroupSessionConfig from './entity-modules/report-group-session.conf
3636
import transportationConfig from './entity-modules/transportation.config';
3737
import absenceTypeConfig from './entity-modules/absenceType.config';
3838
import uploadedFileConfig from '@shared/entities/configs/uploaded-file.config';
39+
import phoneTemplateConfig from '@shared/entities/configs/phone-template.config';
40+
import phoneCampaignConfig from '@shared/entities/configs/phone-campaign.config';
3941
import { Student } from './db/entities/Student.entity';
4042
import { Teacher } from './db/entities/Teacher.entity';
4143
import userConfig from '@shared/entities/configs/user.config';
@@ -90,6 +92,8 @@ registerEntityNameMap({
9092
BaseEntityModule.register(transportationConfig),
9193
BaseEntityModule.register(absenceTypeConfig),
9294
BaseEntityModule.register(uploadedFileConfig),
95+
BaseEntityModule.register(phoneTemplateConfig),
96+
BaseEntityModule.register(phoneCampaignConfig),
9397
],
9498
})
9599
export class EntitiesModule {}
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
2+
3+
export class AddPhoneCampaign1780185600000 implements MigrationInterface {
4+
name = 'AddPhoneCampaign1780185600000';
5+
6+
public async up(queryRunner: QueryRunner): Promise<void> {
7+
await queryRunner.query(`
8+
CREATE TABLE \`phone_templates\` (
9+
\`id\` int NOT NULL AUTO_INCREMENT,
10+
\`user_id\` int NOT NULL,
11+
\`name\` varchar(100) NOT NULL,
12+
\`description\` varchar(500) NULL,
13+
\`yemot_template_id\` varchar(255) NULL,
14+
\`message_type\` varchar(50) NOT NULL DEFAULT 'text',
15+
\`message_text\` text NOT NULL,
16+
\`is_active\` tinyint NOT NULL DEFAULT 1,
17+
\`caller_id\` varchar(20) NULL,
18+
\`settings\` text NULL,
19+
\`created_at\` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
20+
\`updated_at\` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
21+
INDEX \`phone_template_user_id_idx\` (\`user_id\`),
22+
PRIMARY KEY (\`id\`)
23+
) ENGINE=InnoDB
24+
`);
25+
await queryRunner.query(`
26+
CREATE TABLE \`phone_campaigns\` (
27+
\`id\` int NOT NULL AUTO_INCREMENT,
28+
\`user_id\` int NOT NULL,
29+
\`phone_template_id\` int NOT NULL,
30+
\`yemot_campaign_id\` varchar(255) NULL,
31+
\`status\` varchar(50) NOT NULL DEFAULT 'pending',
32+
\`total_phones\` int NOT NULL DEFAULT 0,
33+
\`successful_calls\` int NOT NULL DEFAULT 0,
34+
\`failed_calls\` int NOT NULL DEFAULT 0,
35+
\`phone_numbers\` text NOT NULL,
36+
\`error_message\` text NULL,
37+
\`completed_at\` datetime NULL,
38+
\`created_at\` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6),
39+
\`updated_at\` timestamp(6) NOT NULL DEFAULT CURRENT_TIMESTAMP(6) ON UPDATE CURRENT_TIMESTAMP(6),
40+
INDEX \`phone_campaign_user_id_idx\` (\`user_id\`),
41+
INDEX \`phone_campaign_template_id_idx\` (\`phone_template_id\`),
42+
INDEX \`phone_campaign_status_idx\` (\`status\`),
43+
PRIMARY KEY (\`id\`)
44+
) ENGINE=InnoDB
45+
`);
46+
}
47+
48+
public async down(queryRunner: QueryRunner): Promise<void> {
49+
await queryRunner.query(`DROP TABLE \`phone_campaigns\``);
50+
await queryRunner.query(`DROP TABLE \`phone_templates\``);
51+
}
52+
}

0 commit comments

Comments
 (0)