Web:Components:Cron Added context

This commit is contained in:
Akmal Isomadinov 2023-09-13 10:48:39 +05:00
parent 58e0603cda
commit 9f0266f84e
2 changed files with 10 additions and 3 deletions

View File

@ -15,6 +15,9 @@ const globalTypes = {
description: "Internationalization locale",
toolbar: {
icon: "globe",
defaultValue: "en",
dynamicTitle: true,
showName: true,
items: [
{ value: "ar-SA", title: "عربي (المملكة العربية السعودية)" },
{ value: "az", title: "Azərbaycan (Latın, Azərbaycan)" },
@ -45,7 +48,6 @@ const globalTypes = {
{ value: "vi", title: "Tiếng Việt (Việt Nam)" },
{ value: "zh-CN", title: "中文(简体,中国)" },
],
showName: true,
},
},
};

View File

@ -31,12 +31,14 @@ export default meta;
export const Default: Story = {
args: {},
render: ({ value: defaultValue }) => {
render: ({ value: defaultValue }, context) => {
const [input, setInput] = useState(defaultValue);
const [cron, setCron] = useState(defaultValue);
const [error, setError] = useState<Error>();
const { locale } = context.globals;
const onError = (error?: Error) => {
setError(error);
};
@ -86,7 +88,10 @@ export const Default: Story = {
{date && (
<p>
<strong>Next synchronization: </strong>{" "}
{date.toUTC().setLocale("en-GB").toFormat("DDDD tt")}
{date
.toUTC()
.setLocale(locale ?? "en")
.toFormat("DDDD tt")}
</p>
)}
</div>