Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

detail customer #29

Merged
merged 7 commits into from
Jun 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 18 additions & 20 deletions src/views/customer/CustomerListView/UpdateCustomer.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { makeStyles, createStyles, Theme } from '@material-ui/core/styles';
import { makeStyles } from '@material-ui/core';
import Typography from '@material-ui/core/Typography';
import Button from '@material-ui/core/Button';
import { useUpdateCustomerMutation } from 'src/generated/graphql'
Expand All @@ -8,23 +8,22 @@ import {
TextField,
} from '@material-ui/core';
import { UpdateProps } from './Types'
const useStyles = makeStyles((theme: Theme) =>
createStyles({
typography: {
padding: theme.spacing(2),
textAlign: 'center',
},
box: {
margin: theme.spacing(2),
},
textfield: {
marginTop: theme.spacing(2),
},
button: {
margin: theme.spacing(1),
}
}),
);

const useStyles = makeStyles((theme: any) => ({
Copy link
Contributor

@jozef-slezak jozef-slezak Jun 21, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, do not use any type! Wouldn't it better to modify the theme file than overriding somehow the styles in place? https://github.com/iteria-app/example-material-ui/blob/c10255b0c046bc539b99a35ce744d3ad5eb0095b/src/theme/theme-light/index.ts

What is the intent of doing makeStyles() here?

typography: {
padding: theme.spacing(2),
textAlign: 'center',
},
box: {
margin: theme.spacing(2),
},
textfield: {
marginTop: theme.spacing(2),
},
button: {
margin: theme.spacing(1),
}
}));

const UpdateCustomer: React.FC<UpdateProps> = ({ customer, handleClose }) => {
const classes = useStyles();
Expand Down Expand Up @@ -79,5 +78,4 @@ const UpdateCustomer: React.FC<UpdateProps> = ({ customer, handleClose }) => {
</Box>
);
}
export default UpdateCustomer;

export default UpdateCustomer;
2 changes: 1 addition & 1 deletion src/views/customer/CustomerListView/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useState } from 'react';
import React, { useState } from 'react';
import {
Box,
Container,
Expand Down
9 changes: 5 additions & 4 deletions src/views/test/DetailPage.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import React from 'react'
import data from '../customer/CustomerListView/data';
import { FormikComponent } from './DetailPageCodegen';
import { Customer } from './Customer';
import { GeneratedCustomerDetail } from './GeneratedCustomerDetail';
import { CustomerProps } from './types';

const CustomerDetailView = () => {
const customer: Customer = {
const customer: CustomerProps = {
avatarUrl: data[0].avatarUrl,
name: data[0].name,
createdAt: data[0].createdAt, //new Date(data[0].createdAt).toISOString().split('T')[0],
Expand All @@ -13,6 +14,6 @@ const CustomerDetailView = () => {
test2: 258
};
console.log(customer);
return <FormikComponent {...customer} />;
return <GeneratedCustomerDetail {...customer} />;
};
export default CustomerDetailView;
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,9 @@ import {
Grid
} from '@material-ui/core';
import { useFormik } from 'formik';
import { Customer } from './Customer';
export var FormikComponent: React.FC<Customer> = customer => {
import { CustomerProps } from './types';
export var GeneratedCustomerDetail: React.FC<CustomerProps> = customer => {
const intl = useIntl();
const formik = useFormik({
initialValues: {
avatarUrl: customer.avatarUrl,
Expand All @@ -20,7 +21,7 @@ export var FormikComponent: React.FC<Customer> = customer => {
updatedAt: customer.updatedAt,
test2: customer.test2
},
onSubmit: values => {}
onSubmit: values => { }
});
{
const intl = useIntl();
Expand Down
16 changes: 8 additions & 8 deletions src/views/test/GeneratedCustomers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import data from '../customer/CustomerListView/data'
import React, { useState } from 'react';
import GeneratedTable from './GeneratedCustomersTable'

const CustomerListView = () => {
const [customers] = useState(data);
return (
<GeneratedTable customers={customers} />
);
};
export default CustomerListView
const GeneratedCustomers = () => {
const [customers] = useState(data);

return (
<GeneratedTable customers={customers} />
);
};
export default GeneratedCustomers
31 changes: 18 additions & 13 deletions src/views/test/GeneratedCustomersTable.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,18 @@
import { useIntl,FormattedMessage } from "react-intl";
import { GridColParams,DataGrid } from "@material-ui/data-grid";
export default function CustomerTable({ customers }) {
const intl = useIntl();
const columns = [
{ field: "avatarUrl", flex: 1, type: "string", valueFormatter: ({ value }) => value, renderHeader: (params: GridColParams) => (<FormattedMessage id="Customer" defaultMessage="avatarUrl"/>) },
{ field: "createdAt", flex: 1, type: "date", valueFormatter: ({ value }) => intl.formatDate(value), renderHeader: (params: GridColParams) => (<FormattedMessage id="Customer" defaultMessage="createdAt"/>) },
{ field: "email", flex: 1, type: "string", valueFormatter: ({ value }) => value, renderHeader: (params: GridColParams) => (<FormattedMessage id="Customer" defaultMessage="email"/>) },
{ field: "id", flex: 1, type: "string", valueFormatter: ({ value }) => value, renderHeader: (params: GridColParams) => (<FormattedMessage id="Customer" defaultMessage="id"/>) },
{ field: "name", flex: 1, type: "string", valueFormatter: ({ value }) => value, renderHeader: (params: GridColParams) => (<FormattedMessage id="Customer" defaultMessage="name"/>) },
];
return (<div style={{ height: "400px", width: "100%" }}><DataGrid columns={columns} rows={customers}/></div>);
}
import React from 'react'
import { useIntl, FormattedMessage } from "react-intl";
import { GridColParams, DataGrid } from "@material-ui/data-grid";
import { useNavigate } from 'react-router-dom'

export default function CustomerTable({ customers }) {
let navigate = useNavigate();

const intl = useIntl();
const columns = [
{ field: "avatarUrl", flex: 1, type: "string", valueFormatter: ({ value }) => value, renderHeader: (params: GridColParams) => (<FormattedMessage id="Customer" defaultMessage="avatarUrl" />) },
{ field: "createdAt", flex: 1, type: "date", valueFormatter: ({ value }) => intl.formatDate(value), renderHeader: (params: GridColParams) => (<FormattedMessage id="Customer" defaultMessage="createdAt" />) },
{ field: "email", flex: 1, type: "string", valueFormatter: ({ value }) => value, renderHeader: (params: GridColParams) => (<FormattedMessage id="Customer" defaultMessage="email" />) },
{ field: "id", flex: 1, type: "string", valueFormatter: ({ value }) => value, renderHeader: (params: GridColParams) => (<FormattedMessage id="Customer" defaultMessage="id" />) },
{ field: "name", flex: 1, type: "string", valueFormatter: ({ value }) => value, renderHeader: (params: GridColParams) => (<FormattedMessage id="Customer" defaultMessage="name" />) },
];
return (<div style={{ height: "400px", width: "100%" }}><DataGrid onRowClick={() => navigate('/app/generated-customer-detail', { replace: true })} columns={columns} rows={customers} /></div>);
}
2 changes: 1 addition & 1 deletion src/views/test/Customer.ts → src/views/test/types.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export interface Customer {
export interface CustomerProps {
avatarUrl: string;
createdAt: number;
email: string;
Expand Down