diff --git a/package.json b/package.json index 9bc0a3f..47bf7b7 100755 --- a/package.json +++ b/package.json @@ -75,7 +75,9 @@ "remark-gfm": "^3.0.1", "slick-carousel": "^1.8.1", "stylis-plugin-rtl": "^2.1.1", - "typescript": "^4.5.5", + "sweetalert2": "^11.4.4", + "sweetalert2-react-content": "^4.2.0", + "typescript": "4.4.4", "uuid": "^8.3.2", "web-vitals": "^2.1.4", "yup": "^0.32.11" diff --git a/src/App.js b/src/App.js index 7166f4e..dc59fb9 100755 --- a/src/App.js +++ b/src/App.js @@ -9,10 +9,7 @@ import Snackbar from 'ui-component/extended/Snackbar'; import ThemeCustomization from 'themes'; // auth provider -import { FirebaseProvider as AuthProvider } from 'contexts/FirebaseContext'; -// import { AWSCognitoProvider as AuthProvider } from 'contexts/AWSCognitoContext'; -// import { JWTProvider as AuthProvider } from 'contexts/JWTContext'; -// import { Auth0Provider as AuthProvider } from 'contexts/Auth0Context'; +import { JWTProvider as AuthProvider } from 'contexts/JWTContext'; // ==============================|| APP ||============================== // diff --git a/src/apis/ApiService.js b/src/apis/ApiService.js new file mode 100644 index 0000000..68b759a --- /dev/null +++ b/src/apis/ApiService.js @@ -0,0 +1,133 @@ +import axios, { AxiosInstance, AxiosInterceptorManager, AxiosRequestConfig, AxiosResponse } from 'axios'; +import Swal from 'sweetalert2'; + +type CustomResponseFormat = { + response: T; // e; + refreshedToken?: string; +}; + +export interface CustomInstance extends AxiosInstance { + interceptors: { + request: AxiosInterceptorManager; + response: AxiosInterceptorManager>; + }; + + getUri(config?: AxiosRequestConfig): string; + + request(config: AxiosRequestConfig): Promise; + + get(url: string, config?: AxiosRequestConfig): Promise; + + delete(url: string, config?: AxiosRequestConfig): Promise; + + head(url: string, config?: AxiosRequestConfig): Promise; + + options(url: string, config?: AxiosRequestConfig): Promise; + + post(url: string, data?: any, config?: AxiosRequestConfig): Promise; + + put(url: string, data?: any, config?: AxiosRequestConfig): Promise; + + patch(url: string, data?: any, config?: AxiosRequestConfig): Promise; +} + +const reqApi: CustomInstance = axios.create({ + baseURL: process.env.NODE_ENV === 'development' ? process.env.REACT_APP_API_URL : '', + withCredentials: process.env.NODE_ENV === 'development', // 개발시만 사용 : crossdomain + timeout: 1000 + // headers: { + // 'Content-Type': 'application/json' + // // AUTH_HEADER_NAME: accessToken + // } + // params: {key: key} +}); + +/** + * before axios request + */ +reqApi.interceptors.request.use( + (config) => { + Swal.fire({ + title: 'Please Wait ...', + // html: '', + // imageUrl: + // timer: 10000, + didOpen: () => Swal.showLoading() + }).then((r) => {}); + return config; + }, + ({ config, request, response, ...error }) => { + console.error('========== ApiService.request error Data =========='); + return alertError(config, request, response, error); + } +); + +/** + * after axios response + */ +reqApi.interceptors.response.use( + (response: AxiosResponse) => { + Swal.close(); + if (!response.data.success) { + Swal.fire({ + icon: 'error', + title: 'Api Error', + html: `${response.data.message}`, + // imageUrl: + timer: 5000 + }).then((r) => {}); + console.log(response); + } + return Promise.resolve(response.data); + }, + ({ config, request, response, ...error }) => { + console.error('========== ApiService.response Error Data =========='); + alertError(config, request, response, error); + // error 데이타 return + // return response.data; + return error; + } +); + +/** + * 에러 처리 + * TODO :: 토큰 에러인 경우 업무 정의에 따라 alert 처리 여부등 결정하여 내용 추가 + * @param config + * @param request + * @param response + * @param error + */ +const alertError = (config: AxiosRequestConfig, request: any, response: AxiosResponse, error: Error) => { + if (!response) { + Swal.fire({ + icon: 'error', + title: 'Api Error', + html: `시스템 에러~~~~~~~~~~~~`, + // imageUrl: + timer: 5000 + }).then((r) => {}); + return; + } + + const errCode = response.data.code; + const errMsg = response.data.error; + console.error(`${errCode}: ${errMsg}`); + console.error('================================='); + + // Alert.error(`${errCode}: ${errMsg}`); + Swal.fire({ + icon: 'error', + title: 'Api Error', + html: `${errCode}: ${errMsg}`, + // imageUrl: + timer: 5000 + }).then((r) => {}); + + // return Promise.reject({ + // config, + // //message: errMsg, + // response, + // ...error + // }) +}; +export default reqApi; diff --git a/src/apis/AuthService.js b/src/apis/AuthService.js new file mode 100644 index 0000000..a251b66 --- /dev/null +++ b/src/apis/AuthService.js @@ -0,0 +1,16 @@ +import { IUser } from 'types/auth'; +import reqApi from './ApiService'; +import { LOGIN_URL } from 'commons/ApiUrl'; +import { IApiResponse } from 'types/api'; + +class AuthService { + login = (user) => reqApi.post(LOGIN_URL, user); + + // getCurrentUser = async () => { + // if (!localStorage.getItem(ACCESS_TOKEN_NAME)) { + // return Promise.reject('No access token set.'); + // } + // }; +} + +export default new AuthService(); diff --git a/src/apis/BoardService.js b/src/apis/BoardService.js new file mode 100644 index 0000000..026d4e4 --- /dev/null +++ b/src/apis/BoardService.js @@ -0,0 +1,14 @@ +import { BOARD_LIST_URL } from 'commons/ApiUrl'; +import axios from 'utils/axios'; +import { IBoard, IParam } from 'types/Data'; +import { IApiPageResponse } from 'types/api'; +import { AxiosResponse } from 'axios'; + +class BoardService { + getBoardList = (params) => + axios.get(BOARD_LIST_URL, { params }).then((r) => { + console.log(r); + return r; + }); +} +export default new BoardService(); diff --git a/src/apis/CmmService.js b/src/apis/CmmService.js new file mode 100644 index 0000000..e7077da --- /dev/null +++ b/src/apis/CmmService.js @@ -0,0 +1,17 @@ +import reqApi from './ApiService'; +import { CMM_CODE_LIST_URL } from 'commons/ApiUrl'; +import { IApiResponse } from 'types/api'; +import { IComboCode, IParam } from 'types/Data'; + +class CmmService { + // eslint-disable-next-line class-methods-use-this + getComboCodeList(params) { + return reqApi.get(CMM_CODE_LIST_URL, { params }); + // .then(r => console.log(r)) + // .catch(e => { + // console.log(e) + // }); + } +} + +export default CmmService; diff --git a/src/assets/images/icons/earning.svg b/src/assets/images/icons/earning.svg new file mode 100755 index 0000000..e877b59 --- /dev/null +++ b/src/assets/images/icons/earning.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/assets/images/widget/AUSTRALIA.jpg b/src/assets/images/widget/AUSTRALIA.jpg new file mode 100755 index 0000000..4488bab Binary files /dev/null and b/src/assets/images/widget/AUSTRALIA.jpg differ diff --git a/src/assets/images/widget/BRAZIL.jpg b/src/assets/images/widget/BRAZIL.jpg new file mode 100755 index 0000000..0ee52bf Binary files /dev/null and b/src/assets/images/widget/BRAZIL.jpg differ diff --git a/src/assets/images/widget/GERMANY.jpg b/src/assets/images/widget/GERMANY.jpg new file mode 100755 index 0000000..431281f Binary files /dev/null and b/src/assets/images/widget/GERMANY.jpg differ diff --git a/src/assets/images/widget/PHONE1.jpg b/src/assets/images/widget/PHONE1.jpg new file mode 100755 index 0000000..e4362bf Binary files /dev/null and b/src/assets/images/widget/PHONE1.jpg differ diff --git a/src/assets/images/widget/PHONE2.jpg b/src/assets/images/widget/PHONE2.jpg new file mode 100755 index 0000000..e49fe69 Binary files /dev/null and b/src/assets/images/widget/PHONE2.jpg differ diff --git a/src/assets/images/widget/PHONE3.jpg b/src/assets/images/widget/PHONE3.jpg new file mode 100755 index 0000000..34e6077 Binary files /dev/null and b/src/assets/images/widget/PHONE3.jpg differ diff --git a/src/assets/images/widget/PHONE4.jpg b/src/assets/images/widget/PHONE4.jpg new file mode 100755 index 0000000..7049aee Binary files /dev/null and b/src/assets/images/widget/PHONE4.jpg differ diff --git a/src/assets/images/widget/UK.jpg b/src/assets/images/widget/UK.jpg new file mode 100755 index 0000000..37149a6 Binary files /dev/null and b/src/assets/images/widget/UK.jpg differ diff --git a/src/assets/images/widget/USA.jpg b/src/assets/images/widget/USA.jpg new file mode 100755 index 0000000..2b0f805 Binary files /dev/null and b/src/assets/images/widget/USA.jpg differ diff --git a/src/assets/images/widget/blur-bg.png b/src/assets/images/widget/blur-bg.png new file mode 100755 index 0000000..adda5df Binary files /dev/null and b/src/assets/images/widget/blur-bg.png differ diff --git a/src/assets/images/widget/dashborad-1.jpg b/src/assets/images/widget/dashborad-1.jpg new file mode 100755 index 0000000..c0cf7dd Binary files /dev/null and b/src/assets/images/widget/dashborad-1.jpg differ diff --git a/src/assets/images/widget/dashborad-2.jpg b/src/assets/images/widget/dashborad-2.jpg new file mode 100755 index 0000000..97a5dad Binary files /dev/null and b/src/assets/images/widget/dashborad-2.jpg differ diff --git a/src/assets/images/widget/dashborad-3.jpg b/src/assets/images/widget/dashborad-3.jpg new file mode 100755 index 0000000..73080f0 Binary files /dev/null and b/src/assets/images/widget/dashborad-3.jpg differ diff --git a/src/assets/images/widget/img-round1.jpg b/src/assets/images/widget/img-round1.jpg new file mode 100755 index 0000000..0680b9a Binary files /dev/null and b/src/assets/images/widget/img-round1.jpg differ diff --git a/src/assets/images/widget/p1.jpg b/src/assets/images/widget/p1.jpg new file mode 100755 index 0000000..144f316 Binary files /dev/null and b/src/assets/images/widget/p1.jpg differ diff --git a/src/assets/images/widget/p2.jpg b/src/assets/images/widget/p2.jpg new file mode 100755 index 0000000..be941b6 Binary files /dev/null and b/src/assets/images/widget/p2.jpg differ diff --git a/src/assets/images/widget/p3.jpg b/src/assets/images/widget/p3.jpg new file mode 100755 index 0000000..4ba25f3 Binary files /dev/null and b/src/assets/images/widget/p3.jpg differ diff --git a/src/assets/images/widget/p4.jpg b/src/assets/images/widget/p4.jpg new file mode 100755 index 0000000..68db2d7 Binary files /dev/null and b/src/assets/images/widget/p4.jpg differ diff --git a/src/assets/images/widget/prod1.jpg b/src/assets/images/widget/prod1.jpg new file mode 100755 index 0000000..de3741f Binary files /dev/null and b/src/assets/images/widget/prod1.jpg differ diff --git a/src/assets/images/widget/prod2.jpg b/src/assets/images/widget/prod2.jpg new file mode 100755 index 0000000..9f1fadb Binary files /dev/null and b/src/assets/images/widget/prod2.jpg differ diff --git a/src/assets/images/widget/prod3.jpg b/src/assets/images/widget/prod3.jpg new file mode 100755 index 0000000..cca2675 Binary files /dev/null and b/src/assets/images/widget/prod3.jpg differ diff --git a/src/assets/images/widget/prod4.jpg b/src/assets/images/widget/prod4.jpg new file mode 100755 index 0000000..9f66d05 Binary files /dev/null and b/src/assets/images/widget/prod4.jpg differ diff --git a/src/assets/images/widget/profile-person1.jpg b/src/assets/images/widget/profile-person1.jpg new file mode 100755 index 0000000..709bc69 Binary files /dev/null and b/src/assets/images/widget/profile-person1.jpg differ diff --git a/src/assets/images/widget/slider5.jpg b/src/assets/images/widget/slider5.jpg new file mode 100755 index 0000000..03f1e5e Binary files /dev/null and b/src/assets/images/widget/slider5.jpg differ diff --git a/src/assets/images/widget/slider6.jpg b/src/assets/images/widget/slider6.jpg new file mode 100755 index 0000000..0e0105d Binary files /dev/null and b/src/assets/images/widget/slider6.jpg differ diff --git a/src/assets/images/widget/slider7.jpg b/src/assets/images/widget/slider7.jpg new file mode 100755 index 0000000..05692f0 Binary files /dev/null and b/src/assets/images/widget/slider7.jpg differ diff --git a/src/assets/images/widget/user-blur-bg.png b/src/assets/images/widget/user-blur-bg.png new file mode 100755 index 0000000..6058bf7 Binary files /dev/null and b/src/assets/images/widget/user-blur-bg.png differ diff --git a/src/commons/ApiUrl.js b/src/commons/ApiUrl.js new file mode 100644 index 0000000..e3c24ff --- /dev/null +++ b/src/commons/ApiUrl.js @@ -0,0 +1,5 @@ +// const URL = process.env.NODE_ENV !== 'development' ? process.env.REACT_APP_API_URL : '' +// console.log(process.env.NODE_ENV) +export const LOGIN_URL = '/api/v1/ctgy/account/login'; +export const CMM_CODE_LIST_URL = '/api/v1/biz/cmm/combo'; +export const BOARD_LIST_URL = '/api/v1/ctgy/board'; diff --git a/src/commons/XitCmm.js b/src/commons/XitCmm.js new file mode 100644 index 0000000..7bb202f --- /dev/null +++ b/src/commons/XitCmm.js @@ -0,0 +1,266 @@ +import Swal from 'sweetalert2'; +import React, { Dispatch, SetStateAction, useCallback, useState } from 'react'; +// import axios, {AxiosResponse} from 'axios'; +// import {IApiResponse} from 'types/ApiModel'; +// import Alert from 'react-s-alert'; + +const XitCmm = { + // const request: (options: object) => { + // const headers = new Headers({ + // 'Content-Type': 'application/json', + // }) + // + // if(localStorage.getItem(ACCESS_TOKEN)) { + // headers.append('Authorization', 'Bearer ' + localStorage.getItem(ACCESS_TOKEN)) + // } + // + // const defaults = {headers: headers}; + // options = Object.assign({}, defaults, options); + // + // return fetch(options.url, options) + // .then(response => + // response.json().then(json => { + // if(!response.ok) { + // return Promise.reject(json); + // } + // return json; + // }) + // ); + // }, + + // requestApi: async ( + // methodType: string, + // url: string, + // params: any, + // headers: any + // ): Promise> => { + // console.log(`process.env.NODE_ENV`, process.env.NODE_ENV); + // console.table(params); + // + // headers = Object.assign({'Content-Type': 'application/json;charset=UTF-8'}, headers); //, "Authorization": session.get('token')}; + // let options: any = { + // url: process.env.NODE_ENV === 'development' ? url : process.env.REACT_APP_API + url, + // method: methodType, + // headers: headers + // }; + // // get 요청은 body 없이 call + // if (methodType.toLocaleLowerCase() === 'get') options = {...options, params}; + // else options = {...options, data: params}; + // + // // 요청 처리 + // let res: IApiResponse; + // try { + // res = await axios(options); //{...config, ...options});//.then(res => { + // } catch (e) { + // console.log(`@@@@@@@@@@@ requestApi EXCEPTION @@@@@@@@@@@@@`); + // Alert.error(`

${e}

`); + // } finally { + // } + // if (res !== undefined && res.success && res.data.success) { + // console.log(JSON.stringify(res.data)); + // Alert.success(`처리되었습니다`); + // } else { + // console.log(`@@@@@@@@@@@ requestApi ERROR @@@@@@@@@@@@@`); + // let code = res.data.code != null ? `[${res.data.code}]` : ''; + // await SweetAlert.fire({ + // title: `Inpix Administrator`, + // html: `

${res.data.message} ${code}

`, + // //footer: 'Copyright 2018', + // timer: 3000 + // }); + // } + // return res.data; + // }, + + /** + * validation check error message + * @param message + */ + alertParam: (message: string) => { + Swal.fire({ + icon: 'warning', + html: message, + // imageUrl: + timer: 3000 + }).then((r) => {}); + return false; + }, + + /** + * API Error message + * @param message + */ + alertError: (message: string) => { + Swal.fire({ + icon: 'error', + title: 'API error', + html: message, + // imageUrl: + timer: 3000 + }).then((r) => {}); + return false; + }, + + /** + * + * @return [value: string, onchange: (e: ChangeEvent) => void] + * @param initalValue + * @param validator + */ + + useInput( + initalValue: T, + validator?: (value: string) => boolean + ): [T, Dispatch>, (e?: React.ChangeEvent) => void] { + const [value, setValue] = useState(initalValue); + const changer = useCallback( + (e) => { + const v = e.target.value; + if (validator === undefined || validator(v)) { + setValue(v); + } + }, + [validator] + ); + + return [value, setValue, changer]; + }, + + // ag-grid 페이지 변경 + onPageSizeChanged() { + /* + Page Size: +