Skip to content
Permalink
Browse files

issue#15: Review date does not use ps settings - fixes #15

  • Loading branch information...
tyruk committed Aug 4, 2018
1 parent 3580633 commit 4c8b53aa5c7b010e333eb74102a468156acd58a3
@@ -17,6 +17,7 @@ type Props = {
language: number,
languages: LanguagesType,
criteria: CriteriaType,
dateFormat: string,
displayCriteria: DisplayCriteriaType,
shape: GradingShapeType,
shapeSize: number,
@@ -146,7 +147,7 @@ class EditReviewDialog extends React.PureComponent<Props, State> {
}

renderViewMode = (review: ReviewType) => {
const { onSave, criteria, language, shape, shapeSize, shopName, displayCriteria } = this.props;
const { onSave, criteria, language, shape, shapeSize, shopName, displayCriteria, dateFormat } = this.props;
return (
<ViewReviewForm
onUpdateReview={review => {
@@ -157,6 +158,7 @@ class EditReviewDialog extends React.PureComponent<Props, State> {
review={review}
shape={shape}
shapeSize={shapeSize}
dateFormat={dateFormat}
language={language}
displayCriteria={displayCriteria}
criteria={criteria} />
@@ -13,6 +13,7 @@ type Props = {
criteria: CriteriaType,
shape: GradingShapeType,
shapeSize: number,
dateFormat: string,
review: ReviewType,
displayCriteria: DisplayCriteriaType,
onUpdateReview: (ReviewType)=>void,
@@ -29,7 +30,7 @@ class EditReviewForm extends React.PureComponent<Props> {
static displayName = 'EditReviewForm';

render() {
const { shopName, criteria, review, shape, shapeSize, displayCriteria, onUpdateReview } = this.props;
const { shopName, criteria, review, shape, shapeSize, displayCriteria, onUpdateReview, dateFormat } = this.props;
return (
<Bootstrap className={styles.preview}>
<ReviewListItem
@@ -38,6 +39,7 @@ class EditReviewForm extends React.PureComponent<Props> {
shopName={shopName}
shape={shape}
shapeSize={shapeSize}
dateFormat={dateFormat}
review={merge(review, caps)}
onSaveReply={reply => onUpdateReview(assoc('reply', reply, review))}
/>
@@ -17,6 +17,7 @@ export type InputProps = {
displayCriteria: DisplayCriteriaType,
shape: GradingShapeType,
shapeSize: number,
dateFormat: string,
uniqueId: string,
title: string,
emptyLabel?: string,
@@ -117,7 +118,7 @@ class Controller extends React.PureComponent<Props, State> {
renderList(list: ReviewListType) {
const {
languages, criteria, emptyLabel, title, shape, approveReview, deleteReview, undeleteReview,
language, shapeSize, shopName, displayCriteria, deletePermReview, drilldownUrls
language, shapeSize, shopName, displayCriteria, deletePermReview, drilldownUrls, dateFormat
} = this.props;
const { edit, page, pageSize, order, orderDir, filters } = this.state;
const { total, reviews } = list;
@@ -159,6 +160,7 @@ class Controller extends React.PureComponent<Props, State> {
criteria={criteria}
shape={shape}
shapeSize={shapeSize}
dateFormat={dateFormat}
onSave={this.onSaveReview}
displayCriteria={displayCriteria}
onClose={() => this.setState({ edit: null })}
@@ -26,6 +26,7 @@ class ModerationPage extends React.PureComponent<Props> {
emptyLabel={__('Nothing to approve')}
shape={shape}
shapeSize={settings.theme.shapeSize.product}
dateFormat={data.dateFormat}
displayCriteria={settings.review.displayCriteria}
criteria={criteria}
filters={{
@@ -47,6 +47,7 @@ class ReviewsPage extends React.PureComponent<Props> {
emptyLabel={__('No reviews')}
shape={shape}
shapeSize={shapeSize}
dateFormat={data.dateFormat}
criteria={criteria}
displayCriteria={settings.review.displayCriteria}
filters={{
@@ -10,6 +10,7 @@ type Props = {
shopName: string,
colors: ShapeColorsType,
shape: GradingShapeType,
dateFormat: string,
displayCriteria: DisplayCriteriaType,
size: number,
canVote: boolean,
@@ -20,7 +21,7 @@ class ReviewPreview extends React.PureComponent<Props> {
static displayName = 'ReviewPreview';

render() {
const { shape, size, colors, canVote, canReport, shopName, displayCriteria } = this.props;
const { shape, size, colors, canVote, canReport, shopName, displayCriteria, dateFormat } = this.props;
const criteria: CriteriaType = indexBy(prop('id'), [
{ id: 1, label: __('Quality'), value: 5},
{ id: 2, label: __('Shipping'), value: 3}
@@ -56,6 +57,7 @@ class ReviewPreview extends React.PureComponent<Props> {
shopName={shopName}
shape={shape}
shapeSize={size}
dateFormat={dateFormat}
review={review}
criteria={criteria}
displayCriteria={displayCriteria}
@@ -164,7 +164,7 @@ class Settings extends React.PureComponent<Props, State> {
}

renderTheme = () => {
const { shapes, shopName } = this.props.data;
const { shapes, shopName, dateFormat } = this.props.data;
const { theme, review } = this.state.settings;
const size = theme.shapeSize.product;
const sizes = map(v => v*2, range(5, 13));
@@ -230,6 +230,7 @@ class Settings extends React.PureComponent<Props, State> {
shopName={shopName}
shape={shapes[theme.shape]}
size={theme.shapeSize.product}
dateFormat={dateFormat}
displayCriteria={review.displayCriteria}
canVote={review.allowVoting}
canReport={review.allowReporting} />
@@ -99,6 +99,7 @@ export type GlobalDataType = {
shapes: {
[ string ]: GradingShapeType
},
dateFormat: string,
language: number,
languages: LanguagesType,
platform: 'thirtybees' | 'prestashop',
@@ -9,6 +9,7 @@ type Props = {
product: ProductInfoType,
colors?: ShapeColorsType,
shapeSize: number,
dateFormat: string,
criteria: CriteriaType,
displayCriteria: DisplayCriteriaType,
review: ReviewType,
@@ -25,7 +26,7 @@ class ReviewListItemWithProduct extends React.PureComponent<Props> {
static defaultProps = {};

render() {
const { product, shopName, shape, colors, shapeSize, criteria, displayCriteria, review, onEdit, onDelete, onVote, onReport } = this.props;
const { product, shopName, shape, colors, shapeSize, criteria, displayCriteria, review, onEdit, onDelete, onVote, onReport, dateFormat } = this.props;
return (
<div className="revws-review-with-product">
<div>
@@ -42,6 +43,7 @@ class ReviewListItemWithProduct extends React.PureComponent<Props> {
shape={shape}
colors={colors}
shapeSize={shapeSize}
dateFormat={dateFormat}
criteria={criteria}
displayCriteria={displayCriteria}
review={review}
@@ -13,11 +13,13 @@ import Textarea from 'common/components/text-area/text-area';
import InlineCriteria from 'common/components/criteria/inline';
import BlockCriteria from 'common/components/criteria/block';
import Button from 'material-ui/Button';
import formatDate from 'locutus/php/datetime/date';

type Props = {
shopName: string,
shape: GradingShapeType,
colors?: ShapeColorsType,
dateFormat: string,
shapeSize: number,
criteria: CriteriaType,
displayCriteria: DisplayCriteriaType,
@@ -56,7 +58,7 @@ class ReviewListItem extends React.PureComponent<Props, State> {
}

render() {
const { colors, shape, shapeSize, onReport, onEdit, onDelete, onVote, review, criteria, displayCriteria } = this.props;
const { colors, shape, shapeSize, onReport, onEdit, onDelete, onVote, review, criteria, displayCriteria, dateFormat } = this.props;
const { displayName, date, title, underReview, verifiedBuyer, content, canVote, canReport, grades, canEdit, canDelete, loading } = review;
const classes = classnames('revws-review', {
'revws-review-under-review': underReview,
@@ -85,7 +87,7 @@ class ReviewListItem extends React.PureComponent<Props, State> {
<div className="revws-review-author-name">{ displayName }</div>
{verifiedBuyer && <div className="revws-verified-buyer-badge">{__("Verified purchase")}</div>}
{stars}
<div className="revws-review-date">{formatDate(date)}</div>
<div className="revws-review-date">{formatDate(dateFormat, date)}</div>
</div>

<div className="revws-review-details">
@@ -262,15 +264,6 @@ class ReviewListItem extends React.PureComponent<Props, State> {
}
}

const formatDate = (date: Date): string => {
var month = pad(date.getMonth()+1);
var day = pad(date.getDate());
var year = date.getFullYear();
return month + "/" + day + "/" + year;
};

const pad = (value) => ('00'+value).substr(-2);

const getCriteriaToRender = (criteria, grades) => {
const list = sortBy(prop('id'), values(criteria));
return filter(crit => has(crit.id, grades), list);
@@ -15,6 +15,7 @@ export type SettingsType = {
list: number,
create: number
},
dateFormat: string,
preferences: {
allowEmptyReviews: boolean,
allowGuestReviews: boolean,
@@ -31,6 +31,7 @@ const getSettings = (input: any): SettingsType => {
const api = get('api', isString, input);
const csrf = get('csrf', isString, input);
const gdpr = get('gdpr', isObject, input);
const dateFormat = get('dateFormat', isString, input);

return {
csrf,
@@ -40,6 +41,7 @@ const getSettings = (input: any): SettingsType => {
criteria,
shape,
shapeSize,
dateFormat,
preferences,
gdpr
};
@@ -44,6 +44,7 @@ class FrontAppCustomerReviewList extends React.PureComponent<Props> {
shopName={settings.shopName}
shape={settings.shape}
shapeSize={settings.shapeSize.product}
dateFormat={settings.dateFormat}
reviewList={reviewList}
loading={loading}
onDelete={onDelete}
@@ -33,6 +33,7 @@ class FrontAppReviewList extends React.PureComponent<Props> {
reviewStyle='item'
entities={entities}
shopName={settings.shopName}
dateFormat={settings.dateFormat}
shape={settings.shape}
shapeSize={settings.shapeSize.product}
reviewList={reviewList}
@@ -15,6 +15,7 @@ type Props = {
shopName: string,
shape: GradingShapeType,
shapeSize: number,
dateFormat: string,
reviewList: ReviewListType,
criteria: CriteriaType,
displayCriteria: DisplayCriteriaType,
@@ -49,10 +50,11 @@ class ReviewList extends React.PureComponent<Props> {
}

renderReview = (review: ReviewType) => {
const { displayReply, shape, shapeSize, onReport, onVote, onEdit, onDelete, shopName, displayCriteria, criteria } = this.props;
const { displayReply, shape, shapeSize, onReport, onVote, onEdit, onDelete, shopName, displayCriteria, criteria, dateFormat } = this.props;
return (
<ReviewListItem
key={review.id}
dateFormat={dateFormat}
shape={shape}
shapeSize={shapeSize}
shopName={shopName}
@@ -68,14 +70,15 @@ class ReviewList extends React.PureComponent<Props> {
}

renderReviewWithProduct = (review: ReviewType) => {
const { entities, shape, shapeSize, onReport, onVote, onEdit, onDelete, shopName, displayCriteria, criteria } = this.props;
const { entities, shape, shapeSize, onReport, onVote, onEdit, onDelete, shopName, displayCriteria, criteria, dateFormat } = this.props;
const product = getProduct(entities, review.productId);
return (
<ReviewListItemWithProduct
product={product}
key={review.id}
shape={shape}
shapeSize={shapeSize}
dateFormat={dateFormat}
shopName={shopName}
onEdit={onEdit}
onDelete={onDelete}

Some generated files are not rendered by default. Learn more.

@@ -52,6 +52,7 @@
"debounce": "^1.1.0",
"element-resize-detector": "^1.1.12",
"history": "^4.7.2",
"locutus": "^2.0.9",
"markdown": "^0.5.0",
"material-ui": "^1.0.0-beta.27",
"material-ui-icons": "^1.0.0-beta.17",
@@ -166,6 +166,7 @@ public function getStaticData() {
'create' => $set->getShapeSize() * 5
]
],
'dateFormat' => $context->language->date_format_lite,
'criteria' => RevwsCriterion::getCriteria($this->getLanguage()),
'preferences' => [
'allowEmptyReviews' => $set->allowEmptyReviews(),
@@ -71,6 +71,7 @@ public function display() {
'language' => $lang,
'platform' => $platform,
'platformVersion' => $platformVersion,
'dateFormat' => $this->context->language->date_format_lite,
'environment' => [
'krona' => $this->module->getKrona()->isInstalled(),
'productcomments' => Module::isInstalled('productcomments'),

0 comments on commit 4c8b53a

Please sign in to comment.
You can’t perform that action at this time.