-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[feature]: Support publish company notice
- Loading branch information
Showing
18 changed files
with
470 additions
and
20 deletions.
There are no files selected for viewing
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
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
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,11 @@ | ||
import { | ||
IGetCompanyNoticeResp, | ||
IUpdateCompanyNoticeReq, | ||
IBaseRes | ||
} from '../common.d'; | ||
|
||
export interface IGetCompanyNoticeReturn extends IGetCompanyNoticeResp {} | ||
|
||
export interface IUpdateCompanyNoticeParams extends IUpdateCompanyNoticeReq {} | ||
|
||
export interface IUpdateCompanyNoticeReturn extends IBaseRes {} |
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,37 @@ | ||
/* tslint:disable no-identical-functions */ | ||
/* tslint:disable no-useless-cast */ | ||
/* tslint:disable no-unnecessary-type-assertion */ | ||
/* tslint:disable no-big-function */ | ||
/* tslint:disable no-duplicate-string */ | ||
import ServiceBase from '../Service.base'; | ||
import { AxiosRequestConfig } from 'axios'; | ||
|
||
import { | ||
IGetCompanyNoticeReturn, | ||
IUpdateCompanyNoticeParams, | ||
IUpdateCompanyNoticeReturn | ||
} from './index.d'; | ||
|
||
class CompanyNoticeService extends ServiceBase { | ||
public getCompanyNotice(options?: AxiosRequestConfig) { | ||
return this.get<IGetCompanyNoticeReturn>( | ||
'/v1/company_notice', | ||
undefined, | ||
options | ||
); | ||
} | ||
|
||
public updateCompanyNotice( | ||
params: IUpdateCompanyNoticeParams, | ||
options?: AxiosRequestConfig | ||
) { | ||
const paramsData = this.cloneDeep(params); | ||
return this.patch<IUpdateCompanyNoticeReturn>( | ||
'/v1/company_notice', | ||
paramsData, | ||
options | ||
); | ||
} | ||
} | ||
|
||
export default new CompanyNoticeService(); |
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
53 changes: 53 additions & 0 deletions
53
src/components/Nav/Header/Component/CompanyNoticeTrigger.tsx
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,53 @@ | ||
import { useDispatch } from 'react-redux'; | ||
import { NotificationOutlined } from '@ant-design/icons'; | ||
import { updateNavModalStatus } from '../../../../store/nav'; | ||
import { ModalName } from '../../../../data/ModalName'; | ||
import { useRequest } from 'ahooks'; | ||
import companyNotice from '../../../../api/companyNotice'; | ||
import StorageKey from '../../../../data/StorageKey'; | ||
import { | ||
ResponseCode, | ||
CompanyNoticeDisplayStatusEnum, | ||
} from '../../../../data/common'; | ||
import LocalStorageWrapper from '../../../../utils/LocalStorageWrapper'; | ||
|
||
const CompanyNoticeTrigger: React.FC = () => { | ||
const dispatch = useDispatch(); | ||
|
||
useRequest( | ||
() => | ||
companyNotice.getCompanyNotice().then((res) => { | ||
if (res.data.code === ResponseCode.SUCCESS) { | ||
if (res.data.data?.notice_str) { | ||
dispatch( | ||
updateNavModalStatus({ | ||
modalName: ModalName.Company_Notice, | ||
status: true, | ||
}) | ||
); | ||
} | ||
} | ||
}), | ||
{ | ||
ready: | ||
LocalStorageWrapper.get(StorageKey.SHOW_COMPANY_NOTICE) === | ||
CompanyNoticeDisplayStatusEnum.NotDisplayed, | ||
} | ||
); | ||
|
||
return ( | ||
<NotificationOutlined | ||
className="header-notification-icon" | ||
onClick={() => { | ||
dispatch( | ||
updateNavModalStatus({ | ||
modalName: ModalName.Company_Notice, | ||
status: true, | ||
}) | ||
); | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
export default CompanyNoticeTrigger; |
Oops, something went wrong.