advanced filter post api

This commit is contained in:
Sonika 2024-01-02 12:49:50 +05:30
parent aee30f0c6b
commit 0b78d804f3
2 changed files with 61 additions and 26 deletions

View File

@ -1,16 +1,36 @@
import {useQuery} from '@tanstack/react-query'; // import {useQuery} from '@tanstack/react-query';
// type props={
// artist:string,
// asset_type:number,
// genre:string,
// language:string,
// mood:string,
// rights:number,
// searchByValue:string,
// territory:string,
// validity:number,
// }
// export const postSearchList = async({artist,asset_type,genre,language,mood,rights,searchByValue,territory,validity,}:props)=>{
// const response = await fetch(`${process.env.REACT_APP_API_URL}/project-list-search`);
// const projectListData = await response.json()
// return projectListData;
// }
export const postSearchList = async(searchBy:any)=>{ // export const usePostSearchListData = (searchBy: any) => {
const response = await fetch(`${process.env.REACT_APP_API_URL}/project-list-search`); // return useQuery(
const projectListData = await response.json() // {
return projectListData; // queryKey: ['search-project-list', searchBy],
} // queryFn: () => postSearchList(searchBy)
// }
// );
// };
export const usepostSearchListtData = (searchBy: any) => { import axios from "axios";
return useQuery(
{ export const postSearchList = async (data: any)=> {
queryKey: ['search-project-list', searchBy], const { data: response } = await axios.post(
queryFn: () => postSearchList(searchBy) `${process.env.REACT_APP_API_URL}/add-user`,
} data
); );
}; return await response.data;
};

View File

@ -1,13 +1,29 @@
import { Button, Grid, Paper, TextField } from "@mui/material"; import { Button, Grid, Paper, TextField } from "@mui/material";
import React, { useState } from "react"; import React, { useEffect, useState } from "react";
import { postSearchList, } from "../../APIs/SearchAPIs/postSearchList";
export default function Search(){
export default function Search() {
const [searchText, setSearchText] = useState(''); const [searchText, setSearchText] = useState('');
const [advandeFilterData, setAdvandeFilterData] = useState({});
useEffect(()=>{
postSearchList(advandeFilterData)
},[advandeFilterData])
const handleSearch = () => { const handleSearch = () => {
// Implement your search logic here using searchText
console.log('Search:', searchText); setAdvandeFilterData({
searchText,
rights: 0,
asset_type: 0,
territory: '',
genre: '',
language: '',
mood: '',
validity: 0,
artist: ''
});
}; };
const handleClear = () => { const handleClear = () => {
@ -15,7 +31,6 @@ export default function Search(){
}; };
const handleAdvancedFilter = () => { const handleAdvancedFilter = () => {
// Implement your advanced filter logic here
console.log('Advanced Filter'); console.log('Advanced Filter');
}; };
@ -25,30 +40,30 @@ export default function Search(){
<Grid container spacing={2} sx={{ bgcolor: '#181818' }} justifyContent="center"> <Grid container spacing={2} sx={{ bgcolor: '#181818' }} justifyContent="center">
<Grid item xs={12}> <Grid item xs={12}>
<TextField <TextField
placeholder="Search" placeholder="Search By Project Title, Asset Title, Artist, Track Grid, ISRC"
variant="outlined" variant="outlined"
value={searchText} value={searchText}
onChange={(e) => setSearchText(e.target.value)} onChange={(e) => setSearchText(e.target.value)}
sx={{ sx={{
width: '50%', width: '50%',
'& label.Mui-focused': { '& label.Mui-focused': {
color: 'white', // Label color when focused color: 'white',
}, },
'& .MuiOutlinedInput-root': { '& .MuiOutlinedInput-root': {
'& fieldset': { '& fieldset': {
borderColor: 'white', // Border color borderColor: 'white',
}, },
'&:hover fieldset': { '&:hover fieldset': {
borderColor: 'white', // Border color on hover borderColor: 'white',
}, },
'&.Mui-focused fieldset': { '&.Mui-focused fieldset': {
borderColor: 'white', // Border color when focused borderColor: 'white',
}, },
}, },
'& input': { '& input': {
color: 'white', // Input text color color: 'white',
}, },
marginTop:2 marginTop:2,
}} }}
/> />
</Grid> </Grid>