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)=>{
const response = await fetch(`${process.env.REACT_APP_API_URL}/project-list-search`);
const projectListData = await response.json()
return projectListData;
}
// export const usePostSearchListData = (searchBy: any) => {
// return useQuery(
// {
// queryKey: ['search-project-list', searchBy],
// queryFn: () => postSearchList(searchBy)
// }
// );
// };
export const usepostSearchListtData = (searchBy: any) => {
return useQuery(
{
queryKey: ['search-project-list', searchBy],
queryFn: () => postSearchList(searchBy)
}
import axios from "axios";
export const postSearchList = async (data: any)=> {
const { data: response } = await axios.post(
`${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 React, { useState } from "react";
import React, { useEffect, useState } from "react";
import { postSearchList, } from "../../APIs/SearchAPIs/postSearchList";
export default function Search() {
const [searchText, setSearchText] = useState('');
const [advandeFilterData, setAdvandeFilterData] = useState({});
useEffect(()=>{
postSearchList(advandeFilterData)
},[advandeFilterData])
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 = () => {
@ -15,7 +31,6 @@ export default function Search(){
};
const handleAdvancedFilter = () => {
// Implement your advanced filter logic here
console.log('Advanced Filter');
};
@ -25,30 +40,30 @@ export default function Search(){
<Grid container spacing={2} sx={{ bgcolor: '#181818' }} justifyContent="center">
<Grid item xs={12}>
<TextField
placeholder="Search"
placeholder="Search By Project Title, Asset Title, Artist, Track Grid, ISRC"
variant="outlined"
value={searchText}
onChange={(e) => setSearchText(e.target.value)}
sx={{
width: '50%',
'& label.Mui-focused': {
color: 'white', // Label color when focused
color: 'white',
},
'& .MuiOutlinedInput-root': {
'& fieldset': {
borderColor: 'white', // Border color
borderColor: 'white',
},
'&:hover fieldset': {
borderColor: 'white', // Border color on hover
borderColor: 'white',
},
'&.Mui-focused fieldset': {
borderColor: 'white', // Border color when focused
borderColor: 'white',
},
},
'& input': {
color: 'white', // Input text color
color: 'white',
},
marginTop:2
marginTop:2,
}}
/>
</Grid>