Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrouid committed Jun 11, 2019
1 parent 4f61f44 commit 6ee9140
Show file tree
Hide file tree
Showing 59 changed files with 689 additions and 148 deletions.
2 changes: 2 additions & 0 deletions images.d.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
declare module "is-ipfs";

declare module "*.svg";
declare module "*.png";
declare module "*.jpg";
Expand Down
119 changes: 119 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"@walletconnect/browser": "^1.0.0-beta.25",
"axios": "^0.18.0",
"bignumber.js": "^8.1.1",
"is-ipfs": "^0.6.1",
"qr-image": "^3.2.0",
"react": "^16.8.6",
"react-blockies": "^1.4.0",
Expand Down
30 changes: 30 additions & 0 deletions src/components/EmptyState.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import * as React from "react";
import * as PropTypes from "prop-types";
import styled from "styled-components";
import { SCenter } from "./common";
import { colors } from "../styles";

const SEmptyState = styled(SCenter)`
background: rgb(${colors.white});
& h6 {
font-weight: normal;
color: rgb(${colors.grey});
}
`;

const EmptyState = (props: any) => (
<SEmptyState>
<h6>{props.message}</h6>
{props.children}
</SEmptyState>
);

EmptyState.propTypes = {
message: PropTypes.string
};

EmptyState.defaultProps = {
message: "No Items"
};

export default EmptyState;
4 changes: 2 additions & 2 deletions src/components/ListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from "react";
import styled from "styled-components";
import { colors, fonts, shadows, transitions } from "../styles";
import { IMenuItem, IOrderItem, IBusinessPayment } from "../helpers/types";
import { formatDisplayAmount } from "../helpers/utilities";
import { formatDisplayAmount, sanitizeImgSrc } from "../helpers/utilities";
import {
SListItemImage,
SListItemText,
Expand Down Expand Up @@ -137,7 +137,7 @@ const ListItem = ({
<SListItemDetails flex={3}>
{!!item.image && !noImage && (
<SListItemImage>
<img src={item.image} alt={item.name} />
<img src={sanitizeImgSrc(item.image)} alt={item.name} />
</SListItemImage>
)}
<SListItemText>
Expand Down
3 changes: 1 addition & 2 deletions src/components/ProfileForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import Input from "../components/Input";
import Button from "../components/Button";
import Dropdown from "../components/Dropdown";
import UploadToIpfs from "../components/UploadToIpfs";
import { getIpfsUrl } from "../helpers/utilities";
import { IBusinessProfile } from "../helpers/types";
import BUSINESS_TYPES from "../constants/businessTypes";
import COUNTRIES from "../constants/countries";
Expand Down Expand Up @@ -43,7 +42,7 @@ const ProfileForm = (props: IProfileFormProps) => {
<UploadToIpfs
size={200}
label={`Logo`}
image={getIpfsUrl(businessProfile.logo)}
image={businessProfile.logo}
onUpload={(logo: string) => {
onInputChange({ logo });
if (onInputSubmit) {
Expand Down
7 changes: 4 additions & 3 deletions src/components/Upload.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import uploadIcon from "../assets/upload.svg";
import editIcon from "../assets/edit.svg";
import { colors, transitions } from "../styles";
import { SLabel } from "./common";
import { sanitizeImgSrc } from "../helpers/utilities";

const IMAGE_PADDING = 5;

Expand Down Expand Up @@ -69,7 +70,7 @@ const SUploadButton = styled.button<IUploadButtonStyleProps>`
`;

interface IImageDisplayStyledProps {
url: string;
image: string;
}

const SImageDisplay = styled.div<IImageDisplayStyledProps>`
Expand All @@ -79,7 +80,7 @@ const SImageDisplay = styled.div<IImageDisplayStyledProps>`
left: ${IMAGE_PADDING}px;
right: ${IMAGE_PADDING}px;
overflow: hidden;
background-image: ${({ url }) => `url(${url})`};
background-image: ${({ image }) => `url(${image})`};
background-position: center;
background-size: cover;
background-repeat: no-repeat;
Expand Down Expand Up @@ -174,7 +175,7 @@ class Upload extends React.Component<any, any> {
/>
{image && !uploading ? (
<React.Fragment>
<SImageDisplay url={image} />
<SImageDisplay image={sanitizeImgSrc(image)} />
<SEditIcon
size={(5 * size) / 40}
icon={editIcon}
Expand Down
11 changes: 2 additions & 9 deletions src/components/UploadToIpfs.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import * as React from "react";
import * as PropTypes from "prop-types";
import { apiPinFile } from "../helpers/api";
import { getIpfsUrl, getIpfsHash } from "../helpers/utilities";
import Upload from "../components/Upload";

class UploadToIpfs extends React.Component<any, any> {
Expand All @@ -20,18 +19,12 @@ class UploadToIpfs extends React.Component<any, any> {
formData.append(`${idx}`, file);
});

const fileHash = await apiPinFile(formData);

let result = "";

if (fileHash) {
result = getIpfsUrl(fileHash);
}
const result = await apiPinFile(formData);

return result;
};

public onUpload = (url: string) => this.props.onUpload(getIpfsHash(url));
public onUpload = (image: string) => this.props.onUpload(image);

public render() {
const { color, size, label, image } = this.props;
Expand Down
1 change: 1 addition & 0 deletions src/components/common/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ export const SGrid = styled.div<IGridStyleProps>`
`;

export const SLabel = styled.label`
text-align: left;
color: rgb(${colors.grey});
font-size: ${fonts.size.small};
font-weight: ${fonts.weight.semibold};
Expand Down
File renamed without changes.
2 changes: 2 additions & 0 deletions src/constants/modals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ export const PAYMENT_METHODS_MODAL = "PAYMENT_METHODS_MODAL";
export const PLAIN_MESSAGE_MODAL = "PLAIN_MESSAGE_MODAL";

export const ADMIN_AUTHENTICATION_MODAL = "ADMIN_AUTHENTICATION_MODAL";

export const INVENTORY_ITEM = "INVENTORY_ITEM";
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
File renamed without changes
Loading

0 comments on commit 6ee9140

Please sign in to comment.