Skip to content

Commit

Permalink
fix: fixed missing type for set image
Browse files Browse the repository at this point in the history
  • Loading branch information
coderdiaz committed Jul 24, 2023
1 parent 8427d82 commit 8c4267d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/images/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import unionpay from './unionpay.js';
import mastercard from './mastercard.js';
import placeholder from './placeholder.js';
import visa from './visa.js';
import { CardType } from '../utils/validation.js';

export default {
amex,
Expand All @@ -18,4 +19,4 @@ export default {
mastercard,
placeholder,
visa,
};
} as { [key in CardType]: React.ReactNode | JSX.Element };
6 changes: 3 additions & 3 deletions src/useCardBrand.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ interface UseCardBrandProps {
images?: {
[key: string]: React.ReactNode | JSX.Element;
};
cardNumber?: string;
type?: string;
ariaLabel?: string;
}

export default function useCardBrand() {
const getSvgProps = React.useCallback((props: UseCardBrandProps = {}) => {
const images = props.images ?? {};
const type = 'placeholder';
const type = props.type ?? 'placeholder';

return React.useMemo(
() => ({
'aria-label': props.ariaLabel ?? 'Placeholder card',
children: images[type] || images,
children: images[type] || null,
width: '1.5em',
height: '1em',
viewBox: '0 0 24 16',
Expand Down
2 changes: 1 addition & 1 deletion src/utils/validation.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
enum CardType {
export enum CardType {
Amex = 'amex',
Diners = 'dinersclub',
Discover = 'discover',
Expand Down

0 comments on commit 8c4267d

Please sign in to comment.