skeleton for inputs
parent
72a2ff1d51
commit
65b33f8009
|
@ -1,4 +1,4 @@
|
||||||
import { Form, Input, InputNumber } from "antd";
|
import { Form, Input, InputNumber, Skeleton } from "antd";
|
||||||
import { Constants, myFetch } from "../../utils";
|
import { Constants, myFetch } from "../../utils";
|
||||||
import { useRef } from "react";
|
import { useRef } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
|
@ -221,6 +221,7 @@ export function MyFormInput({
|
||||||
inputPlaceholder,
|
inputPlaceholder,
|
||||||
inputType,
|
inputType,
|
||||||
inputNotRequired,
|
inputNotRequired,
|
||||||
|
showSkeleton,
|
||||||
}) {
|
}) {
|
||||||
const commonProps = {
|
const commonProps = {
|
||||||
...propsInput,
|
...propsInput,
|
||||||
|
@ -254,12 +255,18 @@ export function MyFormInput({
|
||||||
}
|
}
|
||||||
|
|
||||||
const inputComponents = {
|
const inputComponents = {
|
||||||
textarea: (
|
textarea: showSkeleton ? (
|
||||||
|
<Skeleton.Input size="large" active block />
|
||||||
|
) : (
|
||||||
<Input.TextArea {...commonProps} autoSize={{ minRows: 2, maxRows: 6 }} />
|
<Input.TextArea {...commonProps} autoSize={{ minRows: 2, maxRows: 6 }} />
|
||||||
),
|
),
|
||||||
number: <InputNumber {...commonProps} />,
|
number: <InputNumber {...commonProps} />,
|
||||||
password: <Input.Password {...commonProps} />,
|
password: <Input.Password {...commonProps} />,
|
||||||
default: <Input {...commonProps} />,
|
default: showSkeleton ? (
|
||||||
|
<Skeleton.Input active block />
|
||||||
|
) : (
|
||||||
|
<Input {...commonProps} />
|
||||||
|
),
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
|
@ -19,7 +19,7 @@ export default function StoreSettings() {
|
||||||
|
|
||||||
const [isRequesting, setIsRequesting] = useState(true);
|
const [isRequesting, setIsRequesting] = useState(true);
|
||||||
const [requestState, setRequestState] = useState(RequestState.INIT);
|
const [requestState, setRequestState] = useState(RequestState.INIT);
|
||||||
//const [storeData, setStoreData] = useState({});
|
|
||||||
const delayTimeout = useRef();
|
const delayTimeout = useRef();
|
||||||
|
|
||||||
const companyName = Form.useWatch("companyName", form);
|
const companyName = Form.useWatch("companyName", form);
|
||||||
|
@ -35,8 +35,6 @@ export default function StoreSettings() {
|
||||||
t: t,
|
t: t,
|
||||||
})
|
})
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
// setStoreData(data.store);
|
|
||||||
|
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
companyName: data.store.name,
|
companyName: data.store.name,
|
||||||
phoneNumber: data.store.phone_number,
|
phoneNumber: data.store.phone_number,
|
||||||
|
@ -98,7 +96,6 @@ export default function StoreSettings() {
|
||||||
|
|
||||||
<Card
|
<Card
|
||||||
title={t("storeSettings.pageTitle")}
|
title={t("storeSettings.pageTitle")}
|
||||||
loading={isRequesting}
|
|
||||||
extra={
|
extra={
|
||||||
<RequestStateItem
|
<RequestStateItem
|
||||||
state={requestState}
|
state={requestState}
|
||||||
|
@ -111,18 +108,21 @@ export default function StoreSettings() {
|
||||||
formItemName="companyName"
|
formItemName="companyName"
|
||||||
label={t("common.companyName")}
|
label={t("common.companyName")}
|
||||||
inputPlaceholder={t("common.companyNamePlaceholder")}
|
inputPlaceholder={t("common.companyNamePlaceholder")}
|
||||||
|
showSkeleton={isRequesting}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<MyFormInput
|
<MyFormInput
|
||||||
formItemName="phoneNumber"
|
formItemName="phoneNumber"
|
||||||
label={t("common.companyPhoneNumber")}
|
label={t("common.companyPhoneNumber")}
|
||||||
inputPlaceholder={t("common.companyPhoneNumberPlaceholder")}
|
inputPlaceholder={t("common.companyPhoneNumberPlaceholder")}
|
||||||
|
showSkeleton={isRequesting}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<MyFormInput
|
<MyFormInput
|
||||||
formItemName="email"
|
formItemName="email"
|
||||||
label={t("common.companyEmail")}
|
label={t("common.companyEmail")}
|
||||||
inputPlaceholder={t("common.companyEmailPlaceholder")}
|
inputPlaceholder={t("common.companyEmailPlaceholder")}
|
||||||
|
showSkeleton={isRequesting}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<MyFormInput
|
<MyFormInput
|
||||||
|
@ -130,6 +130,7 @@ export default function StoreSettings() {
|
||||||
label={t("common.companyAddress")}
|
label={t("common.companyAddress")}
|
||||||
inputType="textarea"
|
inputType="textarea"
|
||||||
inputPlaceholder={t("common.companyAddressPlaceholder")}
|
inputPlaceholder={t("common.companyAddressPlaceholder")}
|
||||||
|
showSkeleton={isRequesting}
|
||||||
/>
|
/>
|
||||||
</Form>
|
</Form>
|
||||||
</Card>
|
</Card>
|
||||||
|
|
Loading…
Reference in New Issue