Merge branch 'release/v1.29.0'
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
NEXT_PUBLIC_API_NAME = "Loan Facilities Dashboard"
|
||||
NEXT_PUBLIC_API_VERSION = "1.28.5"
|
||||
NEXT_PUBLIC_API_VERSION = "1.29.0"
|
||||
NEXT_PUBLIC_DEFAULT_LANGUAGE = "fa"
|
||||
NEXT_PUBLIC_DEFAULT_DIRECTION = "rtl"
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
"register": {
|
||||
"date": {
|
||||
"from": "1402/10/02",
|
||||
"to": "1402/10/15"
|
||||
"to": "1402/11/15"
|
||||
},
|
||||
"messages": {
|
||||
"before": "ثبت نام هنوز شروع نشده",
|
||||
@@ -47,5 +47,6 @@
|
||||
"secondary": "فرآیند معرفی ضامن و پرداخت"
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"banner":"سلام"
|
||||
}
|
||||
@@ -17,7 +17,6 @@ import {useFormik} from "formik";
|
||||
import {useTranslations} from "next-intl";
|
||||
import * as Yup from "yup";
|
||||
import {CenterLayout, useRequest, useUser} from "@witel/webapp-builder";
|
||||
import useProvince from "@/lib/app/hooks/useProvince";
|
||||
import useCities from "@/lib/app/hooks/useCities";
|
||||
import PlateNumber from "@/core/components/PlateNumber";
|
||||
import MuiDatePicker from "@/core/components/MuiDatePicker";
|
||||
@@ -29,6 +28,7 @@ import {NextLinkComposed} from "@witel/webapp-builder/dist/utils/linkRouting";
|
||||
import SvgDone from "@/core/components/svgs/SvgDone";
|
||||
import {SEND_LOAN_REQUEST_NAVGAN} from "@/core/data/apiRoutes";
|
||||
import {useRouter} from "next/router";
|
||||
import useLimitedProvince from "@/lib/app/hooks/useLimitedProvince";
|
||||
|
||||
const AddFormComponent = () => {
|
||||
const router = useRouter()
|
||||
@@ -37,7 +37,7 @@ const AddFormComponent = () => {
|
||||
const [finishLoanRequest, setFinishLoanRequest] = useState(false)
|
||||
const [checked, setChecked] = useState(false);
|
||||
const requestServer = useRequest()
|
||||
const {provinceList, isLoadingProvinceList, errorProvinceList} = useProvince()
|
||||
const {provinceList, isLoadingProvinceList, errorProvinceList} = useLimitedProvince()
|
||||
const {cityTextField, cityList, setProvinceID, isLoadingCityList} = useCities()
|
||||
const {educationsList, isLoadingEducationsList, errorEducationsList} = UseEducations()
|
||||
const {occupationsList, isLoadingOccupationsList, errorOccupationsList} = useOccupations()
|
||||
|
||||
@@ -116,17 +116,13 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
||||
}
|
||||
formData.append("birthday", values.birthday.locale('en').format("YYYY-MM-DD"));
|
||||
formData.append("postal_code", values.postal_code);
|
||||
formData.append("province_id", values.province_id);
|
||||
formData.append("city_id", values.city_id);
|
||||
formData.append("province_id", LoanDetails.province_id);
|
||||
formData.append("city_id", LoanDetails.city_id);
|
||||
formData.append("telephone_number", values.telephone_number);
|
||||
formData.append("education_id", values.education_id);
|
||||
formData.append("occupation_id", values.occupation_id);
|
||||
formData.append("address", values.address);
|
||||
|
||||
for (var pair of formData.entries()) {
|
||||
console.log(pair[0] + ':' + pair[1]);
|
||||
}
|
||||
|
||||
await requestServer(UPDATE_LOAN + LoanId, "post", {
|
||||
auth: true, notification: true, data: formData
|
||||
}).then(() => {
|
||||
@@ -551,7 +547,8 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
||||
name="province_id"
|
||||
label={t("ShowLoan.text_field_province_id")}
|
||||
size="small"
|
||||
variant="outlined"
|
||||
variant="standard"
|
||||
disabled
|
||||
selectType="province_id"
|
||||
schema={{value: "value", name: "name"}}
|
||||
isLoading={provinceStates.isLoadingProvinceList}
|
||||
@@ -572,6 +569,7 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
||||
as={TextField}
|
||||
sx={{width: "100%"}}
|
||||
disabled
|
||||
variant="standard"
|
||||
size="small"
|
||||
label={t("ShowLoan.text_field_province_id")}
|
||||
value={t("text_field_loading")}
|
||||
@@ -592,8 +590,9 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
||||
label={citiesStates.cityList.length === 0 ? `${t("ShowLoan.cityList_empty")}` : citiesStates.cityTextField}
|
||||
size="small"
|
||||
selectType="city_id"
|
||||
disabled={citiesStates.cityList.length === 0}
|
||||
variant="outlined"
|
||||
// disabled={citiesStates.cityList.length === 0}
|
||||
variant="standard"
|
||||
disabled
|
||||
selectors={citiesStates.cityList}
|
||||
select={props.values.city_id}
|
||||
schema={{value: "value", name: "name"}}
|
||||
@@ -606,6 +605,7 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
||||
as={TextField}
|
||||
sx={{width: "100%"}}
|
||||
disabled
|
||||
variant="standard"
|
||||
size="small"
|
||||
label={t("ShowLoan.cityList_empty")}
|
||||
value={t("text_field_loading")}
|
||||
@@ -773,7 +773,6 @@ const UpdateForm = ({LoanDetails, LoanId}) => {
|
||||
width: {xs: "100%", sm: "30%", md: "25%"},
|
||||
}}
|
||||
>
|
||||
{console.log(props.errors)}
|
||||
<Button
|
||||
fullWidth
|
||||
type="submit"
|
||||
|
||||
14
src/components/first/Banner.jsx
Normal file
14
src/components/first/Banner.jsx
Normal file
@@ -0,0 +1,14 @@
|
||||
import {Box, Container} from "@mui/material";
|
||||
import {useConfig} from "@witel/webapp-builder";
|
||||
|
||||
const Banner = () => {
|
||||
const {config} = useConfig();
|
||||
const bannerHTML = config.banner;
|
||||
return (<Box sx={{backgroundColor: "primary.light"}}>
|
||||
{config.banner && config.banner !== "" && (<Container sx={{py: 0.7}} maxWidth="xl">
|
||||
<div dangerouslySetInnerHTML={{__html: bannerHTML}}/>
|
||||
</Container>)}
|
||||
</Box>);
|
||||
};
|
||||
|
||||
export default Banner;
|
||||
@@ -6,6 +6,7 @@ import FooterDetails from "@/components/first/FooterDetails";
|
||||
import HeaderDetails from "@/components/first/HeaderDetails";
|
||||
import LoanDescription from "@/components/first/LoanDescription";
|
||||
import {FullPageLayout} from "@witel/webapp-builder";
|
||||
import Banner from "@/components/first/Banner";
|
||||
|
||||
const FirstComponent = () => {
|
||||
const t = useTranslations();
|
||||
@@ -14,6 +15,7 @@ const FirstComponent = () => {
|
||||
<FullPageLayout>
|
||||
<Stack>
|
||||
<HeaderDetails/>
|
||||
<Banner/>
|
||||
<LoanRegister/>
|
||||
<LoanDescription/>
|
||||
<LoanCondition/>
|
||||
|
||||
35
src/core/components/Config.jsx
Normal file
35
src/core/components/Config.jsx
Normal file
@@ -0,0 +1,35 @@
|
||||
import {useEffect, useState} from "react";
|
||||
import axios from "axios";
|
||||
import {GET_CONFIG} from "@/core/data/apiRoutes";
|
||||
import {ConfigProvider} from "@witel/webapp-builder";
|
||||
import {useRouter} from "next/router";
|
||||
import {isValidJson} from "@/core/utils/isValidJson";
|
||||
|
||||
const ConfigApp = ({children}) => {
|
||||
const router = useRouter()
|
||||
const [error, setError] = useState(false)
|
||||
const [config, setConfig] = useState()
|
||||
|
||||
useEffect(() => {
|
||||
const fetchConfig = async () => {
|
||||
try {
|
||||
const response = await axios(GET_CONFIG)
|
||||
let _config = {}
|
||||
response.data.data.forEach(item => {
|
||||
_config[item.name] = isValidJson(item.value) ? JSON.parse(item.value) : item.value
|
||||
})
|
||||
setConfig(_config)
|
||||
} catch (error) {
|
||||
setError(true)
|
||||
}
|
||||
}
|
||||
|
||||
fetchConfig()
|
||||
|
||||
}, [router]);
|
||||
|
||||
return (
|
||||
<ConfigProvider config={config || {}}>{error ? <>Error request config</> : config && children}</ConfigProvider>)
|
||||
}
|
||||
|
||||
export default ConfigApp
|
||||
@@ -1,5 +1,7 @@
|
||||
const BASE_URL = process.env.NEXT_PUBLIC_BASE_URL + "/api";
|
||||
|
||||
export const GET_CONFIG = process.env.NEXT_PUBLIC_BASE_URL + "/dashboard/settings/list";
|
||||
|
||||
// export const LOGIN_SEND_OTP_TOKEN = BASE_URL + "/login/send_otp";
|
||||
export const LOGIN = BASE_URL + "/login";
|
||||
// export const REGISTER_SEND_OTP_TOKEN = BASE_URL + "/register/send_otp";
|
||||
@@ -14,6 +16,7 @@ export const SEND_LOAN_REQUEST_WELFARE = BASE_URL + "/refahi/loan/store";
|
||||
export const UPDATE_LOAN_REQUEST_WELFARE = BASE_URL + "/refahi/loan/update/";
|
||||
export const DETAILS_LOAN_REQUEST_WELFARE = BASE_URL + "/refahi/loan/details/";
|
||||
export const GET_PROVINCE_LIST = BASE_URL + "/provinces";
|
||||
export const GET_LIMITED_PROVINCE_LIST = BASE_URL + "/provinces/navgan_eligible";
|
||||
export const GET_CITIES_LIST = BASE_URL + "/cities";
|
||||
export const GET_EDUCATIONS_LIST = BASE_URL + "/education";
|
||||
export const GET_OCCUPATIONS_LIST = BASE_URL + "/occupations";
|
||||
|
||||
@@ -1,13 +1,9 @@
|
||||
import {parse} from "next-useragent";
|
||||
import process from "next/dist/build/webpack/loaders/resolve-url-loader/lib/postcss";
|
||||
|
||||
export const globalServerProps = async ({req, locale}) => {
|
||||
const {isBot} = parse(req.headers["user-agent"]);
|
||||
|
||||
const responseConfig = await fetch(`${process.env.NEXT_PUBLIC_CONFIG_APP_URL}?_=${Math.random()}`);
|
||||
|
||||
return {
|
||||
config: await responseConfig.json(),
|
||||
messages: (await import(`&/locales/${locale}/app.json`)).default,
|
||||
isBot,
|
||||
locale,
|
||||
|
||||
9
src/core/utils/isValidJson.js
Normal file
9
src/core/utils/isValidJson.js
Normal file
@@ -0,0 +1,9 @@
|
||||
export const isValidJson = (value) => {
|
||||
try {
|
||||
JSON.parse(value)
|
||||
return true
|
||||
} catch (e) {
|
||||
return false
|
||||
}
|
||||
|
||||
}
|
||||
34
src/lib/app/hooks/useLimitedProvince.jsx
Normal file
34
src/lib/app/hooks/useLimitedProvince.jsx
Normal file
@@ -0,0 +1,34 @@
|
||||
import {GET_LIMITED_PROVINCE_LIST} from "@/core/data/apiRoutes";
|
||||
import {useRequest} from "@witel/webapp-builder";
|
||||
import {useEffect, useState} from "react";
|
||||
|
||||
const useLimitedProvince = () => {
|
||||
const [isLoadingProvinceList, setIsLoadingProvinceList] = useState(false)
|
||||
const [errorProvinceList, setErrorProvinceList] = useState(false)
|
||||
const [provinceList, setProvinceList] = useState([])
|
||||
const requestServer = useRequest({auth: true, notification: false})
|
||||
|
||||
useEffect(() => {
|
||||
setIsLoadingProvinceList(true)
|
||||
requestServer(GET_LIMITED_PROVINCE_LIST, 'get', {auth: true, notification: false}).then(({data}) => {
|
||||
const formattedData = data.data.map((province, index) => ({
|
||||
id: index,
|
||||
name: province.name,
|
||||
value: province.id,
|
||||
}));
|
||||
setIsLoadingProvinceList(false)
|
||||
setProvinceList(formattedData);
|
||||
}).catch(() => {
|
||||
setIsLoadingProvinceList(false)
|
||||
setErrorProvinceList(true)
|
||||
})
|
||||
}, [])
|
||||
|
||||
return {
|
||||
provinceList,
|
||||
isLoadingProvinceList,
|
||||
errorProvinceList
|
||||
}
|
||||
};
|
||||
|
||||
export default useLimitedProvince;
|
||||
@@ -8,10 +8,10 @@ const useProvince = () => {
|
||||
const [provinceList, setProvinceList] = useState([])
|
||||
const requestServer = useRequest({auth: true, notification: false})
|
||||
|
||||
useEffect(()=> {
|
||||
useEffect(() => {
|
||||
setIsLoadingProvinceList(true)
|
||||
requestServer(GET_PROVINCE_LIST, 'get',{auth : true, notification : false}).then(({data}) => {
|
||||
const formattedData = data.map((province, index) => ({
|
||||
requestServer(GET_PROVINCE_LIST, 'get', {auth: true, notification: false}).then(({data}) => {
|
||||
const formattedData = data.data.map((province, index) => ({
|
||||
id: index,
|
||||
name: province.name,
|
||||
value: province.id,
|
||||
@@ -22,7 +22,7 @@ const useProvince = () => {
|
||||
setIsLoadingProvinceList(false)
|
||||
setErrorProvinceList(true)
|
||||
})
|
||||
},[])
|
||||
}, [])
|
||||
|
||||
return {
|
||||
provinceList,
|
||||
|
||||
@@ -2,7 +2,6 @@ import "&/global.scss";
|
||||
import "moment/locale/fa";
|
||||
import {
|
||||
AppLayout,
|
||||
ConfigProvider,
|
||||
LanguageProvider,
|
||||
LoadingProvider,
|
||||
MuiLayout,
|
||||
@@ -18,10 +17,11 @@ import themeRtl from "@/core/utils/theme-rtl";
|
||||
import TitlePage from "@/core/components/TitlePage";
|
||||
import GlobalHead from "@/core/components/GlobalHead";
|
||||
import Layout from "@/layouts";
|
||||
import ConfigApp from "@/core/components/Config";
|
||||
|
||||
const App = ({Component, pageProps}) => {
|
||||
return (<>
|
||||
<ConfigProvider config={pageProps.config || {}}>
|
||||
<ConfigApp>
|
||||
<UserProvider urlGetUser={GET_USER} schemaGetUser={(data) => data}>
|
||||
<LanguageProvider defaultLanguage={process.env.NEXT_PUBLIC_DEFAULT_LANGUAGE}
|
||||
languageList={languageList}>
|
||||
@@ -45,7 +45,7 @@ const App = ({Component, pageProps}) => {
|
||||
</NextIntlProvider>
|
||||
</LanguageProvider>
|
||||
</UserProvider>
|
||||
</ConfigProvider>
|
||||
</ConfigApp>
|
||||
</>);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user