Skip to content

Commit f18a61e

Browse files
authored
Merge pull request #103 from kube-js/develop
fix: fix autocomplete bug and added course image placeholder
2 parents 0614a2b + 8fc1de8 commit f18a61e

File tree

14 files changed

+40
-72
lines changed

14 files changed

+40
-72
lines changed

.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
# DO NOT PUT SECRETS HERE AS IT'S NOT GITIGNORED
22
# FOR local only, for production scripts/deploy.sh recreate .env file
33
# all env vars should be passed from CI/CD env (circleci) and starts with 'REACT_APP_' prefix
4+
REACT_APP_ASSETS_URL=https://kube-ts-server.s3.eu-west-2.amazonaws.com
5+
46
REACT_APP_API_URL=https://demo.mariuszrajczakowski.me/api/v1
57
# available values: dummy, sentry
68
REACT_APP_LOGGER_TYPE=dummy

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,4 @@ build
6363
env-config.js
6464

6565
/k8s/override.yaml
66+
.env

assets/jscpd-badge.svg

Lines changed: 2 additions & 2 deletions
Loading

k8s/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
description: A Helm chart for kube-ts-react-client
33
name: kube-ts-react-client
44
version: 1.0.0
5-
appVersion: 1.5.14
5+
appVersion: 1.5.17
66
home: https://cloud.docker.com/u/kubejs/repository/docker/kubejs/kube-ts-react-client
77
icon: https://avatars2.githubusercontent.com/u/47761918?s=200&v=4
88
sources:

k8s/values-circleci.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ secret: {}
33

44
configMap:
55
REACT_APP_API_URL: $REACT_APP_API_URL
6+
REACT_APP_ASSETS_URL: $REACT_APP_ASSETS_URL
67
REACT_APP_SENTRY_DSN: $REACT_APP_SENTRY_DSN
78
REACT_APP_LOGGER_TYPE: $REACT_APP_LOGGER_TYPE
89
REACT_APP_NODE_ENV: $REACT_APP_NODE_ENV

k8s/values.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ replicaCount: 2
66

77
image:
88
repository: kubejs/kube-ts-react-client
9-
tag: 1.5.14
9+
tag: 1.5.17
1010
pullPolicy: Always
1111
containerPort: 80
1212

@@ -69,6 +69,7 @@ secret:
6969
# Configmap [remove "{}", uncomment and change the values below]
7070
configMap:
7171
{}
72+
# REACT_APP_ASSETS_URL: https://localhost:3000
7273
# REACT_APP_API_URL: https://localhost:9000/api/v1
7374
# REACT_APP_SENTRY_DSN: https://[email protected]/yourSentryNumber
7475
# REACT_APP_LOGGER_TYPE: sentry

src/atoms/Autocomplete/index.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,4 +133,3 @@ const Autocomplete = ({value, onChange, suggestions}: any) => {
133133

134134
// tslint:disable-next-line:max-file-line-count
135135
export default Autocomplete;
136-

src/components/CourseSlide/index.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ import {
77
Typography,
88
} from '@material-ui/core';
99
import _find from 'ramda/src/find';
10+
import _isNil from 'ramda/src/isNil';
1011
import _propEq from 'ramda/src/propEq';
1112
import React from 'react';
1213
import { Link } from 'react-router-dom';
1314
// tslint:disable:no-import-side-effect
1415
import 'slick-carousel/slick/slick-theme.css';
1516
import 'slick-carousel/slick/slick.css';
1617
import CourseRating from '../../atoms/CourseRating';
18+
import courseImagePlaceholder from '../../images/course_400x180.png';
1719
import { EnhancedCourse } from '../../redux/discoveryItems/actionCreators';
20+
import assetsUrl from '../../utils/helpers/assetsUrl';
1821

1922
const Slide = ({
2023
course,
@@ -28,12 +31,14 @@ const Slide = ({
2831
// tslint:disable-next-line:no-magic-numbers
2932
const coursePrice = Number(Math.random() * 10 + 9).toFixed(2);
3033

34+
const imageUrl = !_isNil(course.imageUrl) ? assetsUrl(course.imageUrl) : courseImagePlaceholder;
35+
3136
return (
3237
<Card className={classes.card}>
3338
<Link className={classes.courseLink} to={`/courses/${course.slug}`}>
3439
<CardMedia
3540
className={classes.cardMedia}
36-
image={course.imageUrl}
41+
image={imageUrl}
3742
title="Image title"
3843
/>
3944
<CardContent className={classes.cardContent}>

src/components/CourseView/index.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
// tslint:disable:no-magic-numbers
22
import { Avatar, Button, Container, Grid, Paper } from '@material-ui/core';
3+
import _isNil from 'ramda/src/isNil';
34
import React, { memo, useEffect } from 'react';
45
import { useDispatch, useSelector } from 'react-redux';
56
import { RouteComponentProps } from 'react-router';
67
import { Redirect } from 'react-router-dom';
78
import { ROOT } from '../../constants/routes';
9+
import courseImagePlaceholder from '../../images/course_400x180.png';
810
import { getCourseDetailsRequested } from '../../redux/courseDetails/actionCreators';
911
import { State } from '../../redux/rootReducer';
12+
import assetsUrl from '../../utils/helpers/assetsUrl';
1013
import useStyles from './styles';
1114

1215
export interface Params {
@@ -33,7 +36,7 @@ const CourseView = ({ match }: RouteComponentProps<Params>) => {
3336
// TODO: make course placeholder
3437
return <div>Loading...</div>;
3538
}
36-
39+
const imageUrl = !_isNil(course.imageUrl) ? assetsUrl(course.imageUrl) : courseImagePlaceholder;
3740
const coursePrice = Number(Math.random() * 10 + 9).toFixed(2);
3841

3942
return (
@@ -59,7 +62,7 @@ const CourseView = ({ match }: RouteComponentProps<Params>) => {
5962
</Grid>
6063
<Grid item xs={12} sm={3}>
6164
<Paper className={classes.paper}>
62-
<img src={course.imageUrl} style={{ width: '100%' }} />
65+
<img src={imageUrl} style={{ width: '100%' }} />
6366
<h4>{${coursePrice}`}</h4>
6467
<Button variant="contained" fullWidth color="primary">
6568
Add to cart

src/components/HeroContent/index.tsx

Lines changed: 2 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import Container from '@material-ui/core/Container';
33
import Grid from '@material-ui/core/Grid';
44
import Typography from '@material-ui/core/Typography';
5+
import _isNil from 'ramda/src/isNil';
56
import React, { useState } from 'react';
67
import { useDispatch, useSelector } from 'react-redux';
78
import { useHistory } from 'react-router-dom';
@@ -11,69 +12,6 @@ import { State } from '../../redux/rootReducer';
1112
import Course from '../../types/items/Course';
1213
import User from '../../types/items/User';
1314
import useStyles from './styles';
14-
15-
const initialResults = [
16-
{ label: 'Afghanistan' },
17-
{ label: 'Aland Islands' },
18-
{ label: 'Albania' },
19-
{ label: 'Algeria' },
20-
{ label: 'American Samoa' },
21-
{ label: 'Andorra' },
22-
{ label: 'Angola' },
23-
{ label: 'Anguilla' },
24-
{ label: 'Antarctica' },
25-
{ label: 'Antigua and Barbuda' },
26-
{ label: 'Argentina' },
27-
{ label: 'Armenia' },
28-
{ label: 'Aruba' },
29-
{ label: 'Australia' },
30-
{ label: 'Austria' },
31-
{ label: 'Azerbaijan' },
32-
{ label: 'Bahamas' },
33-
{ label: 'Bahrain' },
34-
{ label: 'Bangladesh' },
35-
{ label: 'Barbados' },
36-
{ label: 'Belarus' },
37-
{ label: 'Belgium' },
38-
{ label: 'Belize' },
39-
{ label: 'Benin' },
40-
{ label: 'Bermuda' },
41-
{ label: 'Bhutan' },
42-
{ label: 'Bolivia, Plurinational State of' },
43-
{ label: 'Bonaire, Sint Eustatius and Saba' },
44-
{ label: 'Bosnia and Herzegovina' },
45-
{ label: 'Botswana' },
46-
{ label: 'Bouvet Island' },
47-
{ label: 'Brazil' },
48-
{ label: 'British Indian Ocean Territory' },
49-
{ label: 'Brunei Darussalam' },
50-
];
51-
52-
function getSuggestions(
53-
value: string | null,
54-
{ showEmpty }: { showEmpty: boolean } = { showEmpty: false }
55-
) {
56-
const inputValue = String(value)
57-
.trim()
58-
.toLowerCase();
59-
const inputLength = inputValue.length;
60-
let count = 0;
61-
62-
return inputLength === 0 && !showEmpty
63-
? []
64-
: initialResults.filter(suggestion => {
65-
const keep =
66-
count < 5 &&
67-
suggestion.label.slice(0, inputLength).toLowerCase() === inputValue;
68-
69-
if (keep) {
70-
count += 1;
71-
}
72-
73-
return keep;
74-
});
75-
}
76-
7715
export interface GetFormattedResultsOptions {
7816
readonly courses: Course[];
7917
readonly users: User[];
@@ -114,7 +52,7 @@ const HeroContent = () => {
11452

11553
const handleChange = (changes: any) => {
11654
// TODO: abstract this operations
117-
if (changes.hasOwnProperty('selectedItem')) {
55+
if (changes.hasOwnProperty('selectedItem') && !_isNil(changes.selectedItem)) {
11856
setValue(changes.selectedItem);
11957

12058
const item: any = results.filter(

0 commit comments

Comments
 (0)