build_app
This commit is contained in:
		
							parent
							
								
									fdd158290f
								
							
						
					
					
						commit
						8a785e8cf1
					
				| @ -69,6 +69,12 @@ public class BuilderService { | |||||||
| 		executeDump(true); | 		executeDump(true); | ||||||
| 
 | 
 | ||||||
| 		// ADD OTHER SERVICE | 		// ADD OTHER SERVICE | ||||||
|  | addCustomMenu( "Child","Child",  "Transcations");  | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | addCustomMenu( "Test_a","Test_a",  "Transcations");  | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| 		System.out.println("dashboard and menu inserted..."); | 		System.out.println("dashboard and menu inserted..."); | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -0,0 +1,91 @@ | |||||||
|  | package com.realnet.basic1.Controllers; | ||||||
|  | import java.util.List; | ||||||
|  | import org.springframework.beans.factory.annotation.Autowired; | ||||||
|  |  import org.springframework.web.bind.annotation.*; | ||||||
|  | import org.springframework.web.multipart.MultipartFile; | ||||||
|  | import com.fasterxml.jackson.core.JsonProcessingException; | ||||||
|  | import org.springframework.web.bind.annotation.CrossOrigin; | ||||||
|  | import com.fasterxml.jackson.databind.JsonMappingException; | ||||||
|  | import com.realnet.config.EmailService; | ||||||
|  | import com.realnet.users.entity1.AppUser; | ||||||
|  | import com.realnet.users.service1.AppUserServiceImpl; | ||||||
|  | import com.fasterxml.jackson.databind.ObjectMapper; | ||||||
|  | import org.springframework.data.domain.*; | ||||||
|  | import com.realnet.fnd.response.EntityResponse; | ||||||
|  | import org.springframework.http.*; | ||||||
|  | import org.springframework.beans.factory.annotation.*; | ||||||
|  | import com.realnet.basic1.Entity.Child; | ||||||
|  | import com.realnet.basic1.Services.ChildService ; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @RequestMapping(value = "/Child") | ||||||
|  |  @CrossOrigin("*")  | ||||||
|  | @RestController | ||||||
|  | public class ChildController { | ||||||
|  | 	@Autowired | ||||||
|  | 	private ChildService Service; | ||||||
|  | 
 | ||||||
|  | @Value("${projectPath}") | ||||||
|  | 	private String projectPath; | ||||||
|  |   | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	@PostMapping("/Child") | ||||||
|  | 		  public Child Savedata(@RequestBody Child data) { | ||||||
|  | 		Child save = Service.Savedata(data)	; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 		System.out.println("data saved..." + save); | ||||||
|  | 
 | ||||||
|  |  return save; | ||||||
|  | 	  } | ||||||
|  | @PutMapping("/Child/{id}") | ||||||
|  | 	public  Child update(@RequestBody Child data,@PathVariable Integer id ) { | ||||||
|  | 		Child update = Service.update(data,id); | ||||||
|  | 		System.out.println("data update..." + update); | ||||||
|  | 		return update; | ||||||
|  | 	}	  | ||||||
|  | //	get all with pagination | ||||||
|  | 	@GetMapping("/Child/getall/page") | ||||||
|  | 	public Page<Child> getall(@RequestParam(value = "page", required = false) Integer page, | ||||||
|  | 			@RequestParam(value = "size", required = false) Integer size) { | ||||||
|  | 		Pageable paging = PageRequest.of(page, size); | ||||||
|  | 		Page<Child> get = Service.getAllWithPagination(paging); | ||||||
|  | 
 | ||||||
|  | 		return get; | ||||||
|  | 
 | ||||||
|  | 	}	 | ||||||
|  | 	@GetMapping("/Child") | ||||||
|  | 	public List<Child> getdetails() { | ||||||
|  | 		 List<Child> get = Service.getdetails();		 | ||||||
|  | 		return get; | ||||||
|  | } | ||||||
|  | // get all without authentication  | ||||||
|  | 
 | ||||||
|  | 	@GetMapping("/token/Child") | ||||||
|  | 	public List<Child> getallwioutsec() { | ||||||
|  | 		 List<Child> get = Service.getdetails();		 | ||||||
|  | 		return get; | ||||||
|  | } | ||||||
|  | @GetMapping("/Child/{id}") | ||||||
|  | 	public  Child  getdetailsbyId(@PathVariable Integer id ) { | ||||||
|  | 		Child  get = Service.getdetailsbyId(id); | ||||||
|  | 		return get; | ||||||
|  | 	} | ||||||
|  | @DeleteMapping("/Child/{id}") | ||||||
|  | 	public  ResponseEntity<?> delete_by_id(@PathVariable Integer id ) { | ||||||
|  | 	Service.delete_by_id(id); | ||||||
|  | 			return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK); | ||||||
|  | 	 | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,99 @@ | |||||||
|  | package com.realnet.basic1.Controllers; | ||||||
|  | import java.util.List; | ||||||
|  | import org.springframework.beans.factory.annotation.Autowired; | ||||||
|  |  import org.springframework.web.bind.annotation.*; | ||||||
|  | import org.springframework.web.multipart.MultipartFile; | ||||||
|  | import com.fasterxml.jackson.core.JsonProcessingException; | ||||||
|  | import org.springframework.web.bind.annotation.CrossOrigin; | ||||||
|  | import com.fasterxml.jackson.databind.JsonMappingException; | ||||||
|  | import com.realnet.config.EmailService; | ||||||
|  | import com.realnet.users.entity1.AppUser; | ||||||
|  | import com.realnet.users.service1.AppUserServiceImpl; | ||||||
|  | import com.fasterxml.jackson.databind.ObjectMapper; | ||||||
|  | import org.springframework.data.domain.*; | ||||||
|  | import com.realnet.fnd.response.EntityResponse; | ||||||
|  | import org.springframework.http.*; | ||||||
|  | import org.springframework.beans.factory.annotation.*; | ||||||
|  | import com.realnet.basic1.Entity.Test_a; | ||||||
|  | import com.realnet.basic1.Services.Test_aService ; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @RequestMapping(value = "/Test_a") | ||||||
|  |  @CrossOrigin("*")  | ||||||
|  | @RestController | ||||||
|  | public class Test_aController { | ||||||
|  | 	@Autowired | ||||||
|  | 	private Test_aService Service; | ||||||
|  | 
 | ||||||
|  | @Value("${projectPath}") | ||||||
|  | 	private String projectPath; | ||||||
|  |   | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	@PostMapping("/Test_a") | ||||||
|  | 		  public Test_a Savedata(@RequestBody Test_a data) { | ||||||
|  | 		Test_a save = Service.Savedata(data)	; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 		System.out.println("data saved..." + save); | ||||||
|  | 
 | ||||||
|  |  return save; | ||||||
|  | 	  } | ||||||
|  | @PutMapping("/Test_a/{id}") | ||||||
|  | 	public  Test_a update(@RequestBody Test_a data,@PathVariable Integer id ) { | ||||||
|  | 		Test_a update = Service.update(data,id); | ||||||
|  | 		System.out.println("data update..." + update); | ||||||
|  | 		return update; | ||||||
|  | 	}	  | ||||||
|  | //	get all with pagination | ||||||
|  | 	@GetMapping("/Test_a/getall/page") | ||||||
|  | 	public Page<Test_a> getall(@RequestParam(value = "page", required = false) Integer page, | ||||||
|  | 			@RequestParam(value = "size", required = false) Integer size) { | ||||||
|  | 		Pageable paging = PageRequest.of(page, size); | ||||||
|  | 		Page<Test_a> get = Service.getAllWithPagination(paging); | ||||||
|  | 
 | ||||||
|  | 		return get; | ||||||
|  | 
 | ||||||
|  | 	}	 | ||||||
|  | 	@GetMapping("/Test_a") | ||||||
|  | 	public List<Test_a> getdetails() { | ||||||
|  | 		 List<Test_a> get = Service.getdetails();		 | ||||||
|  | 		return get; | ||||||
|  | } | ||||||
|  | // get all without authentication  | ||||||
|  | 
 | ||||||
|  | 	@GetMapping("/token/Test_a") | ||||||
|  | 	public List<Test_a> getallwioutsec() { | ||||||
|  | 		 List<Test_a> get = Service.getdetails();		 | ||||||
|  | 		return get; | ||||||
|  | } | ||||||
|  | @GetMapping("/Test_a/{id}") | ||||||
|  | 	public  Test_a  getdetailsbyId(@PathVariable Integer id ) { | ||||||
|  | 		Test_a  get = Service.getdetailsbyId(id); | ||||||
|  | 		return get; | ||||||
|  | 	} | ||||||
|  | @DeleteMapping("/Test_a/{id}") | ||||||
|  | 	public  ResponseEntity<?> delete_by_id(@PathVariable Integer id ) { | ||||||
|  | 	Service.delete_by_id(id); | ||||||
|  | 			return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK); | ||||||
|  | 	 | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,91 @@ | |||||||
|  | package com.realnet.basic1.Controllers; | ||||||
|  | import java.util.List; | ||||||
|  | import org.springframework.beans.factory.annotation.Autowired; | ||||||
|  |  import org.springframework.web.bind.annotation.*; | ||||||
|  | import org.springframework.web.multipart.MultipartFile; | ||||||
|  | import com.fasterxml.jackson.core.JsonProcessingException; | ||||||
|  | import org.springframework.web.bind.annotation.CrossOrigin; | ||||||
|  | import com.fasterxml.jackson.databind.JsonMappingException; | ||||||
|  | import com.realnet.config.EmailService; | ||||||
|  | import com.realnet.users.entity1.AppUser; | ||||||
|  | import com.realnet.users.service1.AppUserServiceImpl; | ||||||
|  | import com.fasterxml.jackson.databind.ObjectMapper; | ||||||
|  | import org.springframework.data.domain.*; | ||||||
|  | import com.realnet.fnd.response.EntityResponse; | ||||||
|  | import org.springframework.http.*; | ||||||
|  | import org.springframework.beans.factory.annotation.*; | ||||||
|  | import com.realnet.basic1.Entity.Child; | ||||||
|  | import com.realnet.basic1.Services.ChildService ; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @RequestMapping(value = "/token/Child") | ||||||
|  |  @CrossOrigin("*")  | ||||||
|  | @RestController | ||||||
|  | public class tokenFree_ChildController { | ||||||
|  | 	@Autowired | ||||||
|  | 	private ChildService Service; | ||||||
|  | 
 | ||||||
|  | @Value("${projectPath}") | ||||||
|  | 	private String projectPath; | ||||||
|  |   | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	@PostMapping("/Child") | ||||||
|  | 		  public Child Savedata(@RequestBody Child data) { | ||||||
|  | 		Child save = Service.Savedata(data)	; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 		System.out.println("data saved..." + save); | ||||||
|  | 
 | ||||||
|  |  return save; | ||||||
|  | 	  } | ||||||
|  | @PutMapping("/Child/{id}") | ||||||
|  | 	public  Child update(@RequestBody Child data,@PathVariable Integer id ) { | ||||||
|  | 		Child update = Service.update(data,id); | ||||||
|  | 		System.out.println("data update..." + update); | ||||||
|  | 		return update; | ||||||
|  | 	}	  | ||||||
|  | //	get all with pagination | ||||||
|  | 	@GetMapping("/Child/getall/page") | ||||||
|  | 	public Page<Child> getall(@RequestParam(value = "page", required = false) Integer page, | ||||||
|  | 			@RequestParam(value = "size", required = false) Integer size) { | ||||||
|  | 		Pageable paging = PageRequest.of(page, size); | ||||||
|  | 		Page<Child> get = Service.getAllWithPagination(paging); | ||||||
|  | 
 | ||||||
|  | 		return get; | ||||||
|  | 
 | ||||||
|  | 	}	 | ||||||
|  | 	@GetMapping("/Child") | ||||||
|  | 	public List<Child> getdetails() { | ||||||
|  | 		 List<Child> get = Service.getdetails();		 | ||||||
|  | 		return get; | ||||||
|  | } | ||||||
|  | // get all without authentication  | ||||||
|  | 
 | ||||||
|  | 	@GetMapping("/token/Child") | ||||||
|  | 	public List<Child> getallwioutsec() { | ||||||
|  | 		 List<Child> get = Service.getdetails();		 | ||||||
|  | 		return get; | ||||||
|  | } | ||||||
|  | @GetMapping("/Child/{id}") | ||||||
|  | 	public  Child  getdetailsbyId(@PathVariable Integer id ) { | ||||||
|  | 		Child  get = Service.getdetailsbyId(id); | ||||||
|  | 		return get; | ||||||
|  | 	} | ||||||
|  | @DeleteMapping("/Child/{id}") | ||||||
|  | 	public  ResponseEntity<?> delete_by_id(@PathVariable Integer id ) { | ||||||
|  | 	Service.delete_by_id(id); | ||||||
|  | 			return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK); | ||||||
|  | 	 | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,99 @@ | |||||||
|  | package com.realnet.basic1.Controllers; | ||||||
|  | import java.util.List; | ||||||
|  | import org.springframework.beans.factory.annotation.Autowired; | ||||||
|  |  import org.springframework.web.bind.annotation.*; | ||||||
|  | import org.springframework.web.multipart.MultipartFile; | ||||||
|  | import com.fasterxml.jackson.core.JsonProcessingException; | ||||||
|  | import org.springframework.web.bind.annotation.CrossOrigin; | ||||||
|  | import com.fasterxml.jackson.databind.JsonMappingException; | ||||||
|  | import com.realnet.config.EmailService; | ||||||
|  | import com.realnet.users.entity1.AppUser; | ||||||
|  | import com.realnet.users.service1.AppUserServiceImpl; | ||||||
|  | import com.fasterxml.jackson.databind.ObjectMapper; | ||||||
|  | import org.springframework.data.domain.*; | ||||||
|  | import com.realnet.fnd.response.EntityResponse; | ||||||
|  | import org.springframework.http.*; | ||||||
|  | import org.springframework.beans.factory.annotation.*; | ||||||
|  | import com.realnet.basic1.Entity.Test_a; | ||||||
|  | import com.realnet.basic1.Services.Test_aService ; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | @RequestMapping(value = "/token/Test_a") | ||||||
|  |  @CrossOrigin("*")  | ||||||
|  | @RestController | ||||||
|  | public class tokenFree_Test_aController { | ||||||
|  | 	@Autowired | ||||||
|  | 	private Test_aService Service; | ||||||
|  | 
 | ||||||
|  | @Value("${projectPath}") | ||||||
|  | 	private String projectPath; | ||||||
|  |   | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	@PostMapping("/Test_a") | ||||||
|  | 		  public Test_a Savedata(@RequestBody Test_a data) { | ||||||
|  | 		Test_a save = Service.Savedata(data)	; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 		System.out.println("data saved..." + save); | ||||||
|  | 
 | ||||||
|  |  return save; | ||||||
|  | 	  } | ||||||
|  | @PutMapping("/Test_a/{id}") | ||||||
|  | 	public  Test_a update(@RequestBody Test_a data,@PathVariable Integer id ) { | ||||||
|  | 		Test_a update = Service.update(data,id); | ||||||
|  | 		System.out.println("data update..." + update); | ||||||
|  | 		return update; | ||||||
|  | 	}	  | ||||||
|  | //	get all with pagination | ||||||
|  | 	@GetMapping("/Test_a/getall/page") | ||||||
|  | 	public Page<Test_a> getall(@RequestParam(value = "page", required = false) Integer page, | ||||||
|  | 			@RequestParam(value = "size", required = false) Integer size) { | ||||||
|  | 		Pageable paging = PageRequest.of(page, size); | ||||||
|  | 		Page<Test_a> get = Service.getAllWithPagination(paging); | ||||||
|  | 
 | ||||||
|  | 		return get; | ||||||
|  | 
 | ||||||
|  | 	}	 | ||||||
|  | 	@GetMapping("/Test_a") | ||||||
|  | 	public List<Test_a> getdetails() { | ||||||
|  | 		 List<Test_a> get = Service.getdetails();		 | ||||||
|  | 		return get; | ||||||
|  | } | ||||||
|  | // get all without authentication  | ||||||
|  | 
 | ||||||
|  | 	@GetMapping("/token/Test_a") | ||||||
|  | 	public List<Test_a> getallwioutsec() { | ||||||
|  | 		 List<Test_a> get = Service.getdetails();		 | ||||||
|  | 		return get; | ||||||
|  | } | ||||||
|  | @GetMapping("/Test_a/{id}") | ||||||
|  | 	public  Test_a  getdetailsbyId(@PathVariable Integer id ) { | ||||||
|  | 		Test_a  get = Service.getdetailsbyId(id); | ||||||
|  | 		return get; | ||||||
|  | 	} | ||||||
|  | @DeleteMapping("/Test_a/{id}") | ||||||
|  | 	public  ResponseEntity<?> delete_by_id(@PathVariable Integer id ) { | ||||||
|  | 	Service.delete_by_id(id); | ||||||
|  | 			return new ResponseEntity<>(new EntityResponse("Deleted"), HttpStatus.OK); | ||||||
|  | 	 | ||||||
|  | 	} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,29 @@ | |||||||
|  | package com.realnet.basic1.Entity; | ||||||
|  |  import lombok.*; | ||||||
|  | import com.realnet.WhoColumn.Entity.Extension;  | ||||||
|  |  import javax.persistence.*; | ||||||
|  |  import java.time.LocalDateTime; | ||||||
|  |  import java.util.*; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |  @Entity  | ||||||
|  |  @Data | ||||||
|  |  public class    Child extends Extension {  | ||||||
|  |  /** | ||||||
|  | 	 *  | ||||||
|  | 	 */ | ||||||
|  | 	private static final long serialVersionUID = 1L; | ||||||
|  | 
 | ||||||
|  |  @Id | ||||||
|  |  @GeneratedValue(strategy = GenerationType.IDENTITY) | ||||||
|  |  private Integer id; | ||||||
|  | 
 | ||||||
|  | private String  name; | ||||||
|  | 
 | ||||||
|  | @Column(length = 2000) | ||||||
|  | private String description; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,34 @@ | |||||||
|  | package com.realnet.basic1.Entity; | ||||||
|  |  import lombok.*; | ||||||
|  | import com.realnet.WhoColumn.Entity.Extension;  | ||||||
|  |  import javax.persistence.*; | ||||||
|  |  import java.time.LocalDateTime; | ||||||
|  |  import java.util.*; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | import com.realnet.basic1.Entity.Child; | ||||||
|  | 
 | ||||||
|  |  @Entity  | ||||||
|  |  @Data | ||||||
|  |  public class    Test_a extends Extension {  | ||||||
|  |  /** | ||||||
|  | 	 *  | ||||||
|  | 	 */ | ||||||
|  | 	private static final long serialVersionUID = 1L; | ||||||
|  | 
 | ||||||
|  |  @Id | ||||||
|  |  @GeneratedValue(strategy = GenerationType.IDENTITY) | ||||||
|  |  private Integer id; | ||||||
|  | 
 | ||||||
|  | private String  name; | ||||||
|  | 
 | ||||||
|  | @Column(length = 2000) | ||||||
|  | private String description; | ||||||
|  | 
 | ||||||
|  | @OneToMany(  cascade=CascadeType.ALL) | ||||||
|  |  private List<Child> child = new ArrayList<>(); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | } | ||||||
| @ -0,0 +1,28 @@ | |||||||
|  | package com.realnet.basic1.Repository; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | import org.springframework.data.domain.Page; | ||||||
|  | import org.springframework.data.domain.Pageable; | ||||||
|  | import org.springframework.data.jpa.repository.JpaRepository; | ||||||
|  | import org.springframework.data.jpa.repository.Query; | ||||||
|  | 
 | ||||||
|  | import org.springframework.stereotype.Repository;  | ||||||
|  | import java.util.*; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |   | ||||||
|  | 
 | ||||||
|  | import com.realnet.basic1.Entity.Child; | ||||||
|  | 
 | ||||||
|  | @Repository | ||||||
|  | public interface  ChildRepository  extends  JpaRepository<Child, Integer>  {  | ||||||
|  | 
 | ||||||
|  | @Query(value = "select * from child where  created_by=?1", nativeQuery = true) | ||||||
|  | 	List<Child> findAll(Long creayedBy); | ||||||
|  | 
 | ||||||
|  | @Query(value = "select * from child where  created_by=?1", nativeQuery = true) | ||||||
|  | 	Page<Child> findAll(Pageable page, Long creayedBy); | ||||||
|  | } | ||||||
| @ -0,0 +1,30 @@ | |||||||
|  | package com.realnet.basic1.Repository; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | import org.springframework.data.domain.Page; | ||||||
|  | import org.springframework.data.domain.Pageable; | ||||||
|  | import org.springframework.data.jpa.repository.JpaRepository; | ||||||
|  | import org.springframework.data.jpa.repository.Query; | ||||||
|  | 
 | ||||||
|  | import org.springframework.stereotype.Repository;  | ||||||
|  | import java.util.*; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |   | ||||||
|  | 
 | ||||||
|  | import com.realnet.basic1.Entity.Test_a; | ||||||
|  | 
 | ||||||
|  | @Repository | ||||||
|  | public interface  Test_aRepository  extends  JpaRepository<Test_a, Integer>  {  | ||||||
|  | 
 | ||||||
|  | @Query(value = "select * from test_a where  created_by=?1", nativeQuery = true) | ||||||
|  | 	List<Test_a> findAll(Long creayedBy); | ||||||
|  | 
 | ||||||
|  | @Query(value = "select * from test_a where  created_by=?1", nativeQuery = true) | ||||||
|  | 	Page<Test_a> findAll(Pageable page, Long creayedBy); | ||||||
|  | } | ||||||
| @ -0,0 +1,83 @@ | |||||||
|  | package com.realnet.basic1.Services; | ||||||
|  | import com.realnet.basic1.Repository.ChildRepository; | ||||||
|  | import com.realnet.basic1.Entity.Child | ||||||
|  | ;import java.util.*; | ||||||
|  | 
 | ||||||
|  | import org.springframework.beans.factory.annotation.Autowired; | ||||||
|  | import com.realnet.SequenceGenerator.Service.SequenceService; | ||||||
|  | import org.springframework.data.domain.Page; | ||||||
|  | import com.realnet.realm.Entity.Realm; | ||||||
|  | import com.realnet.realm.Services.RealmService; | ||||||
|  | import org.springframework.data.domain.Pageable; | ||||||
|  | import org.springframework.http.*; | ||||||
|  | import com.realnet.users.service1.AppUserServiceImpl; | ||||||
|  | import com.realnet.users.entity1.AppUser; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	import org.springframework.stereotype.Service; | ||||||
|  | 
 | ||||||
|  | @Service | ||||||
|  |  public class ChildService { | ||||||
|  | @Autowired | ||||||
|  | private ChildRepository Repository; | ||||||
|  | 	@Autowired | ||||||
|  | 	private AppUserServiceImpl userService;  | ||||||
|  | @Autowired | ||||||
|  | 	private RealmService realmService; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | public Child Savedata(Child data) { | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	data.setUpdatedBy(getUser().getUserId()); | ||||||
|  | 		data.setCreatedBy(getUser().getUserId()); | ||||||
|  | 		data.setAccountId(getUser().getAccount().getAccount_id()); | ||||||
|  | Child save = Repository.save(data); | ||||||
|  | 				return save;	 | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | //	get all with pagination | ||||||
|  | 	public Page<Child> getAllWithPagination(Pageable page) { | ||||||
|  | 		return Repository.findAll(page, getUser().getUserId()); | ||||||
|  | 	}			 | ||||||
|  | public List<Child> getdetails() {   | ||||||
|  | 		List<Realm> realm = realmService.findByUserId(getUser().getUserId()); | ||||||
|  | List<Child> all = Repository.findAll(getUser().getUserId()); | ||||||
|  | 		 | ||||||
|  | 		return all ;		} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | public Child getdetailsbyId(Integer id) { | ||||||
|  | 	return Repository.findById(id).get(); | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	public void delete_by_id(Integer id) { | ||||||
|  |  Repository.deleteById(id); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | public Child update(Child data,Integer id) { | ||||||
|  | 	Child old = Repository.findById(id).get(); | ||||||
|  | old.setName(data.getName()); | ||||||
|  | 
 | ||||||
|  | old.setDescription(data.getDescription()); | ||||||
|  | 
 | ||||||
|  | final Child test = Repository.save(old); | ||||||
|  | 		data.setUpdatedBy(getUser().getUserId()); | ||||||
|  |   return test;}  | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |  public AppUser getUser() { | ||||||
|  | 		AppUser user = userService.getLoggedInUser(); | ||||||
|  | 		return user; | ||||||
|  | 
 | ||||||
|  | 	}} | ||||||
| @ -0,0 +1,93 @@ | |||||||
|  | package com.realnet.basic1.Services; | ||||||
|  | import com.realnet.basic1.Repository.Test_aRepository; | ||||||
|  | import com.realnet.basic1.Entity.Test_a | ||||||
|  | ;import java.util.*; | ||||||
|  | 
 | ||||||
|  | import org.springframework.beans.factory.annotation.Autowired; | ||||||
|  | import com.realnet.SequenceGenerator.Service.SequenceService; | ||||||
|  | import org.springframework.data.domain.Page; | ||||||
|  | import com.realnet.realm.Entity.Realm; | ||||||
|  | import com.realnet.realm.Services.RealmService; | ||||||
|  | import org.springframework.data.domain.Pageable; | ||||||
|  | import org.springframework.http.*; | ||||||
|  | import com.realnet.users.service1.AppUserServiceImpl; | ||||||
|  | import com.realnet.users.entity1.AppUser; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	import org.springframework.stereotype.Service; | ||||||
|  | 
 | ||||||
|  | @Service | ||||||
|  |  public class Test_aService { | ||||||
|  | @Autowired | ||||||
|  | private Test_aRepository Repository; | ||||||
|  | 	@Autowired | ||||||
|  | 	private AppUserServiceImpl userService;  | ||||||
|  | @Autowired | ||||||
|  | 	private RealmService realmService; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | public Test_a Savedata(Test_a data) { | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	data.setUpdatedBy(getUser().getUserId()); | ||||||
|  | 		data.setCreatedBy(getUser().getUserId()); | ||||||
|  | 		data.setAccountId(getUser().getAccount().getAccount_id()); | ||||||
|  | Test_a save = Repository.save(data); | ||||||
|  | 				return save;	 | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | //	get all with pagination | ||||||
|  | 	public Page<Test_a> getAllWithPagination(Pageable page) { | ||||||
|  | 		return Repository.findAll(page, getUser().getUserId()); | ||||||
|  | 	}			 | ||||||
|  | public List<Test_a> getdetails() {   | ||||||
|  | 		List<Realm> realm = realmService.findByUserId(getUser().getUserId()); | ||||||
|  | List<Test_a> all = Repository.findAll(getUser().getUserId()); | ||||||
|  | 		 | ||||||
|  | 		return all ;		} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | public Test_a getdetailsbyId(Integer id) { | ||||||
|  | 	return Repository.findById(id).get(); | ||||||
|  | 			} | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 	public void delete_by_id(Integer id) { | ||||||
|  |  Repository.deleteById(id); | ||||||
|  | } | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | public Test_a update(Test_a data,Integer id) { | ||||||
|  | 	Test_a old = Repository.findById(id).get(); | ||||||
|  | old.setName(data.getName()); | ||||||
|  | 
 | ||||||
|  | old.setDescription(data.getDescription()); | ||||||
|  | 
 | ||||||
|  | old.setChild(data.getChild()); | ||||||
|  | 
 | ||||||
|  | final Test_a test = Repository.save(old); | ||||||
|  | 		data.setUpdatedBy(getUser().getUserId()); | ||||||
|  |   return test;}  | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |  public AppUser getUser() { | ||||||
|  | 		AppUser user = userService.getLoggedInUser(); | ||||||
|  | 		return user; | ||||||
|  | 
 | ||||||
|  | 	}} | ||||||
							
								
								
									
										4
									
								
								testrelationship-db-d/authsec_mysql/mysql/wf_table/wf_table.sql
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										4
									
								
								testrelationship-db-d/authsec_mysql/mysql/wf_table/wf_table.sql
									
									
									
									
									
										Executable file
									
								
							| @ -0,0 +1,4 @@ | |||||||
|  | CREATE TABLE db.Test_a(id BIGINT NOT NULL AUTO_INCREMENT, description VARCHAR(400), onetomanyextension VARCHAR(400), name VARCHAR(400),  PRIMARY KEY (id)); | ||||||
|  | 
 | ||||||
|  | CREATE TABLE db.Child(id BIGINT NOT NULL AUTO_INCREMENT, description VARCHAR(400), name VARCHAR(400),  PRIMARY KEY (id)); | ||||||
|  | 
 | ||||||
| @ -1,3 +1,7 @@ | |||||||
|  | import Child from "./components/BuilderComponents/basic1/Child/Child"; | ||||||
|  | 
 | ||||||
|  | import TestA from "./components/BuilderComponents/basic1/TestA/TestA"; | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| import React from "react"; | import React from "react"; | ||||||
| @ -143,6 +147,12 @@ const App = () => { | |||||||
| 
 | 
 | ||||||
|             </Route> |             </Route> | ||||||
|             {/* buildercomponents */} |             {/* buildercomponents */} | ||||||
|  |         <Route path="/Child" element={<Child />} /> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |         <Route path="/TestA" element={<TestA />} /> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
| 
 | 
 | ||||||
|             <Route path="/auth/*" element={<AuthLayout />}> |             <Route path="/auth/*" element={<AuthLayout />}> | ||||||
|               <Route path="login" element={<Login />} /> |               <Route path="login" element={<Login />} /> | ||||||
| @ -156,4 +166,3 @@ const App = () => { | |||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| export default App; | export default App; | ||||||
| 
 |  | ||||||
|  | |||||||
| @ -0,0 +1,483 @@ | |||||||
|  | import React, { useEffect, useState , useRef } from "react"; | ||||||
|  | import QRCode from "qrcode.react"; | ||||||
|  | import Barcode from "react-barcode"; | ||||||
|  | import html2canvas from "html2canvas"; | ||||||
|  | import Select from "react-select"; | ||||||
|  | import ReCAPTCHA from "react-google-recaptcha"; | ||||||
|  | import axios from "axios"; | ||||||
|  | import { FaTrash } from "react-icons/fa"; | ||||||
|  | import { Modal, Button, Form, Pagination,Container, Row, Col, Image , ProgressBar , } from "react-bootstrap"; | ||||||
|  | import { ToastContainer, toast } from "react-toastify"; | ||||||
|  | import "react-toastify/dist/ReactToastify.css"; | ||||||
|  | import { getToken } from '../../../../utils/tokenService';import Table from "react-bootstrap/Table"; | ||||||
|  | const FILE_API_URL = `${process.env.REACT_APP_API_URL}/FileUpload/Uploadeddocs`;  | ||||||
|  | const API_URL = `${process.env.REACT_APP_API_URL}/Child/Child`; | ||||||
|  | const REACT_APP_API_TOKEN = localStorage.getItem("authToken") | ||||||
|  | 
 | ||||||
|  | const EntityTable = () => { | ||||||
|  |   const [data, setData] = useState([]); | ||||||
|  |   const [filteredData, setFilteredData] = useState([]); | ||||||
|  |   const [newEntity, setNewEntity] = useState({ | ||||||
|  |     name: "", | ||||||
|  | 
 | ||||||
|  |     description: "", | ||||||
|  | 
 | ||||||
|  |   }); | ||||||
|  |   const [editEntity, setEditEntity] = useState(null); | ||||||
|  |   const [showEditModal, setShowEditModal] = useState(false); | ||||||
|  |   const [showAddModal, setShowAddModal] = useState(false); | ||||||
|  |   const [showDeleteModal, setShowDeleteModal] = useState(false); | ||||||
|  |   const [deleteEntityId, setDeleteEntityId] = useState(null); | ||||||
|  |   const [currentPage, setCurrentPage] = useState(1); | ||||||
|  |   const [itemsPerPage] = useState(5); // Adjust this value as needed
 | ||||||
|  |   const [searchQuery, setSearchQuery] = useState(""); | ||||||
|  |   const [loading, setLoading] = useState(true); | ||||||
|  |   const [options, setOptions] = useState([]); | ||||||
|  |   const [filteredOptions, setFilteredOptions] = useState([]); | ||||||
|  |   const [error, setError] = useState(null); | ||||||
|  |  const [uploadProgress, setUploadProgress] = useState(0); | ||||||
|  |  const [showModal, setShowModal] = useState(false); | ||||||
|  |   const [showValulistModal, setShowValulistModal] = useState(false); | ||||||
|  |  const barcodeRef = useRef(null); | ||||||
|  |   const [serverData, setServerData] = useState([]); | ||||||
|  |   const recaptchaRef = useRef(null); | ||||||
|  |  const editBarcodeRef = useRef(null); | ||||||
|  |   useEffect(() => { | ||||||
|  |     fetchData(); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |   }, []); | ||||||
|  | 
 | ||||||
|  |   useEffect(() => { | ||||||
|  |     handleSearch(); | ||||||
|  |   }, [searchQuery, data]); | ||||||
|  |   const fetchData = async () => { | ||||||
|  |     try { | ||||||
|  | const token = getToken(); | ||||||
|  |       const response = await axios.get(API_URL, { | ||||||
|  |         headers: { Authorization: `Bearer ${token}` }, | ||||||
|  |       }); | ||||||
|  |       setData(response.data); | ||||||
|  |     } catch (error) { | ||||||
|  |       console.error("Error fetching data:", error); | ||||||
|  |     } | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   const handleDelete = async () => { | ||||||
|  |     try { | ||||||
|  |  const token = getToken(); | ||||||
|  |       await axios.delete(`${API_URL}/${deleteEntityId}`, { | ||||||
|  |         headers: { Authorization: `Bearer ${token}` }, | ||||||
|  |       }); | ||||||
|  |       fetchData(); | ||||||
|  |       toast.success("Successfully deleted!"); | ||||||
|  |       setShowDeleteModal(false); | ||||||
|  |     } catch (error) { | ||||||
|  |       console.error("Error deleting data:", error); | ||||||
|  |     } | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   const handleAdd = async () => { | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     try { | ||||||
|  |  const token = getToken(); | ||||||
|  |       await axios.post(API_URL, newEntity, { | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |         headers: { Authorization: `Bearer ${token}` }, | ||||||
|  |       }); | ||||||
|  |       fetchData(); | ||||||
|  |       setNewEntity({ | ||||||
|  |     name: "", | ||||||
|  | 
 | ||||||
|  |     description: "", | ||||||
|  | 
 | ||||||
|  |       }); | ||||||
|  |       setShowAddModal(false); | ||||||
|  |       toast.success("Successfully added!"); | ||||||
|  |     } catch (error) { | ||||||
|  |       console.error("Error adding data:", error); | ||||||
|  |     } | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   const handleChange = (e) => { | ||||||
|  |     const { name, value } = e.target; | ||||||
|  |     setNewEntity({ ...newEntity, [name]: value }); | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   const handleEditChange = (e) => { | ||||||
|  |     const { name, value } = e.target; | ||||||
|  |     setEditEntity({ ...editEntity, [name]: value }); | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   const handleEdit = (entity) => { | ||||||
|  |     setEditEntity(entity); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     setShowEditModal(true); | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   const formatCurrency = (value) => { | ||||||
|  |    if (value && !value.startsWith('₹')) { | ||||||
|  |     return `₹${value}`; | ||||||
|  |   } | ||||||
|  |   return value; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |    const handleUpdate = async () => { | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     try { | ||||||
|  | const token = getToken(); | ||||||
|  |       await axios.put(`${API_URL}/${editEntity.id}`, editEntity, { | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |         headers: { Authorization: `Bearer ${token}` }, | ||||||
|  |       }); | ||||||
|  |       fetchData(); | ||||||
|  |       setShowEditModal(false); | ||||||
|  |       toast.success("Successfully updated!"); | ||||||
|  |     } catch (error) { | ||||||
|  |       console.error("Error updating data:", error); | ||||||
|  |     } | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   const handleSearch = () => { | ||||||
|  |     const filtered = data.filter( | ||||||
|  |       (entity) => | ||||||
|  | 
 | ||||||
|  |       entity.name.toLowerCase().includes(searchQuery.toLowerCase()) || | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |       entity.description.toLowerCase().includes(searchQuery.toLowerCase())     ); | ||||||
|  |     setFilteredData(filtered); | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   const handlePageChange = (pageNumber) => { | ||||||
|  |     setCurrentPage(pageNumber); | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   const generateBarcodeImage = async (ref) => { | ||||||
|  |     if (ref.current) { | ||||||
|  |       const canvas = await html2canvas(ref.current); | ||||||
|  |       const imgData = canvas.toDataURL("image/png"); | ||||||
|  |       const link = document.createElement("a"); | ||||||
|  |       link.href = imgData; | ||||||
|  |       link.download = "barcode.png"; | ||||||
|  |       link.click(); | ||||||
|  |     } | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   // Calculate items for current page
 | ||||||
|  |   const indexOfLastItem = currentPage * itemsPerPage; | ||||||
|  |   const indexOfFirstItem = indexOfLastItem - itemsPerPage; | ||||||
|  |   const currentItems = filteredData.slice(indexOfFirstItem, indexOfLastItem); | ||||||
|  | 
 | ||||||
|  |   return ( | ||||||
|  |     <div className="container mt-5"> | ||||||
|  |       <ToastContainer /> | ||||||
|  |       <h1 className="mb-4">Entity Table</h1> | ||||||
|  |       <div className="d-flex justify-content-between mb-3"> | ||||||
|  |         <Button variant="primary" onClick={() => setShowAddModal(true)}> | ||||||
|  |           Add Entity | ||||||
|  |         </Button> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |   | ||||||
|  |         <Form.Control | ||||||
|  |           type="text" | ||||||
|  |           className="w-25" | ||||||
|  |           placeholder="Search..." | ||||||
|  |           value={searchQuery} | ||||||
|  |           onChange={(e) => setSearchQuery(e.target.value)} | ||||||
|  |         /> | ||||||
|  |       </div> | ||||||
|  |       <Table striped bordered hover responsive variant="grey"> | ||||||
|  |         <thead> | ||||||
|  |           <tr> | ||||||
|  |   <th>name</th> | ||||||
|  | 
 | ||||||
|  |   <th>description</th> | ||||||
|  | 
 | ||||||
|  | <th>Action</th> | ||||||
|  |           </tr> | ||||||
|  |         </thead> | ||||||
|  |         <tbody > | ||||||
|  |           {currentItems.map((entity) => ( | ||||||
|  |             <tr key={entity.id}> | ||||||
|  | 
 | ||||||
|  |               <td>{entity.name}</td> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |               <td>{entity.description}</td> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |               <td> | ||||||
|  |                 <Button | ||||||
|  |                   variant="warning" | ||||||
|  |                   size="sm" | ||||||
|  |                   className="me-2" | ||||||
|  |                   onClick={() => handleEdit(entity)} | ||||||
|  |                 > | ||||||
|  |                   Update | ||||||
|  |                 </Button> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |   	 | ||||||
|  |                 <Button | ||||||
|  |                   variant="danger" | ||||||
|  |                   size="sm" | ||||||
|  |                   onClick={() => { | ||||||
|  |                     setDeleteEntityId(entity.id); | ||||||
|  |                     setShowDeleteModal(true); | ||||||
|  |                   }} | ||||||
|  |                 > | ||||||
|  |                   Delete | ||||||
|  |                 </Button> | ||||||
|  |               </td> | ||||||
|  |             </tr> | ||||||
|  |           ))} | ||||||
|  |         </tbody> | ||||||
|  |       </Table> | ||||||
|  |       <Pagination className="d-flex justify-content-center mt-4"> | ||||||
|  |         {Array.from( | ||||||
|  |           { length: Math.ceil(filteredData.length / itemsPerPage) }, | ||||||
|  |           (_, index) => ( | ||||||
|  |             <Pagination.Item | ||||||
|  |               key={index + 1} | ||||||
|  |               active={index + 1 === currentPage} | ||||||
|  |               onClick={() => handlePageChange(index + 1)} | ||||||
|  |             > | ||||||
|  |               {index + 1} | ||||||
|  |             </Pagination.Item> | ||||||
|  |           ) | ||||||
|  |         )} | ||||||
|  |       </Pagination> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |        <Modal show={showEditModal} onHide={() => setShowEditModal(false)}> | ||||||
|  |         <Modal.Header closeButton> | ||||||
|  |           <Modal.Title>Edit Entity</Modal.Title> | ||||||
|  |         </Modal.Header> | ||||||
|  |         <Modal.Body> | ||||||
|  |           {editEntity && ( | ||||||
|  |             <Form> | ||||||
|  | <div className="form-group"> | ||||||
|  |   <div className="container mt-4" style={{ width: '100%' }}> | ||||||
|  |     <div className="card p-4 shadow-sm rounded"> | ||||||
|  |       <div className="row align-items-center"> | ||||||
|  |         <div className="col-md-3"> | ||||||
|  |         </div> | ||||||
|  | <label htmlFor="name" className="form-label">Name</label> | ||||||
|  |         | ||||||
|  |         <div className="col-md-9"> | ||||||
|  |           <input | ||||||
|  |             type="text" | ||||||
|  |             className="form-control" | ||||||
|  |             id="name" | ||||||
|  |             name="name" | ||||||
|  |             value={editEntity.name} | ||||||
|  |             onChange={handleEditChange} | ||||||
|  |             required | ||||||
|  |             style={{ | ||||||
|  |               backgroundColor: '#f7f9fc', | ||||||
|  |               border: '1px solid #ced4da', | ||||||
|  |               borderRadius: '8px', | ||||||
|  |               padding: '10px', | ||||||
|  |               transition: 'border-color 0.3s ease, box-shadow 0.3s ease', | ||||||
|  |             }} | ||||||
|  |             onFocus={(e) => { | ||||||
|  |               e.target.style.borderColor = '#007bff'; | ||||||
|  |               e.target.style.boxShadow = '0 0 8px rgba(0, 123, 255, 0.25)'; | ||||||
|  |             }} | ||||||
|  |             onBlur={(e) => { | ||||||
|  |               e.target.style.borderColor = '#ced4da'; | ||||||
|  |               e.target.style.boxShadow = 'none'; | ||||||
|  |             }} | ||||||
|  |           /> | ||||||
|  |         </div> | ||||||
|  | 
 | ||||||
|  |  <Form.Group className="mb-3"> | ||||||
|  |           <Form.Label>Description</Form.Label> | ||||||
|  |           <Form.Control | ||||||
|  |             as="textarea" | ||||||
|  |             name="description" | ||||||
|  |             value={editEntity.description} | ||||||
|  |             onChange={handleEditChange} | ||||||
|  |             rows={5} | ||||||
|  |             placeholder="Enter description" | ||||||
|  | style={{ | ||||||
|  |               backgroundColor: '#f7f9fc', | ||||||
|  |               border: '1px solid #ced4da', | ||||||
|  |               borderRadius: '8px', | ||||||
|  |               padding: '10px', | ||||||
|  |               transition: 'border-color 0.3s ease, box-shadow 0.3s ease', | ||||||
|  |             }} | ||||||
|  |             onFocus={(e) => { | ||||||
|  |               e.target.style.borderColor = '#007bff'; | ||||||
|  |               e.target.style.boxShadow = '0 0 8px rgba(0, 123, 255, 0.25)'; | ||||||
|  |             }} | ||||||
|  |             onBlur={(e) => { | ||||||
|  |               e.target.style.borderColor = '#ced4da'; | ||||||
|  |               e.target.style.boxShadow = 'none'; | ||||||
|  |             }} | ||||||
|  |           /> | ||||||
|  |         </Form.Group> | ||||||
|  | 
 | ||||||
|  |      | ||||||
|  |       </div> | ||||||
|  |     </div> | ||||||
|  |   </div> | ||||||
|  | </div> | ||||||
|  |           </Form> | ||||||
|  |            | ||||||
|  |           )} | ||||||
|  |         </Modal.Body> | ||||||
|  |         <Modal.Footer> | ||||||
|  |           <Button variant="secondary" onClick={() => setShowEditModal(false)}> | ||||||
|  |             Close | ||||||
|  |           </Button> | ||||||
|  |           <Button variant="primary" onClick={handleUpdate}> | ||||||
|  |             Save changes | ||||||
|  |           </Button> | ||||||
|  |         </Modal.Footer> | ||||||
|  |       </Modal> | ||||||
|  |       <Modal show={showAddModal} onHide={() => setShowAddModal(false)}> | ||||||
|  |         <Modal.Header closeButton> | ||||||
|  |           <Modal.Title>Add New Entity</Modal.Title> | ||||||
|  |         </Modal.Header> | ||||||
|  |         <Modal.Body> | ||||||
|  |         <Form> | ||||||
|  |       <div className="form-group"> | ||||||
|  |   <div className="container mt-4" style={{ width: '100%' }}> | ||||||
|  |     <div className="card p-4 shadow-sm rounded"> | ||||||
|  |       <div className="row align-items-center"> | ||||||
|  |         <div className="col-md-3"> | ||||||
|  |         </div> | ||||||
|  | <label htmlFor="name" className="form-label">name</label> | ||||||
|  |           | ||||||
|  |         <div className="col-md-9"> | ||||||
|  |           <input | ||||||
|  |             type="text" | ||||||
|  |             className="form-control" | ||||||
|  |             id="name" | ||||||
|  |             name="name" | ||||||
|  |             value={newEntity.name} | ||||||
|  |             onChange={handleChange} | ||||||
|  |             required | ||||||
|  |             style={{ | ||||||
|  |               backgroundColor: '#f7f9fc', | ||||||
|  |               border: '1px solid #ced4da', | ||||||
|  |               borderRadius: '8px', | ||||||
|  |               padding: '10px', | ||||||
|  |               transition: 'border-color 0.3s ease, box-shadow 0.3s ease', | ||||||
|  |             }} | ||||||
|  |             onFocus={(e) => { | ||||||
|  |               e.target.style.borderColor = '#007bff'; | ||||||
|  |               e.target.style.boxShadow = '0 0 8px rgba(0, 123, 255, 0.25)'; | ||||||
|  |             }} | ||||||
|  |             onBlur={(e) => { | ||||||
|  |               e.target.style.borderColor = '#ced4da'; | ||||||
|  |               e.target.style.boxShadow = 'none'; | ||||||
|  |             }} | ||||||
|  |           /> | ||||||
|  |         </div> | ||||||
|  | 
 | ||||||
|  | <div className="form-group"> | ||||||
|  |           <label htmlFor="description">Description</label> | ||||||
|  |           <textarea | ||||||
|  |             className="form-control" | ||||||
|  |             id="description" | ||||||
|  |             name="description" | ||||||
|  |             rows="3" | ||||||
|  |             value={newEntity.description} | ||||||
|  |             onChange={handleChange} | ||||||
|  |             required | ||||||
|  | style={{ | ||||||
|  |               backgroundColor: '#f7f9fc', | ||||||
|  |               border: '1px solid #ced4da', | ||||||
|  |               borderRadius: '8px', | ||||||
|  |               padding: '10px', | ||||||
|  |               transition: 'border-color 0.3s ease, box-shadow 0.3s ease', | ||||||
|  |             }} | ||||||
|  |             onFocus={(e) => { | ||||||
|  |               e.target.style.borderColor = '#007bff'; | ||||||
|  |               e.target.style.boxShadow = '0 0 8px rgba(0, 123, 255, 0.25)'; | ||||||
|  |             }} | ||||||
|  |             onBlur={(e) => { | ||||||
|  |               e.target.style.borderColor = '#ced4da'; | ||||||
|  |               e.target.style.boxShadow = 'none'; | ||||||
|  |             }} | ||||||
|  |           ></textarea> | ||||||
|  |         </div> | ||||||
|  | 
 | ||||||
|  |  </div> | ||||||
|  |     </div> | ||||||
|  |   </div> | ||||||
|  | </div> | ||||||
|  | </Form> | ||||||
|  | 
 | ||||||
|  |         </Modal.Body> | ||||||
|  |         <Modal.Footer> | ||||||
|  |           <Button variant="secondary" onClick={() => setShowAddModal(false)}> | ||||||
|  |             Close | ||||||
|  |           </Button> | ||||||
|  |           <Button variant="primary" onClick={handleAdd | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | }> | ||||||
|  |             Add Entity | ||||||
|  |           </Button> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |         </Modal.Footer> | ||||||
|  |       </Modal> | ||||||
|  |       <Modal show={showDeleteModal} onHide={() => setShowDeleteModal(false)}> | ||||||
|  |         <Modal.Header closeButton> | ||||||
|  |           <Modal.Title>Confirm Delete</Modal.Title> | ||||||
|  |         </Modal.Header> | ||||||
|  |         <Modal.Body>Are you sure you want to delete this entity?</Modal.Body> | ||||||
|  |         <Modal.Footer> | ||||||
|  |           <Button variant="secondary" onClick={() => setShowDeleteModal(false)}> | ||||||
|  |             Cancel | ||||||
|  |           </Button> | ||||||
|  |           <Button variant="danger" onClick={handleDelete}> | ||||||
|  |             Delete | ||||||
|  |           </Button> | ||||||
|  |         </Modal.Footer> | ||||||
|  |       </Modal> | ||||||
|  |     </div> | ||||||
|  |   ); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | export default EntityTable; | ||||||
| @ -0,0 +1,663 @@ | |||||||
|  | import React, { useEffect, useState , useRef } from "react"; | ||||||
|  | import QRCode from "qrcode.react"; | ||||||
|  | import Barcode from "react-barcode"; | ||||||
|  | import html2canvas from "html2canvas"; | ||||||
|  | import Select from "react-select"; | ||||||
|  | import ReCAPTCHA from "react-google-recaptcha"; | ||||||
|  | import axios from "axios"; | ||||||
|  | import { FaTrash } from "react-icons/fa"; | ||||||
|  | import { Modal, Button, Form, Pagination,Container, Row, Col, Image , ProgressBar , } from "react-bootstrap"; | ||||||
|  | import { ToastContainer, toast } from "react-toastify"; | ||||||
|  | import "react-toastify/dist/ReactToastify.css"; | ||||||
|  | import { getToken } from '../../../../utils/tokenService';import Table from "react-bootstrap/Table"; | ||||||
|  | const FILE_API_URL = `${process.env.REACT_APP_API_URL}/FileUpload/Uploadeddocs`;  | ||||||
|  | const API_URL = `${process.env.REACT_APP_API_URL}/TestA/TestA`; | ||||||
|  | const REACT_APP_API_TOKEN = localStorage.getItem("authToken") | ||||||
|  | 
 | ||||||
|  | const EntityTable = () => { | ||||||
|  |   const [data, setData] = useState([]); | ||||||
|  |   const [filteredData, setFilteredData] = useState([]); | ||||||
|  |   const [newEntity, setNewEntity] = useState({ | ||||||
|  |     name: "", | ||||||
|  | 
 | ||||||
|  |     description: "", | ||||||
|  | 
 | ||||||
|  |  child: [{  | ||||||
|  | 
 | ||||||
|  |   | ||||||
|  |     Description: "" | ||||||
|  |   | ||||||
|  | 
 | ||||||
|  |   | ||||||
|  |     Name: "" | ||||||
|  |   | ||||||
|  | 
 | ||||||
|  |  }] | ||||||
|  | 
 | ||||||
|  |   }); | ||||||
|  |   const [editEntity, setEditEntity] = useState(null); | ||||||
|  |   const [showEditModal, setShowEditModal] = useState(false); | ||||||
|  |   const [showAddModal, setShowAddModal] = useState(false); | ||||||
|  |   const [showDeleteModal, setShowDeleteModal] = useState(false); | ||||||
|  |   const [deleteEntityId, setDeleteEntityId] = useState(null); | ||||||
|  |   const [currentPage, setCurrentPage] = useState(1); | ||||||
|  |   const [itemsPerPage] = useState(5); // Adjust this value as needed
 | ||||||
|  |   const [searchQuery, setSearchQuery] = useState(""); | ||||||
|  |   const [loading, setLoading] = useState(true); | ||||||
|  |   const [options, setOptions] = useState([]); | ||||||
|  |   const [filteredOptions, setFilteredOptions] = useState([]); | ||||||
|  |   const [error, setError] = useState(null); | ||||||
|  |  const [uploadProgress, setUploadProgress] = useState(0); | ||||||
|  |  const [showModal, setShowModal] = useState(false); | ||||||
|  |   const [showValulistModal, setShowValulistModal] = useState(false); | ||||||
|  |  const barcodeRef = useRef(null); | ||||||
|  |   const [serverData, setServerData] = useState([]); | ||||||
|  |   const recaptchaRef = useRef(null); | ||||||
|  |  const editBarcodeRef = useRef(null); | ||||||
|  |   useEffect(() => { | ||||||
|  |     fetchData(); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |   }, []); | ||||||
|  | 
 | ||||||
|  |   useEffect(() => { | ||||||
|  |     handleSearch(); | ||||||
|  |   }, [searchQuery, data]); | ||||||
|  |   const fetchData = async () => { | ||||||
|  |     try { | ||||||
|  | const token = getToken(); | ||||||
|  |       const response = await axios.get(API_URL, { | ||||||
|  |         headers: { Authorization: `Bearer ${token}` }, | ||||||
|  |       }); | ||||||
|  |       setData(response.data); | ||||||
|  |     } catch (error) { | ||||||
|  |       console.error("Error fetching data:", error); | ||||||
|  |     } | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   const handleDelete = async () => { | ||||||
|  |     try { | ||||||
|  |  const token = getToken(); | ||||||
|  |       await axios.delete(`${API_URL}/${deleteEntityId}`, { | ||||||
|  |         headers: { Authorization: `Bearer ${token}` }, | ||||||
|  |       }); | ||||||
|  |       fetchData(); | ||||||
|  |       toast.success("Successfully deleted!"); | ||||||
|  |       setShowDeleteModal(false); | ||||||
|  |     } catch (error) { | ||||||
|  |       console.error("Error deleting data:", error); | ||||||
|  |     } | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   const handleAdd = async () => { | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     try { | ||||||
|  |  const token = getToken(); | ||||||
|  |       await axios.post(API_URL, newEntity, { | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |         headers: { Authorization: `Bearer ${token}` }, | ||||||
|  |       }); | ||||||
|  |       fetchData(); | ||||||
|  |       setNewEntity({ | ||||||
|  |     name: "", | ||||||
|  | 
 | ||||||
|  |     description: "", | ||||||
|  | 
 | ||||||
|  |  child: [{  | ||||||
|  | 
 | ||||||
|  |   | ||||||
|  |     Description: "" | ||||||
|  |   | ||||||
|  | 
 | ||||||
|  |   | ||||||
|  |     Name: "" | ||||||
|  |   | ||||||
|  | 
 | ||||||
|  |  }] | ||||||
|  | 
 | ||||||
|  |       }); | ||||||
|  |       setShowAddModal(false); | ||||||
|  |       toast.success("Successfully added!"); | ||||||
|  |     } catch (error) { | ||||||
|  |       console.error("Error adding data:", error); | ||||||
|  |     } | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   const handleChange = (e) => { | ||||||
|  |     const { name, value } = e.target; | ||||||
|  |     setNewEntity({ ...newEntity, [name]: value }); | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   const handleEditChange = (e) => { | ||||||
|  |     const { name, value } = e.target; | ||||||
|  |     setEditEntity({ ...editEntity, [name]: value }); | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   const handleEdit = (entity) => { | ||||||
|  |     setEditEntity(entity); | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     setShowEditModal(true); | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   const formatCurrency = (value) => { | ||||||
|  |    if (value && !value.startsWith('₹')) { | ||||||
|  |     return `₹${value}`; | ||||||
|  |   } | ||||||
|  |   return value; | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |  const addNewField = () => { | ||||||
|  |     setNewEntity((prev) => ({ | ||||||
|  |       ...prev, | ||||||
|  |       child: [...prev.child, {  | ||||||
|  | 
 | ||||||
|  |   | ||||||
|  | Description: "" | ||||||
|  |   | ||||||
|  | 
 | ||||||
|  |   | ||||||
|  | Name: "" | ||||||
|  |   | ||||||
|  |   | ||||||
|  | }], | ||||||
|  |     })); | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |   const handlesChange = (e, index = null) => { | ||||||
|  |     const { name, value } = e.target; | ||||||
|  |    | ||||||
|  |     if (index !== null) { | ||||||
|  |       const updated = [...newEntity.child]; | ||||||
|  |       updated[index] = { ...updated[index], [name]: value }; | ||||||
|  |       setNewEntity({ ...newEntity, child: updated }); | ||||||
|  |     } else { | ||||||
|  |       setNewEntity({ ...newEntity, [name]: value }); | ||||||
|  |     } | ||||||
|  |   }; | ||||||
|  | // For handling changes in the edit entity form
 | ||||||
|  | const handlesEditChange = (e, index = null) => { | ||||||
|  |   const { name, value } = e.target; | ||||||
|  | 
 | ||||||
|  |   if (index !== null) { | ||||||
|  |     const updated = [...editEntity.child]; | ||||||
|  |     updated[index] = { ...updated[index], [name]: value }; | ||||||
|  |     setEditEntity({ ...editEntity, child: updated }); | ||||||
|  |   } else { | ||||||
|  |     setEditEntity({ ...editEntity, [name]: value }); | ||||||
|  |   } | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |    const handleUpdate = async () => { | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |     try { | ||||||
|  | const token = getToken(); | ||||||
|  |       await axios.put(`${API_URL}/${editEntity.id}`, editEntity, { | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |         headers: { Authorization: `Bearer ${token}` }, | ||||||
|  |       }); | ||||||
|  |       fetchData(); | ||||||
|  |       setShowEditModal(false); | ||||||
|  |       toast.success("Successfully updated!"); | ||||||
|  |     } catch (error) { | ||||||
|  |       console.error("Error updating data:", error); | ||||||
|  |     } | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   const handleSearch = () => { | ||||||
|  |     const filtered = data.filter( | ||||||
|  |       (entity) => | ||||||
|  | 
 | ||||||
|  |       entity.name.toLowerCase().includes(searchQuery.toLowerCase()) || | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |       entity.description.toLowerCase().includes(searchQuery.toLowerCase()) || | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |       entity.child.toLowerCase().includes(searchQuery.toLowerCase())     ); | ||||||
|  |     setFilteredData(filtered); | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   const handlePageChange = (pageNumber) => { | ||||||
|  |     setCurrentPage(pageNumber); | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   const generateBarcodeImage = async (ref) => { | ||||||
|  |     if (ref.current) { | ||||||
|  |       const canvas = await html2canvas(ref.current); | ||||||
|  |       const imgData = canvas.toDataURL("image/png"); | ||||||
|  |       const link = document.createElement("a"); | ||||||
|  |       link.href = imgData; | ||||||
|  |       link.download = "barcode.png"; | ||||||
|  |       link.click(); | ||||||
|  |     } | ||||||
|  |   }; | ||||||
|  | 
 | ||||||
|  |   // Calculate items for current page
 | ||||||
|  |   const indexOfLastItem = currentPage * itemsPerPage; | ||||||
|  |   const indexOfFirstItem = indexOfLastItem - itemsPerPage; | ||||||
|  |   const currentItems = filteredData.slice(indexOfFirstItem, indexOfLastItem); | ||||||
|  | 
 | ||||||
|  |   return ( | ||||||
|  |     <div className="container mt-5"> | ||||||
|  |       <ToastContainer /> | ||||||
|  |       <h1 className="mb-4">Entity Table</h1> | ||||||
|  |       <div className="d-flex justify-content-between mb-3"> | ||||||
|  |         <Button variant="primary" onClick={() => setShowAddModal(true)}> | ||||||
|  |           Add Entity | ||||||
|  |         </Button> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |   | ||||||
|  |         <Form.Control | ||||||
|  |           type="text" | ||||||
|  |           className="w-25" | ||||||
|  |           placeholder="Search..." | ||||||
|  |           value={searchQuery} | ||||||
|  |           onChange={(e) => setSearchQuery(e.target.value)} | ||||||
|  |         /> | ||||||
|  |       </div> | ||||||
|  |       <Table striped bordered hover responsive variant="grey"> | ||||||
|  |         <thead> | ||||||
|  |           <tr> | ||||||
|  |   <th>name</th> | ||||||
|  | 
 | ||||||
|  |   <th>description</th> | ||||||
|  | 
 | ||||||
|  |   <th>child</th> | ||||||
|  | 
 | ||||||
|  | <th>Action</th> | ||||||
|  |           </tr> | ||||||
|  |         </thead> | ||||||
|  |         <tbody > | ||||||
|  |           {currentItems.map((entity) => ( | ||||||
|  |             <tr key={entity.id}> | ||||||
|  | 
 | ||||||
|  |               <td>{entity.name}</td> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |               <td>{entity.description}</td> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |   | ||||||
|  | <td>{entity.child.map(p => p.Description).join(", ")}</td> | ||||||
|  |   | ||||||
|  | 
 | ||||||
|  |   | ||||||
|  | <td>{entity.child.map(p => p.Name).join(", ")}</td> | ||||||
|  |   | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |               <td> | ||||||
|  |                 <Button | ||||||
|  |                   variant="warning" | ||||||
|  |                   size="sm" | ||||||
|  |                   className="me-2" | ||||||
|  |                   onClick={() => handleEdit(entity)} | ||||||
|  |                 > | ||||||
|  |                   Update | ||||||
|  |                 </Button> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |   	 | ||||||
|  |                 <Button | ||||||
|  |                   variant="danger" | ||||||
|  |                   size="sm" | ||||||
|  |                   onClick={() => { | ||||||
|  |                     setDeleteEntityId(entity.id); | ||||||
|  |                     setShowDeleteModal(true); | ||||||
|  |                   }} | ||||||
|  |                 > | ||||||
|  |                   Delete | ||||||
|  |                 </Button> | ||||||
|  |               </td> | ||||||
|  |             </tr> | ||||||
|  |           ))} | ||||||
|  |         </tbody> | ||||||
|  |       </Table> | ||||||
|  |       <Pagination className="d-flex justify-content-center mt-4"> | ||||||
|  |         {Array.from( | ||||||
|  |           { length: Math.ceil(filteredData.length / itemsPerPage) }, | ||||||
|  |           (_, index) => ( | ||||||
|  |             <Pagination.Item | ||||||
|  |               key={index + 1} | ||||||
|  |               active={index + 1 === currentPage} | ||||||
|  |               onClick={() => handlePageChange(index + 1)} | ||||||
|  |             > | ||||||
|  |               {index + 1} | ||||||
|  |             </Pagination.Item> | ||||||
|  |           ) | ||||||
|  |         )} | ||||||
|  |       </Pagination> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |        <Modal show={showEditModal} onHide={() => setShowEditModal(false)}> | ||||||
|  |         <Modal.Header closeButton> | ||||||
|  |           <Modal.Title>Edit Entity</Modal.Title> | ||||||
|  |         </Modal.Header> | ||||||
|  |         <Modal.Body> | ||||||
|  |           {editEntity && ( | ||||||
|  |             <Form> | ||||||
|  | <div className="form-group"> | ||||||
|  |   <div className="container mt-4" style={{ width: '100%' }}> | ||||||
|  |     <div className="card p-4 shadow-sm rounded"> | ||||||
|  |       <div className="row align-items-center"> | ||||||
|  |         <div className="col-md-3"> | ||||||
|  |         </div> | ||||||
|  | <label htmlFor="name" className="form-label">Name</label> | ||||||
|  |         | ||||||
|  |         <div className="col-md-9"> | ||||||
|  |           <input | ||||||
|  |             type="text" | ||||||
|  |             className="form-control" | ||||||
|  |             id="name" | ||||||
|  |             name="name" | ||||||
|  |             value={editEntity.name} | ||||||
|  |             onChange={handleEditChange} | ||||||
|  |             required | ||||||
|  |             style={{ | ||||||
|  |               backgroundColor: '#f7f9fc', | ||||||
|  |               border: '1px solid #ced4da', | ||||||
|  |               borderRadius: '8px', | ||||||
|  |               padding: '10px', | ||||||
|  |               transition: 'border-color 0.3s ease, box-shadow 0.3s ease', | ||||||
|  |             }} | ||||||
|  |             onFocus={(e) => { | ||||||
|  |               e.target.style.borderColor = '#007bff'; | ||||||
|  |               e.target.style.boxShadow = '0 0 8px rgba(0, 123, 255, 0.25)'; | ||||||
|  |             }} | ||||||
|  |             onBlur={(e) => { | ||||||
|  |               e.target.style.borderColor = '#ced4da'; | ||||||
|  |               e.target.style.boxShadow = 'none'; | ||||||
|  |             }} | ||||||
|  |           /> | ||||||
|  |         </div> | ||||||
|  | 
 | ||||||
|  |  <Form.Group className="mb-3"> | ||||||
|  |           <Form.Label>Description</Form.Label> | ||||||
|  |           <Form.Control | ||||||
|  |             as="textarea" | ||||||
|  |             name="description" | ||||||
|  |             value={editEntity.description} | ||||||
|  |             onChange={handleEditChange} | ||||||
|  |             rows={5} | ||||||
|  |             placeholder="Enter description" | ||||||
|  | style={{ | ||||||
|  |               backgroundColor: '#f7f9fc', | ||||||
|  |               border: '1px solid #ced4da', | ||||||
|  |               borderRadius: '8px', | ||||||
|  |               padding: '10px', | ||||||
|  |               transition: 'border-color 0.3s ease, box-shadow 0.3s ease', | ||||||
|  |             }} | ||||||
|  |             onFocus={(e) => { | ||||||
|  |               e.target.style.borderColor = '#007bff'; | ||||||
|  |               e.target.style.boxShadow = '0 0 8px rgba(0, 123, 255, 0.25)'; | ||||||
|  |             }} | ||||||
|  |             onBlur={(e) => { | ||||||
|  |               e.target.style.borderColor = '#ced4da'; | ||||||
|  |               e.target.style.boxShadow = 'none'; | ||||||
|  |             }} | ||||||
|  |           /> | ||||||
|  |         </Form.Group> | ||||||
|  | 
 | ||||||
|  |  {editEntity.child.map((p, index) => ( | ||||||
|  |               <Form.Group className="mb-3" key={index}> | ||||||
|  |                 <Form.Label>child</Form.Label> | ||||||
|  |                | ||||||
|  |   | ||||||
|  |                 <Form.Control | ||||||
|  |                   type="text" | ||||||
|  |                   name="Description" | ||||||
|  |                   value={p.Description} | ||||||
|  |                   onChange={(e) => handlesEditChange(e, index)} | ||||||
|  |                 /> | ||||||
|  |               </Form.Group> | ||||||
|  |             ))} | ||||||
|  |             <Button variant="secondary" onClick={addEditField}> | ||||||
|  |               Add Another | ||||||
|  |             </Button> | ||||||
|  |       | ||||||
|  | 
 | ||||||
|  |   | ||||||
|  |                 <Form.Control | ||||||
|  |                   type="text" | ||||||
|  |                   name="Name" | ||||||
|  |                   value={p.Name} | ||||||
|  |                   onChange={(e) => handlesEditChange(e, index)} | ||||||
|  |                 /> | ||||||
|  |               </Form.Group> | ||||||
|  |             ))} | ||||||
|  |             <Button variant="secondary" onClick={addEditField}> | ||||||
|  |               Add Another | ||||||
|  |             </Button> | ||||||
|  |       | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |      | ||||||
|  |       </div> | ||||||
|  |     </div> | ||||||
|  |   </div> | ||||||
|  | </div> | ||||||
|  |           </Form> | ||||||
|  |            | ||||||
|  |           )} | ||||||
|  |         </Modal.Body> | ||||||
|  |         <Modal.Footer> | ||||||
|  |           <Button variant="secondary" onClick={() => setShowEditModal(false)}> | ||||||
|  |             Close | ||||||
|  |           </Button> | ||||||
|  |           <Button variant="primary" onClick={handleUpdate}> | ||||||
|  |             Save changes | ||||||
|  |           </Button> | ||||||
|  |         </Modal.Footer> | ||||||
|  |       </Modal> | ||||||
|  |       <Modal show={showAddModal} onHide={() => setShowAddModal(false)}> | ||||||
|  |         <Modal.Header closeButton> | ||||||
|  |           <Modal.Title>Add New Entity</Modal.Title> | ||||||
|  |         </Modal.Header> | ||||||
|  |         <Modal.Body> | ||||||
|  |         <Form> | ||||||
|  |       <div className="form-group"> | ||||||
|  |   <div className="container mt-4" style={{ width: '100%' }}> | ||||||
|  |     <div className="card p-4 shadow-sm rounded"> | ||||||
|  |       <div className="row align-items-center"> | ||||||
|  |         <div className="col-md-3"> | ||||||
|  |         </div> | ||||||
|  | <label htmlFor="name" className="form-label">name</label> | ||||||
|  |           | ||||||
|  |         <div className="col-md-9"> | ||||||
|  |           <input | ||||||
|  |             type="text" | ||||||
|  |             className="form-control" | ||||||
|  |             id="name" | ||||||
|  |             name="name" | ||||||
|  |             value={newEntity.name} | ||||||
|  |             onChange={handleChange} | ||||||
|  |             required | ||||||
|  |             style={{ | ||||||
|  |               backgroundColor: '#f7f9fc', | ||||||
|  |               border: '1px solid #ced4da', | ||||||
|  |               borderRadius: '8px', | ||||||
|  |               padding: '10px', | ||||||
|  |               transition: 'border-color 0.3s ease, box-shadow 0.3s ease', | ||||||
|  |             }} | ||||||
|  |             onFocus={(e) => { | ||||||
|  |               e.target.style.borderColor = '#007bff'; | ||||||
|  |               e.target.style.boxShadow = '0 0 8px rgba(0, 123, 255, 0.25)'; | ||||||
|  |             }} | ||||||
|  |             onBlur={(e) => { | ||||||
|  |               e.target.style.borderColor = '#ced4da'; | ||||||
|  |               e.target.style.boxShadow = 'none'; | ||||||
|  |             }} | ||||||
|  |           /> | ||||||
|  |         </div> | ||||||
|  | 
 | ||||||
|  | <div className="form-group"> | ||||||
|  |           <label htmlFor="description">Description</label> | ||||||
|  |           <textarea | ||||||
|  |             className="form-control" | ||||||
|  |             id="description" | ||||||
|  |             name="description" | ||||||
|  |             rows="3" | ||||||
|  |             value={newEntity.description} | ||||||
|  |             onChange={handleChange} | ||||||
|  |             required | ||||||
|  | style={{ | ||||||
|  |               backgroundColor: '#f7f9fc', | ||||||
|  |               border: '1px solid #ced4da', | ||||||
|  |               borderRadius: '8px', | ||||||
|  |               padding: '10px', | ||||||
|  |               transition: 'border-color 0.3s ease, box-shadow 0.3s ease', | ||||||
|  |             }} | ||||||
|  |             onFocus={(e) => { | ||||||
|  |               e.target.style.borderColor = '#007bff'; | ||||||
|  |               e.target.style.boxShadow = '0 0 8px rgba(0, 123, 255, 0.25)'; | ||||||
|  |             }} | ||||||
|  |             onBlur={(e) => { | ||||||
|  |               e.target.style.borderColor = '#ced4da'; | ||||||
|  |               e.target.style.boxShadow = 'none'; | ||||||
|  |             }} | ||||||
|  |           ></textarea> | ||||||
|  |         </div> | ||||||
|  | 
 | ||||||
|  |  {newEntity.child.map((p, index) => ( | ||||||
|  |               <Form.Group className="mb-3" key={index}> | ||||||
|  |                 <Form.Label>child</Form.Label> | ||||||
|  |                | ||||||
|  |   | ||||||
|  |                 <Form.Control | ||||||
|  |                   type="text" | ||||||
|  |                   name="Description" | ||||||
|  |                   value={p.Description} | ||||||
|  |                   onChange={(e) => handlesChange(e, index)} | ||||||
|  |                 /> | ||||||
|  |               </Form.Group> | ||||||
|  |             ))} | ||||||
|  |             <Button variant="secondary" onClick={addNewField}> | ||||||
|  |               Add Another | ||||||
|  |             </Button> | ||||||
|  |       | ||||||
|  | 
 | ||||||
|  |   | ||||||
|  |                 <Form.Control | ||||||
|  |                   type="text" | ||||||
|  |                   name="Name" | ||||||
|  |                   value={p.Name} | ||||||
|  |                   onChange={(e) => handlesChange(e, index)} | ||||||
|  |                 /> | ||||||
|  |               </Form.Group> | ||||||
|  |             ))} | ||||||
|  |             <Button variant="secondary" onClick={addNewField}> | ||||||
|  |               Add Another | ||||||
|  |             </Button> | ||||||
|  |       | ||||||
|  | 
 | ||||||
|  |           | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |  </div> | ||||||
|  |     </div> | ||||||
|  |   </div> | ||||||
|  | </div> | ||||||
|  | </Form> | ||||||
|  | 
 | ||||||
|  |         </Modal.Body> | ||||||
|  |         <Modal.Footer> | ||||||
|  |           <Button variant="secondary" onClick={() => setShowAddModal(false)}> | ||||||
|  |             Close | ||||||
|  |           </Button> | ||||||
|  |           <Button variant="primary" onClick={handleAdd | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | }> | ||||||
|  |             Add Entity | ||||||
|  |           </Button> | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  | 
 | ||||||
|  |         </Modal.Footer> | ||||||
|  |       </Modal> | ||||||
|  |       <Modal show={showDeleteModal} onHide={() => setShowDeleteModal(false)}> | ||||||
|  |         <Modal.Header closeButton> | ||||||
|  |           <Modal.Title>Confirm Delete</Modal.Title> | ||||||
|  |         </Modal.Header> | ||||||
|  |         <Modal.Body>Are you sure you want to delete this entity?</Modal.Body> | ||||||
|  |         <Modal.Footer> | ||||||
|  |           <Button variant="secondary" onClick={() => setShowDeleteModal(false)}> | ||||||
|  |             Cancel | ||||||
|  |           </Button> | ||||||
|  |           <Button variant="danger" onClick={handleDelete}> | ||||||
|  |             Delete | ||||||
|  |           </Button> | ||||||
|  |         </Modal.Footer> | ||||||
|  |       </Modal> | ||||||
|  |     </div> | ||||||
|  |   ); | ||||||
|  | }; | ||||||
|  | 
 | ||||||
|  | export default EntityTable; | ||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user