Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/backend/docker-compose-db.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ services:
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
POSTGRES_DB: ${POSTGRES_DB}
ports:
- '5432:5432'
- '${POSTGRES_PORT}:5432'
volumes:
- postgres_data:/var/lib/postgresql/data

Expand Down
4 changes: 2 additions & 2 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"@nestjs/passport": "^10.0.3",
"@nestjs/platform-express": "^10.4.15",
"@nestjs/swagger": "^8.1.1",
"@prisma/client": "^6.2.1",
"@prisma/client": "^6.5.0",
"@radix-ui/react-dialog": "^1.1.4",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
Expand All @@ -49,7 +49,7 @@
"eslint": "^9.18.0",
"eslint-config-nestjs": "^0.8.0",
"eslint-plugin-simple-import-sort": "^12.1.1",
"prisma": "^6.2.1",
"prisma": "^6.5.0",
"source-map-support": "^0.5.21",
"ts-loader": "^9.5.2",
"ts-node": "^10.9.2",
Expand Down
23 changes: 15 additions & 8 deletions apps/frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"license": "MIT",
"private": true,
"scripts": {
"dev": "NODE_OPTIONS='--inspect' next dev --turbo",
"dev": "NODE_OPTIONS='--inspect' next dev --turbopack",
"build": "next build",
"start": "next start",
"lint": "next lint"
Expand Down Expand Up @@ -49,15 +49,16 @@
"clsx": "^2.1.1",
"cmdk": "1.0.4",
"date-fns": "^4.1.0",
"file-saver": "^2.0.5",
"hamburger-react": "^2.5.2",
"input-otp": "^1.4.2",
"js-cookie": "^3.0.5",
"jsonwebtoken": "^9.0.2",
"lucide-react": "^0.471.1",
"next": "^15.1.4",
"react": "^19.0.0",
"next": "15.2.2",
"react": "19.0.0",
"react-day-picker": "8.10.1",
"react-dom": "^19.0.0",
"react-dom": "19.0.0",
"react-easy-crop": "^5.2.0",
"react-hook-form": "^7.54.2",
"react-icons": "^5.4.0",
Expand All @@ -66,20 +67,26 @@
"table": "^6.9.0",
"tailwind-merge": "^2.6.0",
"tailwindcss-animate": "^1.0.7",
"xlsx": "^0.18.5",
"zod": "^3.24.1"
},
"devDependencies": {
"@next/eslint-plugin-next": "^15.1.4",
"@next/eslint-plugin-next": "15.2.2",
"@types/file-saver": "^2",
"@types/js-cookie": "^3.0.6",
"@types/node": "^20.17.12",
"@types/react": "^19.0.6",
"@types/react-dom": "^19.0.3",
"eslint-config-next": "^15.1.4",
"@types/react": "19.0.10",
"@types/react-dom": "19.0.4",
"eslint-config-next": "15.2.2",
"eslint-config-prettier": "^10.0.1",
"eslint-plugin-prettier": "5.2.1",
"eslint-plugin-simple-import-sort": "^12.1.1",
"postcss": "^8.5.0",
"tailwindcss": "^3.4.17",
"typescript": "^5.7.3"
},
"resolutions": {
"@types/react": "19.0.10",
"@types/react-dom": "19.0.4"
}
}
11 changes: 11 additions & 0 deletions apps/frontend/src/app/periods/[id]/data-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ interface DataTableProps<TData, TValue> {
onExportPassesClicked: (data: TData[]) => void;
onExportApplicationsClicked: (data: TData[]) => void;
onSetToManufactured: (data: TData[]) => void;
onExportToExcelClicked: (data: TData[]) => void;
}

export function DataTable<TData, TValue>({
Expand All @@ -60,6 +61,7 @@ export function DataTable<TData, TValue>({
onExportApplicationsClicked,
onExportPassesClicked,
onSetToManufactured,
onExportToExcelClicked,
}: DataTableProps<TData, TValue>) {
const [sorting, setSorting] = React.useState<SortingState>([
{
Expand Down Expand Up @@ -205,6 +207,15 @@ export function DataTable<TData, TValue>({
>
Nem kollégisták exportálása (csak kiosztott)
</MenubarItem>
<MenubarItem
onClick={() => {
onExportToExcelClicked(
data.filter((a) => (a as ApplicationEntity).status === ('DISTRIBUTED' as ApplicationStatus))
);
}}
>
Minden kiosztott jelentkezés exportálása Excel file-ba
</MenubarItem>
</MenubarContent>
</MenubarMenu>
<MenubarMenu>
Expand Down
27 changes: 27 additions & 0 deletions apps/frontend/src/app/periods/[id]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import { getStatusKey } from '@/lib/status';
import { toast } from '@/lib/use-toast';
import { ApplicationEntity, ApplicationStatus } from '@/types/application-entity';

import { generateXlsx } from '@/lib/xlsx';
import { saveAs } from 'file-saver';
import { ApplicationExport } from './application-export';
import { PassExport } from './pass-export';

Expand Down Expand Up @@ -187,6 +189,30 @@ export default function Page(props: { params: Promise<{ id: number }> }) {
}
};

/**
* Handles the export of applications to an Excel file.
* This function exports the selected applications which have the status {@link ApplicationStatus.DISTRIBUTED}
* to an Excel file.
*/
const onExportToExcel = async (data: ApplicationEntity[]) => {
const distributedApplications = data.filter((a) => a.status === getStatusKey(ApplicationStatus.DISTRIBUTED));

type ExcelData = {
'Teljes név': string;
'NEPTUN kód': string;
'SZIG szám': string;
};

const dataToExport: ExcelData[] = distributedApplications.map((a) => ({
'Teljes név': a.user.fullName,
'NEPTUN kód': a.user.neptun ?? '-',
'SZIG szám': a.user.idNumber ?? '-',
}));

const excelFile = generateXlsx(dataToExport, 'schbody_applications_export');
saveAs(excelFile, 'schbody_applications_export.xlsx');
};

if (period?.error) return <div>Hiba történt: {period?.error.message}</div>;

return (
Expand Down Expand Up @@ -251,6 +277,7 @@ export default function Page(props: { params: Promise<{ id: number }> }) {
onExportPassesClicked={onPassExport}
onExportApplicationsClicked={onApplicationsExport}
onSetToManufactured={onSetToManufactured}
onExportToExcelClicked={onExportToExcel}
/>
)}
</div>
Expand Down
21 changes: 21 additions & 0 deletions apps/frontend/src/lib/xlsx.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use client';

import { utils, write } from 'xlsx';

/**
* Generates an XLSX file from the provided data and returns it as a Blob.
*
* @param data - An array of objects representing the data to be included in the XLSX file.
* @param fileName - The name of the file (without extension) to be used for the worksheet.
* @returns A Blob representing the generated XLSX file.
*/
export function generateXlsx(data: any[], fileName: string): Blob {
console.log('Data being exported to and excel file: ');
console.table(data);
const worksheet = utils.json_to_sheet(data);
const workbook = utils.book_new();
utils.book_append_sheet(workbook, worksheet, fileName);

const excelBuffer = write(workbook, { bookType: 'xlsx', type: 'array' });
return new Blob([excelBuffer], { type: 'application/octet-stream' });
}
Loading