RQ changes
This commit is contained in:
parent
a663f5276c
commit
22b6745de0
@ -1,7 +1,14 @@
|
|||||||
import {useQuery, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
|
import {useQuery, UseQueryOptions, UseQueryResult } from '@tanstack/react-query';
|
||||||
|
|
||||||
export const getLinkedProjectListCopy = async(searchBy:any)=>{
|
export const getLinkedProjectListCopy = async(searchBy:any)=>{
|
||||||
|
try {
|
||||||
const response = await fetch(`http://localhost:8080/SonyMusicRights/linked-project?searchBy=${searchBy}`);
|
const response = await fetch(`http://localhost:8080/SonyMusicRights/linked-project?searchBy=${searchBy}`);
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error(`HTTP error! Status: ${response.status}`);
|
||||||
|
}
|
||||||
const projectListData = await response.json()
|
const projectListData = await response.json()
|
||||||
return projectListData;
|
return projectListData;
|
||||||
|
}catch(error){
|
||||||
|
console.error('Error fetching data:', error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,20 +0,0 @@
|
|||||||
import {useQuery} from '@tanstack/react-query'
|
|
||||||
|
|
||||||
|
|
||||||
export const getProjectList = async()=>{
|
|
||||||
const response = await fetch('http://localhost:8080/SonyMusicRights/project-list?searchBy=');
|
|
||||||
if (!response.ok) {
|
|
||||||
throw new Error('Failed to get project list data');
|
|
||||||
}
|
|
||||||
const projectListData = await response.json()
|
|
||||||
return projectListData;
|
|
||||||
}
|
|
||||||
|
|
||||||
export const useGetProjectData = () => {
|
|
||||||
return useQuery(
|
|
||||||
{
|
|
||||||
queryKey: ['Project-list'],
|
|
||||||
queryFn: getProjectList,
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
40
src/APIs/getProjectRQ.tsx
Normal file
40
src/APIs/getProjectRQ.tsx
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/* import {useQuery} from '@tanstack/react-query'
|
||||||
|
|
||||||
|
|
||||||
|
export const getProjectList = async()=>{
|
||||||
|
const response = await fetch('http://localhost:8080/SonyMusicRights/project-list?searchBy=');
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Failed to get project list data');
|
||||||
|
}
|
||||||
|
const projectListData = await response.json()
|
||||||
|
return projectListData;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useGetProjectData = () => {
|
||||||
|
return useQuery(
|
||||||
|
{
|
||||||
|
queryKey: ['Project-list'],
|
||||||
|
queryFn: getProjectList,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
} */
|
||||||
|
|
||||||
|
import {useQuery} from '@tanstack/react-query'
|
||||||
|
|
||||||
|
export const getProjectListRQ = async(searchBy: any)=>{
|
||||||
|
const response = await fetch(`http://localhost:8080/SonyMusicRights/project-list?searchBy=${searchBy}`);
|
||||||
|
if (!response.ok) {
|
||||||
|
throw new Error('Failed to get project list data');
|
||||||
|
}
|
||||||
|
const projectListData = await response.json()
|
||||||
|
return projectListData;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const useGetProjectDataRQ = (searchBy:any) => {
|
||||||
|
return useQuery(
|
||||||
|
{
|
||||||
|
queryKey: ['Project-list', searchBy],
|
||||||
|
queryFn: () => getProjectListRQ(searchBy),
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -1,6 +1,6 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import ProjectList from "./ProjectsList";
|
import ProjectList from "./ProjectsList";
|
||||||
import { useGetProjectData } from "../../APIs/getProject";
|
import { useGetProjectDataRQ } from "../../APIs/getProjectRQ";
|
||||||
import { getProjectListCopy } from "../../APIs/ProjectScreenAPIs/getProject";
|
import { getProjectListCopy } from "../../APIs/ProjectScreenAPIs/getProject";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useEffect } from "react";
|
import { useEffect } from "react";
|
||||||
@ -10,10 +10,10 @@ import { getPublishedProjects } from "../../APIs/ProjectScreenAPIs/getPublishedP
|
|||||||
import { getUnlinkedProjects } from "../../APIs/ProjectScreenAPIs/getUnlinkedProject";
|
import { getUnlinkedProjects } from "../../APIs/ProjectScreenAPIs/getUnlinkedProject";
|
||||||
|
|
||||||
export default function Projects(){
|
export default function Projects(){
|
||||||
const { data: getProjectDataList, isLoading, isError } = useGetProjectData();
|
|
||||||
const [selectedContractFilter, setSelectedContractFilter] = useState<any>('All');
|
const [selectedContractFilter, setSelectedContractFilter] = useState<any>('All');
|
||||||
const [ContractFilterResponseData, setContractFilterResponseData] = useState<any>();
|
const [ContractFilterResponseData, setContractFilterResponseData] = useState<any>();
|
||||||
const [searchByFilter, setSearchByFilter] = useState('');
|
const [searchByFilter, setSearchByFilter] = useState('');
|
||||||
|
const { data: getProjectDataList, isLoading, isError } = useGetProjectDataRQ(searchByFilter);
|
||||||
|
|
||||||
useEffect(()=>{
|
useEffect(()=>{
|
||||||
if(selectedContractFilter=='All'){
|
if(selectedContractFilter=='All'){
|
||||||
@ -30,11 +30,10 @@ export default function Projects(){
|
|||||||
}
|
}
|
||||||
},[selectedContractFilter,searchByFilter])
|
},[selectedContractFilter,searchByFilter])
|
||||||
|
|
||||||
// console.log(ContractFilterResponseData,"sdkhhskdjgh",selectedContractFilter)
|
|
||||||
|
|
||||||
if (isLoading) {
|
if (isLoading) {
|
||||||
return <h2>Loading...</h2>
|
return <div>Loading...</div>;
|
||||||
}
|
}
|
||||||
|
console.log(ContractFilterResponseData,getProjectDataList,"sdkhhskdjgh",selectedContractFilter)
|
||||||
|
|
||||||
return(
|
return(
|
||||||
<>
|
<>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user