Skip to content

Commit

Permalink
Merge pull request #305 from kmin-jeong/feat/answer
Browse files Browse the repository at this point in the history
기업관리 유지보수
  • Loading branch information
kmin-jeong authored May 10, 2024
2 parents 5dec22b + 33facee commit d1ff151
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions src/components/ui/adminSelection/companySelection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default function CompanySelection() {
const [selectedCompany, setSelectedCompany] = useState(null);
const [currentPage, setCurrentPage] = useState(0);
const [totalPages, setTotalPages] = useState(0);
const [companyType, setcompanyType] = useState('');
const [companyStatus, setCompanyStatus] = useState('');
const [selectedCity, setSelectedCity] = useState('');
const [selectedDistrictOptions, setSelectedDistrictOptions] = useState<
Expand Down Expand Up @@ -76,6 +77,9 @@ export default function CompanySelection() {
criterion: 'createdAt',
});

if (companyType) {
queryParams.set('type', companyType);
}
if (companyStatus) {
queryParams.set('companyStatus', companyStatus);
}
Expand All @@ -86,8 +90,8 @@ export default function CompanySelection() {
queryParams.set('district', selectedDistrict);
}

const url = `${BASE_URL}/api/company/admin?${queryParams.toString()}`;
fetch(url, {
const item = `${BASE_URL}/api/company/admin/count?${queryParams.toString()}`;
fetch(item, {
headers: {
Authorization: `Bearer ${localStorage.getItem(ACCESS_TOKEN)}`,
'Content-Type': 'application/json',
Expand All @@ -99,6 +103,23 @@ export default function CompanySelection() {
setCompanies(data.data.companies);
setTotalPages(data.data.totalPages);
seTtotalCompanyCount(data.data.totalElements);
})
.catch((error) => {
console.error('Error:', error);
setIsLoading(false);
});

const url = `${BASE_URL}/api/company/admin?${queryParams.toString()}`;
fetch(url, {
headers: {
Authorization: `Bearer ${localStorage.getItem(ACCESS_TOKEN)}`,
'Content-Type': 'application/json',
},
})
.then((response) => response.json())
.then((data: ApiResponse) => {
console.log(data);
setCompanies(data.data.companies);
setIsLoading(false);
})
.catch((error) => {
Expand Down Expand Up @@ -152,7 +173,11 @@ export default function CompanySelection() {
<div className="ad-searchOption">
<div className="ad-searchOption-item">
<span className="ad-searchOption-title">기업 업종</span>
<select className="ad-searchOption-select">
<select
className="ad-searchOption-select"
value={companyType}
onChange={(e) => setcompanyType(e.target.value)}
>
<option value=""></option>
{type.map((companyType, index) => (
<option key={index} value={companyType}>
Expand Down Expand Up @@ -215,7 +240,10 @@ export default function CompanySelection() {
<Button
variant="admin-white"
onClick={() => {
setcompanyType('');
setCompanyStatus('');
setSelectedDistrict('');
setSelectedCity('');
setCurrentPage(0);
}}
>
Expand Down

0 comments on commit d1ff151

Please sign in to comment.