
* Use generated hooks in apps * Remove unused files * Use proper types in apps * Use generated hooks in attributes * Use generated hooks in auth module * Use generated hooks in categories * Use generated hooks in channels * Use generated types in collections * Remove legacy types from background tasks * Use generated hooks in customers * Use generated hooks in discounts * Use generated hook in file upload * Use generated types in gift cards * Use generated types in home * Use generated hooks in navigation * Use generated hooks in orders * Use generated hooks in pages * Use generated hooks in page types * Use generated hooks in permission groups * Use generated hooks in plugins * Use generated hooks in products * Use fragment to mark product variants * Improve code a bit * Use generated hooks in page types * Use generated types in searches * Use generated hooks in shipping * Use generated hooks in site settings * Use generated hooks in staff members * Use generated hooks in taxes * Place all gql generated files in one directory * Use generated hooks in translations * Use global types from new generated module * Use generated hooks in warehouses * Use generated hooks in webhooks * Use generated fragment types * Unclutter types * Remove hoc components * Split hooks and types * Fetch introspection file * Delete obsolete schema file * Fix rebase artifacts * Fix autoreplace * Fix auth provider tests * Fix urls * Remove leftover types * Fix rebase artifacts
96 lines
2.7 KiB
TypeScript
96 lines
2.7 KiB
TypeScript
import {
|
|
Card,
|
|
TableBody,
|
|
TableCell,
|
|
TableHead,
|
|
TableRow
|
|
} from "@material-ui/core";
|
|
import ResponsiveTable from "@saleor/components/ResponsiveTable";
|
|
import Skeleton from "@saleor/components/Skeleton";
|
|
import { CountryListQuery } from "@saleor/graphql";
|
|
import { makeStyles } from "@saleor/macaw-ui";
|
|
import classNames from "classnames";
|
|
import React from "react";
|
|
import { FormattedMessage } from "react-intl";
|
|
|
|
import { maybe, renderCollection } from "../../../misc";
|
|
|
|
const useStyles = makeStyles(
|
|
{
|
|
tableRow: {
|
|
cursor: "pointer"
|
|
},
|
|
textRight: {
|
|
textAlign: "right"
|
|
}
|
|
},
|
|
{ name: "CountryList" }
|
|
);
|
|
|
|
interface CountryListProps {
|
|
countries: CountryListQuery["shop"]["countries"];
|
|
onRowClick: (code: string) => void;
|
|
}
|
|
|
|
const CountryList: React.FC<CountryListProps> = props => {
|
|
const { onRowClick, countries } = props;
|
|
|
|
const classes = useStyles(props);
|
|
|
|
return (
|
|
<Card>
|
|
<ResponsiveTable>
|
|
<TableHead>
|
|
<TableRow>
|
|
<TableCell>
|
|
<FormattedMessage defaultMessage="Country Code" />
|
|
</TableCell>
|
|
<TableCell>
|
|
<FormattedMessage defaultMessage="Country Name" />
|
|
</TableCell>
|
|
<TableCell className={classes.textRight}>
|
|
<FormattedMessage defaultMessage="Reduced Tax Rates" />
|
|
</TableCell>
|
|
</TableRow>
|
|
</TableHead>
|
|
<TableBody>
|
|
{renderCollection(
|
|
countries,
|
|
country => (
|
|
<TableRow
|
|
className={classNames({
|
|
[classes.tableRow]: !!country
|
|
})}
|
|
hover={!!country}
|
|
onClick={!!country ? () => onRowClick(country.code) : undefined}
|
|
key={country ? country.code : "skeleton"}
|
|
>
|
|
<TableCell>
|
|
{maybe<React.ReactNode>(() => country.code, <Skeleton />)}
|
|
</TableCell>
|
|
<TableCell>
|
|
{maybe<React.ReactNode>(() => country.country, <Skeleton />)}
|
|
</TableCell>
|
|
<TableCell className={classes.textRight}>
|
|
{maybe<React.ReactNode>(
|
|
() => country.vat.reducedRates.length,
|
|
<Skeleton />
|
|
)}
|
|
</TableCell>
|
|
</TableRow>
|
|
),
|
|
() => (
|
|
<TableRow>
|
|
<TableCell colSpan={3}>
|
|
<FormattedMessage defaultMessage="No countries found" />
|
|
</TableCell>
|
|
</TableRow>
|
|
)
|
|
)}
|
|
</TableBody>
|
|
</ResponsiveTable>
|
|
</Card>
|
|
);
|
|
};
|
|
CountryList.displayName = "CountryList";
|
|
export default CountryList;
|