-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
은지
committed
Mar 14, 2024
1 parent
78286d5
commit 4bcf74c
Showing
14 changed files
with
760 additions
and
151 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
import { MutationOptions, useMutation, useQuery } from 'react-query'; | ||
import { instance } from '../axios'; | ||
|
||
const router = '/banners'; | ||
|
||
export const useCreateBanners = ( | ||
banner_url: string, | ||
banner_type: string, | ||
start_date: string, | ||
end_date: string, | ||
options: MutationOptions | ||
) => { | ||
const data = { | ||
banner_url, | ||
banner_type, | ||
start_date, | ||
end_date, | ||
}; | ||
return useMutation(async () => instance.post(`${router}`, data), { | ||
...options, | ||
}); | ||
}; | ||
|
||
export const useGetBannerList = ( | ||
is_opened: boolean, | ||
options: MutationOptions | ||
) => { | ||
const params = { | ||
is_opened, | ||
}; | ||
return useMutation( | ||
async () => | ||
instance.get(`${router}/teacher`, { | ||
params: params, | ||
}), | ||
{ | ||
...options, | ||
} | ||
); | ||
}; | ||
|
||
export const useDeleteBanner = ( | ||
banner_id: number, | ||
options: MutationOptions | ||
) => { | ||
return useMutation( | ||
async () => { | ||
const { data } = await instance.delete(`${router}/${banner_id}`); | ||
return data; | ||
}, | ||
{ | ||
...options, | ||
} | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
export interface DateProps { | ||
banner_url: string; | ||
start_date: string; | ||
end_date: string; | ||
banner_type: string; | ||
} | ||
|
||
export interface BannerProps { | ||
banner_id: number; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export interface BannerListProps { | ||
banner_id: number; | ||
banner_url: string; | ||
start_date: string; | ||
end_date: string; | ||
banner_type: string; | ||
} | ||
|
||
export interface BannerListResponse { | ||
banners: BannerListProps[]; | ||
} | ||
|
||
export interface BannerNameType { | ||
RECRUITMENT: string; | ||
BOOKMARK: string; | ||
NONE: string; | ||
INTERNSHIP: string; | ||
COMPANY: string; | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,73 @@ | ||
import * as _ from './style'; | ||
import banner from '../../../Assets/PNG/banner.png'; | ||
import { useEffect, useState } from 'react'; | ||
import { useGetBannerList } from '../../../Apis/Banners'; | ||
import { BannerListProps } from '../../../Apis/Banners/response'; | ||
import { BannerNameType } from '../../../Apis/Banners/response'; | ||
import deleteimg from '../../../Assets/SVG/delete.svg'; | ||
interface Props { | ||
onDelete: (id: number) => void; | ||
} | ||
|
||
export function BannerDetail({ onDelete }: Props) { | ||
const [banners, setBanners] = useState<BannerListProps[]>([]); | ||
const [isOpen, setIsOpen] = useState<boolean>(true); | ||
|
||
const BannersAPI = useGetBannerList(isOpen, { | ||
onSuccess: (data: any) => { | ||
setBanners(data.data.banners); | ||
}, | ||
onError: () => {}, | ||
}); | ||
console.log(BannersAPI); | ||
|
||
useEffect(() => { | ||
if (isOpen) BannersAPI.mutate(); | ||
}, [isOpen]); | ||
|
||
const BannerType = { | ||
RECRUITMENT: '모집의뢰서', | ||
BOOKMARK: '북마크', | ||
NONE: '페이지 이동 안함', | ||
INTERNSHIP: '체험형 현장실습 페이지', | ||
COMPANY: '기업 상세 페이지', | ||
}; | ||
|
||
Object.freeze(BannerType); | ||
|
||
export function BannerDetail() { | ||
return ( | ||
<_.Container> | ||
<_.BannerImg src={banner} /> | ||
<_.Wrapper> | ||
<_.TextWrapper> | ||
<_.Text>이동 되는 페이지</_.Text> | ||
<_.TextContent>체험형 현장실습</_.TextContent> | ||
</_.TextWrapper> | ||
<_.TextWrapper> | ||
<_.Text>표시 기간</_.Text> | ||
<_.TextContent> | ||
2024년 2월 24일 ~ 2024년 2월 27일 | ||
</_.TextContent> | ||
</_.TextWrapper> | ||
</_.Wrapper> | ||
{banners && | ||
banners.length > 0 && | ||
banners.map((banner, index) => ( | ||
<_.BannerDetails key={index}> | ||
<_.BannerImg src={banner.banner_url} /> | ||
<_.DeleteBackground | ||
onClick={() => { | ||
onDelete(banner.banner_id); | ||
}} | ||
> | ||
<_.deleteImg src={deleteimg} /> | ||
</_.DeleteBackground> | ||
<_.Wrapper> | ||
<_.TextWrapper> | ||
<_.Text>이동 되는 페이지</_.Text> | ||
<_.TextContent> | ||
{ | ||
BannerType[ | ||
banner.banner_type as keyof BannerNameType | ||
] | ||
} | ||
</_.TextContent> | ||
</_.TextWrapper> | ||
<_.TextWrapper> | ||
<_.Text>표시 기간</_.Text> | ||
<_.TextContent> | ||
{banner.start_date} ~ {banner.end_date} | ||
</_.TextContent> | ||
</_.TextWrapper> | ||
</_.Wrapper> | ||
</_.BannerDetails> | ||
))} | ||
</_.Container> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.