Changeset 6729ba5
- Timestamp:
- 01/15/21 16:39:45 (4 years ago)
- Branches:
- master
- Children:
- 81c9e25
- Parents:
- ed3f5c4
- Files:
-
- 6 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
client_app/src/components/item_components/internship_component.js
red3f5c4 r6729ba5 1 1 import React from 'react'; 2 2 import {Header, List, Segment, Button} from 'semantic-ui-react'; 3 import {Link} from "react-router-dom"; 3 4 4 5 const Internships = (props) => { … … 6 7 <Segment> 7 8 <Header as="h3">{props.item.title}</Header> 8 {props.item.type!=="USER" ? <Button primary>Edit</Button> : <span> </span>} 9 {props.item.type!=="USER" ? <Button primary as={Link} to={{ 10 pathname: "/edit/internship", 11 state: { 12 index: props.index, 13 item: props.item 14 } 15 }}>Edit</Button> : <span> </span>} 9 16 <Segment>{props.item.description}</Segment> 10 17 <Segment> -
client_app/src/components/item_components/job_component.js
red3f5c4 r6729ba5 7 7 <Segment> 8 8 <Header as="h3">{props.item.title}</Header> 9 {props.item. type!=="USER" ? <Button primary as={Link} to={{9 {props.item.accountType!=="USER" ? <Button primary as={Link} to={{ 10 10 pathname: "/edit/job", 11 11 state: { 12 jobId: props.item.id, 13 accId: props.item.accId, 14 type: props.item.type 12 index: props.index, 13 item: props.item 15 14 } 16 15 }}>Edit</Button> : <span> </span>} -
client_app/src/components/item_components/project_component.js
red3f5c4 r6729ba5 1 1 import React from 'react'; 2 2 import {Header, List, Segment, Button} from 'semantic-ui-react'; 3 import {Link} from "react-router-dom"; 3 4 4 5 const Projects = (props) => { … … 7 8 <Segment> 8 9 <Header as="h3">{props.item.title}</Header> 9 {props.item.type!=="USER" ? <Button primary>Edit</Button> : <span> </span>} 10 {props.item.type!=="USER" ? <Button primary as={Link} to={{ 11 pathname: "/edit/project", 12 state: { 13 index: props.index, 14 item: props.item 15 } 16 }}>Edit</Button> : <span> </span>} 10 17 <Segment>{props.item.description}</Segment> 11 18 <Segment> -
client_app/src/components/main/App.js
red3f5c4 r6729ba5 24 24 import InternshipRegister from "../work_register/internship_register"; 25 25 import ProjectRegister from "../work_register/project_register"; 26 import EditJob from "../work_edit/test"; 26 import EditJob from "../work_edit/edit_job"; 27 import EditInternship from "../work_edit/edit_internship"; 28 import EditProject from "../work_edit/edit_project"; 27 29 28 30 class App extends Component{ … … 63 65 <Route path={"/register/project"} render={() => <ProjectRegister accountId={this.state.currentUser.id} type={this.state.currentUser.type} updateProjects={this.updateProjects} />}/> 64 66 <Route path={"/edit/job"} render={(props) => <EditJob {...props} editJob={this.editJob}/>} /> 65 {/*<Route path={"/edit/internship"} render={(props) => <EditInternship {...props} editJob={this.editInternship}/>} />*/}66 {/*<Route path={"/edit/project"} render={(props) => <EditProject {...props} editJob={this.editProject}/>} />*/}67 <Route path={"/edit/internship"} render={(props) => <EditInternship {...props} editInternship={this.editInternship}/>} /> 68 <Route path={"/edit/project"} render={(props) => <EditProject {...props} editProject={this.editProject}/>} /> 67 69 <Route path={"/logout"} render={() => <Redirect to={"/login"}/>}/> 68 70 <Route path={"/"} render={() => <Redirect to={"/login"}/>}/> … … 121 123 122 124 editJob = (job, index) => { 125 let jobs = this.state.currentUser.jobs; 126 jobs[index] = job; 127 123 128 this.setState(prevState => ({ 124 129 currentUser:{ 125 130 ...prevState.currentUser, 126 jobs: Object.assign([],this.state.jobs,{[index]: job})131 jobs: jobs 127 132 } 128 133 })) … … 130 135 131 136 editInternship = (internship, index) => { 137 let interns = this.state.currentUser.internships; 138 interns[index] = internship; 139 132 140 this.setState(prevState => ({ 133 141 currentUser:{ 134 142 ...prevState.currentUser, 135 internships: Object.assign([],this.state.jobs,{[index]: internship})143 internships: interns 136 144 } 137 145 })) … … 139 147 140 148 editProject = (project, index) => { 149 let proj = this.state.currentUser.projects; 150 proj[index] = project; 151 141 152 this.setState(prevState => ({ 142 153 currentUser:{ 143 154 ...prevState.currentUser, 144 projects: Object.assign([],this.state.jobs,{[index]: project})155 projects: proj 145 156 } 146 157 })) -
src/main/java/it/finki/tinki/model/dto/response/work/WorkResponseDTO.java
red3f5c4 r6729ba5 13 13 String accountEmail; 14 14 String accountName; 15 Long accountId; 15 16 AccountType accountType; 16 17 String error; … … 28 29 this.description = description; 29 30 this.salary = salary; 31 this.accountId = account.getId(); 30 32 this.accountEmail = account.getEmail(); 31 33 this.accountName = account.getName(); -
src/main/java/it/finki/tinki/service/impl/WorkServiceImpl.java
red3f5c4 r6729ba5 131 131 j.setDescription(description); 132 132 j.setSalary(salary); 133 j.setOpenSpots(openSpots); 133 134 134 135 return this.internshipRepository.save(j); -
src/main/java/it/finki/tinki/web/controller/WorkEditController.java
red3f5c4 r6729ba5 4 4 import it.finki.tinki.model.Work.Job; 5 5 import it.finki.tinki.model.Work.Project; 6 import it.finki.tinki.model.dto.edit.work.InternshipEditDTO; 7 import it.finki.tinki.model.dto.edit.work.WorkEditDTO; 6 8 import it.finki.tinki.model.dto.register.work.InternshipRegisterDTO; 7 9 import it.finki.tinki.model.dto.register.work.JobRegisterDTO; … … 29 31 30 32 @PostMapping("/job/{id}") 31 public Map<String, String>editJob(@PathVariable Long id,32 @RequestBody JobRegisterDTO body){33 public JobResponseDTO editJob(@PathVariable Long id, 34 @RequestBody WorkEditDTO body){ 33 35 34 Map<String, String> response = new HashMap<>();36 Job j = this.workService.getJobById(id); 35 37 36 if(body.getAccountId().equals( this.workService.getJobById(id).getAccount().getId())) {38 if(body.getAccountId().equals(j.getAccount().getId())) { 37 39 Job k = this.workService.editJob(id, body.getTitle(), body.getDescription(), body.getSalary()); 38 40 if(k!=null){ 39 response.put("success", "Job edited successfully!"); 40 return response; 41 return new JobResponseDTO(k); 41 42 } 42 43 } 43 44 44 response.put("error", "Internship edit failed!"); 45 return response; 45 return new JobResponseDTO(); 46 46 } 47 47 48 48 @PostMapping("/internship/{id}") 49 public Map<String, String>editInternship(@PathVariable Long id,50 @RequestBody Internship RegisterDTO body){49 public InternshipResponseDTO editInternship(@PathVariable Long id, 50 @RequestBody InternshipEditDTO body){ 51 51 52 Map<String, String> response = new HashMap<>();52 Internship i = this.workService.getInternshipById(id); 53 53 54 if(body.getAccountId().equals( this.workService.getInternshipById(id).getAccount().getId())){54 if(body.getAccountId().equals(i.getAccount().getId())){ 55 55 Internship k = this.workService.editInternship(id, body.getTitle(), body.getDescription(), body.getSalary(), body.getOpenSpots()); 56 56 if(k!=null){ 57 response.put("success", "Internship edited successfully!"); 58 return response; 57 return new InternshipResponseDTO(k); 59 58 } 60 59 } 61 60 62 response.put("error", "Internship edit failed!"); 63 return response; 61 return new InternshipResponseDTO(); 64 62 } 65 63 66 64 @PostMapping("/project/{id}") 67 public Map<String, String>editProject(@PathVariable Long id,68 @RequestBody ProjectRegisterDTO body){65 public ProjectResponseDTO editProject(@PathVariable Long id, 66 @RequestBody WorkEditDTO body){ 69 67 70 Map<String, String> response = new HashMap<>();68 Project p = this.workService.getProjectById(id); 71 69 72 if(body.getAccountId().equals( this.workService.getProjectById(id).getAccount().getId())) {70 if(body.getAccountId().equals(p.getAccount().getId())) { 73 71 Project k = this.workService.editProject(id, body.getTitle(), body.getDescription(), body.getSalary()); 74 72 if(k!=null){ 75 response.put("success", "Project edited successfully!"); 76 return response; 73 return new ProjectResponseDTO(k); 77 74 } 78 75 } 79 76 80 response.put("error", "Project edit failed!"); 81 return response; 77 return new ProjectResponseDTO(); 82 78 } 83 79 }
Note:
See TracChangeset
for help on using the changeset viewer.