Skip to content

Commit

Permalink
add exoport service interface
Browse files Browse the repository at this point in the history
  • Loading branch information
cankurttekin committed Nov 12, 2024
1 parent ff4c933 commit bac1ae7
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.kurttekin.can.job_track.application.service;

import com.kurttekin.can.job_track.domain.model.jobapplication.JobApplication;
import com.kurttekin.can.job_track.domain.service.ExportService;
import org.apache.commons.csv.CSVFormat;
import org.springframework.stereotype.Service;
import org.apache.commons.csv.CSVPrinter;
Expand All @@ -10,7 +11,8 @@
import java.util.List;

@Service
public class ExportService {
public class ExportServiceImpl implements ExportService {
@Override
public String exportToCSV(List<JobApplication> applications) throws IOException {
StringWriter writer = new StringWriter();
try (CSVPrinter csvPrinter = new CSVPrinter(writer, CSVFormat.DEFAULT.withHeader("Company", "Job Title", "Status", "Application Date", "Response Date", "Platform", "Url", "Description", "Comments"))) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.kurttekin.can.job_track.domain.service;

import com.kurttekin.can.job_track.domain.model.jobapplication.JobApplication;

import java.io.IOException;
import java.util.List;

public interface ExportService {
String exportToCSV(List<JobApplication> applications) throws IOException;
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
package com.kurttekin.can.job_track.presentation.rest;

import com.kurttekin.can.job_track.application.service.ExportService;
import com.kurttekin.can.job_track.application.service.ExportServiceImpl;
import com.kurttekin.can.job_track.domain.model.jobapplication.JobApplication;
import com.kurttekin.can.job_track.domain.model.user.User;
import com.kurttekin.can.job_track.domain.service.ExportService;
import com.kurttekin.can.job_track.domain.service.JobApplicationService;
import com.kurttekin.can.job_track.domain.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
Expand All @@ -24,7 +25,7 @@ public class ExportController {
@Autowired
private UserService userService;

public ExportController(ExportService exportService, JobApplicationService jobApplicationService) {
public ExportController(ExportServiceImpl exportService, JobApplicationService jobApplicationService) {
this.exportService = exportService;
this.jobApplicationService = jobApplicationService;
}
Expand Down
8 changes: 4 additions & 4 deletions frontend/src/components/ExportData.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const Container = styled.div`
display: flex;
flex-direction: column;
align-items: center;
margin-top: 50px;
margin: 20px auto;
`;

const Title = styled.h2`
Expand Down Expand Up @@ -55,10 +55,10 @@ const ExportData = () => {
<Container>
<Title>Export Your Data</Title>
<p>Choose the format you would like to export your data:</p>
<FormatButton onClick={() => handleExport('csv')}>Export as CSV</FormatButton>
<FormatButton onClick={() => handleExport('csv')}>CSV</FormatButton>
Will be implemented:
<FormatButton onClick={() => handleExport('pdf')}>Export as PDF</FormatButton>
<FormatButton onClick={() => handleExport('json')}>Export as JSON</FormatButton>
<FormatButton onClick={() => handleExport('pdf')}>PDF</FormatButton>
<FormatButton onClick={() => handleExport('json')}>JSON</FormatButton>
{error && <p style={{ color: 'red' }}>{error}</p>}
</Container>
);
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/components/Sidebar.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const NavbarItems = styled.div`
left: 0;
right: 0;
background-color: white;
padding: 10px 0;
padding: 10px 10px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
z-index: 1001;
}
Expand Down Expand Up @@ -96,7 +96,7 @@ const AppName = styled.div`
align-items: center;
cursor: pointer;
margin-right: 20px;
margin-left: 10px;
margin-left: 2px;
`;

const Navbar = () => {
Expand Down

0 comments on commit bac1ae7

Please sign in to comment.