Changeset 6729ba5 for client_app/src


Ignore:
Timestamp:
01/15/21 16:39:45 (4 years ago)
Author:
Vzdra <vladko.zdravkovski@…>
Branches:
master
Children:
81c9e25
Parents:
ed3f5c4
Message:

finished work edit

Location:
client_app/src
Files:
4 added
4 edited

Legend:

Unmodified
Added
Removed
  • client_app/src/components/item_components/internship_component.js

    red3f5c4 r6729ba5  
    11import React from 'react';
    22import {Header, List, Segment, Button} from 'semantic-ui-react';
     3import {Link} from "react-router-dom";
    34
    45const Internships = (props) => {
     
    67        <Segment>
    78            <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>}
    916            <Segment>{props.item.description}</Segment>
    1017            <Segment>
  • client_app/src/components/item_components/job_component.js

    red3f5c4 r6729ba5  
    77        <Segment>
    88            <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={{
    1010                pathname: "/edit/job",
    1111                state: {
    12                     jobId: props.item.id,
    13                     accId: props.item.accId,
    14                     type: props.item.type
     12                    index: props.index,
     13                    item: props.item
    1514                }
    1615            }}>Edit</Button> : <span> </span>}
  • client_app/src/components/item_components/project_component.js

    red3f5c4 r6729ba5  
    11import React from 'react';
    22import {Header, List, Segment, Button} from 'semantic-ui-react';
     3import {Link} from "react-router-dom";
    34
    45const Projects = (props) => {
     
    78        <Segment>
    89            <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>}
    1017            <Segment>{props.item.description}</Segment>
    1118            <Segment>
  • client_app/src/components/main/App.js

    red3f5c4 r6729ba5  
    2424import InternshipRegister from "../work_register/internship_register";
    2525import ProjectRegister from "../work_register/project_register";
    26 import EditJob from "../work_edit/test";
     26import EditJob from "../work_edit/edit_job";
     27import EditInternship from "../work_edit/edit_internship";
     28import EditProject from "../work_edit/edit_project";
    2729
    2830class App extends Component{
     
    6365                      <Route path={"/register/project"} render={() => <ProjectRegister accountId={this.state.currentUser.id} type={this.state.currentUser.type} updateProjects={this.updateProjects} />}/>
    6466                      <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}/>} />
    6769                      <Route path={"/logout"} render={() => <Redirect to={"/login"}/>}/>
    6870                      <Route path={"/"} render={() => <Redirect to={"/login"}/>}/>
     
    121123
    122124    editJob = (job, index) => {
     125      let jobs = this.state.currentUser.jobs;
     126      jobs[index] = job;
     127
    123128      this.setState(prevState => ({
    124129          currentUser:{
    125130              ...prevState.currentUser,
    126               jobs: Object.assign([],this.state.jobs,{[index]: job})
     131              jobs: jobs
    127132          }
    128133      }))
     
    130135
    131136    editInternship = (internship, index) => {
     137        let interns = this.state.currentUser.internships;
     138        interns[index] = internship;
     139
    132140        this.setState(prevState => ({
    133141            currentUser:{
    134142                ...prevState.currentUser,
    135                 internships: Object.assign([],this.state.jobs,{[index]: internship})
     143                internships: interns
    136144            }
    137145        }))
     
    139147
    140148    editProject = (project, index) => {
     149        let proj = this.state.currentUser.projects;
     150        proj[index] = project;
     151
    141152        this.setState(prevState => ({
    142153            currentUser:{
    143154                ...prevState.currentUser,
    144                 projects: Object.assign([],this.state.jobs,{[index]: project})
     155                projects: proj
    145156            }
    146157        }))
Note: See TracChangeset for help on using the changeset viewer.