split messages between individual views
This commit is contained in:
parent
572d698aca
commit
2e14716a29
5 changed files with 26 additions and 10 deletions
|
@ -17,6 +17,7 @@ import React from "react";
|
||||||
import { FormattedMessage } from "react-intl";
|
import { FormattedMessage } from "react-intl";
|
||||||
|
|
||||||
import { CollectionList_collections_edges_node } from "../../types/CollectionList";
|
import { CollectionList_collections_edges_node } from "../../types/CollectionList";
|
||||||
|
import { messages } from "./messages";
|
||||||
|
|
||||||
const useStyles = makeStyles(
|
const useStyles = makeStyles(
|
||||||
theme => ({
|
theme => ({
|
||||||
|
@ -191,7 +192,7 @@ const CollectionList: React.FC<CollectionListProps> = props => {
|
||||||
(collection?.channelListings !== undefined && channel ? (
|
(collection?.channelListings !== undefined && channel ? (
|
||||||
<AvailabilityStatusLabel
|
<AvailabilityStatusLabel
|
||||||
channel={channel}
|
channel={channel}
|
||||||
type="collection"
|
messages={messages}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<ChannelsAvailabilityDropdown
|
<ChannelsAvailabilityDropdown
|
||||||
|
|
16
src/collections/components/CollectionList/messages.ts
Normal file
16
src/collections/components/CollectionList/messages.ts
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
import { defineMessages } from "react-intl";
|
||||||
|
|
||||||
|
export const messages = defineMessages({
|
||||||
|
published: {
|
||||||
|
defaultMessage: "Published on {date}",
|
||||||
|
description: "collection publication date"
|
||||||
|
},
|
||||||
|
unpublished: {
|
||||||
|
defaultMessage: "Unpublished",
|
||||||
|
description: "collection publication date"
|
||||||
|
},
|
||||||
|
willBePublished: {
|
||||||
|
defaultMessage: "Becomes published on {date}",
|
||||||
|
description: "collection publication date"
|
||||||
|
}
|
||||||
|
});
|
|
@ -3,9 +3,7 @@ import useDateLocalize from "@saleor/hooks/useDateLocalize";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { useIntl } from "react-intl";
|
import { useIntl } from "react-intl";
|
||||||
|
|
||||||
import { messages } from "./messages";
|
export const AvailabilityStatusLabel = ({ channel, messages }) => {
|
||||||
|
|
||||||
export const AvailabilityStatusLabel = ({ channel, type = "" }) => {
|
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const localizeDate = useDateLocalize();
|
const localizeDate = useDateLocalize();
|
||||||
|
|
||||||
|
@ -18,8 +16,7 @@ export const AvailabilityStatusLabel = ({ channel, type = "" }) => {
|
||||||
: messages.willBePublished
|
: messages.willBePublished
|
||||||
: messages.unpublished,
|
: messages.unpublished,
|
||||||
{
|
{
|
||||||
date: localizeDate(channel.publicationDate, "L"),
|
date: localizeDate(channel.publicationDate, "L")
|
||||||
type
|
|
||||||
}
|
}
|
||||||
)}
|
)}
|
||||||
status={
|
status={
|
||||||
|
|
|
@ -36,6 +36,8 @@ import classNames from "classnames";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { FormattedMessage } from "react-intl";
|
import { FormattedMessage } from "react-intl";
|
||||||
|
|
||||||
|
import { messages } from "./messages";
|
||||||
|
|
||||||
const useStyles = makeStyles(
|
const useStyles = makeStyles(
|
||||||
theme => ({
|
theme => ({
|
||||||
[theme.breakpoints.up("lg")]: {
|
[theme.breakpoints.up("lg")]: {
|
||||||
|
@ -377,7 +379,7 @@ export const ProductList: React.FC<ProductListProps> = props => {
|
||||||
(product?.channelListings !== undefined && channel ? (
|
(product?.channelListings !== undefined && channel ? (
|
||||||
<AvailabilityStatusLabel
|
<AvailabilityStatusLabel
|
||||||
channel={channel}
|
channel={channel}
|
||||||
type="product"
|
messages={messages}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<ChannelsAvailabilityDropdown
|
<ChannelsAvailabilityDropdown
|
||||||
|
|
|
@ -3,14 +3,14 @@ import { defineMessages } from "react-intl";
|
||||||
export const messages = defineMessages({
|
export const messages = defineMessages({
|
||||||
published: {
|
published: {
|
||||||
defaultMessage: "Published on {date}",
|
defaultMessage: "Published on {date}",
|
||||||
description: "{type} publication date"
|
description: "product publication date"
|
||||||
},
|
},
|
||||||
unpublished: {
|
unpublished: {
|
||||||
defaultMessage: "Unpublished",
|
defaultMessage: "Unpublished",
|
||||||
description: "{type} publication date"
|
description: "product publication date"
|
||||||
},
|
},
|
||||||
willBePublished: {
|
willBePublished: {
|
||||||
defaultMessage: "Becomes published on {date}",
|
defaultMessage: "Becomes published on {date}",
|
||||||
description: "{type} publication date"
|
description: "product publication date"
|
||||||
}
|
}
|
||||||
});
|
});
|
Loading…
Reference in a new issue