Skip to content

Commit

Permalink
Double quote linting issues fixed 2nd
Browse files Browse the repository at this point in the history
  • Loading branch information
Tharindu Kumarasiri committed Sep 4, 2024
1 parent 66c9562 commit 4e8bc2a
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 76 deletions.
12 changes: 6 additions & 6 deletions src/context/ThemeContext.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// ThemeContext.tsx
import React, { createContext, useContext, useState, useEffect } from 'react';
import React, { createContext, useContext, useState, useEffect } from "react";

import { Appearance } from 'react-native';
import { Appearance } from "react-native";

import { ThemeModes } from '../util/constants';
import { ThemeModes } from "../util/constants";

interface ThemeContextType {
mode: ThemeModes;
Expand All @@ -17,12 +17,12 @@ export const ThemeProvider: React.FC<{ children: React.ReactNode }> = ({
}) => {
const [mode, setMode] = useState<ThemeModes>(() => {
const colorScheme = Appearance.getColorScheme();
return colorScheme === 'dark' ? ThemeModes.dark : ThemeModes.light;
return colorScheme === "dark" ? ThemeModes.dark : ThemeModes.light;
});

useEffect(() => {
const subscription = Appearance.addChangeListener(({ colorScheme }) => {
setMode(colorScheme === 'dark' ? ThemeModes.dark : ThemeModes.light);
setMode(colorScheme === "dark" ? ThemeModes.dark : ThemeModes.light);
});

return () => subscription.remove();
Expand All @@ -44,7 +44,7 @@ export const ThemeProvider: React.FC<{ children: React.ReactNode }> = ({
export const useTheme = (): ThemeContextType => {
const context = useContext(ThemeContext);
if (context === undefined) {
throw new Error('useTheme must be used within a ThemeProvider');
throw new Error("useTheme must be used within a ThemeProvider");
}
return context;
};
40 changes: 20 additions & 20 deletions src/context/state.ts
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
import { createContext } from 'react';
import { createContext } from "react";

import { noop } from '../util/constants';
import { noop } from "../util/constants";
import {
ActionType,
CreatePaymentFuncType,
InitPrams,
PaymentType,
State,
initialState,
} from '../util/types';
} from "../util/types";

/**
* Action types for the reducer
*/

export const Actions = {
RESET_STATES: 'RESET_STATES',
SET_CARDHOLDER_NAME: 'SET_CARDHOLDER_NAME',
SET_CARD_NUMBER: 'SET_CARD_NUMBER',
SET_PAYMENT_OPTION: 'SET_PAYMENT_OPTION',
SET_CARD_EXPIRED_DATE: 'SET_CARD_EXPIRED_DATE',
SET_CARD_CVV: 'SET_CARD_CVV',
SET_NAME: 'SET_NAME',
SET_EMAIL: 'SET_EMAIL',
SET_TRANSFER_FORM_FIELDS: 'SET_TRANSFER_FORM_FIELDS',
SET_SINGLE_INPUT_FORM_FIELD: 'SET_SINGLE_INPUT_FORM_FIELD',
SET_LOADING: 'SET_LOADING',
SET_CURRENCY: 'SET_CURRENCY',
SET_AMOUNT: 'SET_AMOUNT',
SET_SELECTED_STORE: 'SET_SELECTED_STORE',
SET_PAYMENT_STATE: 'SET_PAYMENT_STATE',
SET_PAYMENT_METHODS: 'SET_PAYMENT_METHODS',
SESSION_PAY: 'SESSION_PAY',
RESET_STATES: "RESET_STATES",
SET_CARDHOLDER_NAME: "SET_CARDHOLDER_NAME",
SET_CARD_NUMBER: "SET_CARD_NUMBER",
SET_PAYMENT_OPTION: "SET_PAYMENT_OPTION",
SET_CARD_EXPIRED_DATE: "SET_CARD_EXPIRED_DATE",
SET_CARD_CVV: "SET_CARD_CVV",
SET_NAME: "SET_NAME",
SET_EMAIL: "SET_EMAIL",
SET_TRANSFER_FORM_FIELDS: "SET_TRANSFER_FORM_FIELDS",
SET_SINGLE_INPUT_FORM_FIELD: "SET_SINGLE_INPUT_FORM_FIELD",
SET_LOADING: "SET_LOADING",
SET_CURRENCY: "SET_CURRENCY",
SET_AMOUNT: "SET_AMOUNT",
SET_SELECTED_STORE: "SET_SELECTED_STORE",
SET_PAYMENT_STATE: "SET_PAYMENT_STATE",
SET_PAYMENT_METHODS: "SET_PAYMENT_METHODS",
SESSION_PAY: "SESSION_PAY",
};

/**
Expand Down
12 changes: 8 additions & 4 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import { useContext } from 'react';
import { useContext } from "react";

import { KomojuProvider } from './context/KomojuProvider';
import { KomojuContext } from './context/state';
import { KomojuProvider } from "./context/KomojuProvider";
import { KomojuContext } from "./context/state";

import { LanguageTypes, PaymentType, SessionShowResponseType } from './util/types';
import {
LanguageTypes,
PaymentType,
SessionShowResponseType,
} from "./util/types";

/**
* KomojuSDK provides context utilities for the Komoju payment system.
Expand Down
16 changes: 8 additions & 8 deletions src/services/payForSessionService.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { BASE_URL_API, API_HEADER } from '../util/constants';
import { getMonthYearFromExpiry, printLog } from '../util/helpers';
import { BASE_URL_API, API_HEADER } from "../util/constants";
import { getMonthYearFromExpiry, printLog } from "../util/helpers";
import {
payForSessionProps,
PaymentType,
SessionPayResponseType,
} from '../util/types';
} from "../util/types";

/**
* Processes a payment for a given session.
Expand Down Expand Up @@ -42,12 +42,12 @@ const payForSession = async ({
// TODO: Fix this type error

const { month, year } = getMonthYearFromExpiry(
paymentDetails?.cardExpiredDate || ''
paymentDetails?.cardExpiredDate || ""
);
// refactoring number to remove all unsavory empty spaces from credit card number
// TODO: Fix this type error

const number = paymentDetails?.cardNumber?.replaceAll(' ', '');
const number = paymentDetails?.cardNumber?.replaceAll(" ", "");

// credit card payment_details mandatory parameters type, number, month, year
payment_details = {
Expand Down Expand Up @@ -117,7 +117,7 @@ const payForSession = async ({
method: "POST",
headers: API_HEADER(publishableKey),
body: JSON.stringify({
capture: 'auto',
capture: "auto",
payment_details,
}),
};
Expand All @@ -130,8 +130,8 @@ const payForSession = async ({
} catch (e) {
// logging out any exceptions for debugging
printLog({
logName: 'Error:',
message: 'Unable to Process Payment',
logName: "Error:",
message: "Unable to Process Payment",
});
return null;
}
Expand Down
10 changes: 5 additions & 5 deletions src/services/sessionShow.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BASE_URL_API, API_HEADER } from '../util/constants';
import { printLog } from '../util/helpers';
import { SessionShowResponseType } from '../util/types';
import { BASE_URL_API, API_HEADER } from "../util/constants";
import { printLog } from "../util/helpers";
import { SessionShowResponseType } from "../util/types";

type SessionShowProps = {
sessionId: string;
Expand All @@ -24,8 +24,8 @@ const sessionShow = async ({
return data;
} catch (e) {
printLog({
logName: 'Error:',
message: 'Invalid Session',
logName: "Error:",
message: "Invalid Session",
});
return null;
}
Expand Down
42 changes: 21 additions & 21 deletions src/theme/defaultColorTheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@ const darkTheme = {
BACKGROUND_COLOR: "#1E1E1E",
ERROR: "#fc4747",
TEXT_COLOR: "#fff",
INPUT_BACKGROUND: '#2C2C2C',
INPUT_TEXT: '#F7F8F8',
INPUT_PLACEHOLDER: '#958d8e',
INVERTED_CONTENT: '#1D1617',
INPUT_BACKGROUND: "#2C2C2C",
INPUT_TEXT: "#F7F8F8",
INPUT_PLACEHOLDER: "#958d8e",
INVERTED_CONTENT: "#1D1617",
WHITE50: "#00000080",
CARD_BACKGROUND: '#171717',
CARD_BORDER: '#33414c',
LIGHT_BOX: '#2C2C2C',
CARD_SHADOW_IOS_COLOR: '#000',
CARD_SHADOW_ANDROID_COLOR: '#000',
CARD_BACKGROUND: "#171717",
CARD_BORDER: "#33414c",
LIGHT_BOX: "#2C2C2C",
CARD_SHADOW_IOS_COLOR: "#000",
CARD_SHADOW_ANDROID_COLOR: "#000",
};

const lightTheme = {
PRIMARY_COLOR: "#0B82EE",
BACKGROUND_COLOR: "#FFFFFF",
ERROR: "#fc5d5d",
TEXT_COLOR: "#172E44",
INPUT_BACKGROUND: '#FFFFFF',
INPUT_TEXT: '#172E44',
INPUT_PLACEHOLDER: '#ADA4A5',
INVERTED_CONTENT: '#fff',
WHITE50: '#00000050',
CARD_BACKGROUND: '#ffffff',
CARD_BORDER: '#CAD6E1',
LIGHT_BOX: '#F3F7F9',
CARD_SHADOW_IOS_COLOR: '#D9D9D9',
CARD_SHADOW_ANDROID_COLOR: '#c4c2c2',
INPUT_BACKGROUND: "#FFFFFF",
INPUT_TEXT: "#172E44",
INPUT_PLACEHOLDER: "#ADA4A5",
INVERTED_CONTENT: "#fff",
WHITE50: "#00000050",
CARD_BACKGROUND: "#ffffff",
CARD_BORDER: "#CAD6E1",
LIGHT_BOX: "#F3F7F9",
CARD_SHADOW_IOS_COLOR: "#D9D9D9",
CARD_SHADOW_ANDROID_COLOR: "#c4c2c2",
};

export const appTheme = {
dark: darkTheme,
light: lightTheme
}
light: lightTheme,
};
6 changes: 3 additions & 3 deletions src/theme/scalling.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Dimensions, PixelRatio, Platform } from 'react-native';
import { Dimensions, PixelRatio, Platform } from "react-native";

const figmaScreenWidth = 390;
const figmaScreenHeight = 844;

const { width, height } = Dimensions.get('window');
const { width, height } = Dimensions.get("window");
const screenWidth = Math.min(width, height);
const screenHeight = Math.max(width, height);

Expand All @@ -20,7 +20,7 @@ export const responsiveScale = (size: number): number => {
};

export const resizeFonts = (size: number): number => {
const fontScale = Platform.OS === 'ios' ? 1 : PixelRatio.getFontScale();
const fontScale = Platform.OS === "ios" ? 1 : PixelRatio.getFontScale();
const spFontSize = size * fontScale;
return spFontSize;
};
Expand Down
6 changes: 3 additions & 3 deletions src/theme/useCurrentTheme.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useColorScheme } from 'react-native';
import { useColorScheme } from "react-native";

import { useTheme } from '../context/ThemeContext';
import { useTheme } from "../context/ThemeContext";

import { appTheme } from './defaultColorTheme';
import { appTheme } from "./defaultColorTheme";

export const useCurrentTheme = () => {
const { mode } = useTheme();
Expand Down
4 changes: 2 additions & 2 deletions src/util/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ export const noop = () => {};
export const BASE_URL = "https://komoju.com";
export const BASE_URL_API = `${BASE_URL}/api/v1`;
export const API_HEADER = (publishableKey: string) => ({
accept: "application/json",
"accept": "application/json",
"content-type": "application/json",
"KOMOJU-VIA": "mobile_react",
"X-KOMOJU-API-VERSION": "2024-07-15",
Authorization: `Basic ${btoa(publishableKey + ":")}`,
"Authorization": `Basic ${btoa(publishableKey + ":")}`,
});

export const paymentSuccessCtaText = "BACK_TO_STORE";
Expand Down
8 changes: 4 additions & 4 deletions src/util/validator.ts
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { emailRegex } from './constants';
import { emailRegex } from "./constants";
import {
cardValidationFuncProps,
konbiniValidationFuncProps,
PaymentStatuses,
SessionShowResponseType,
setInputErrorType,
TransferFormFieldsType,
} from './types';
} from "./types";

const MAX_CARD_LENGTH = 19;

export const isCardNumberValid = (cardString: string) => {
const text = cardString.replaceAll(' ', '');
const text = cardString.replaceAll(" ", "");
try {
if (text?.length <= 0) {
return true;
Expand All @@ -37,7 +37,7 @@ export const validateCardExpiry = (expiry: string) => {
if (expiry?.length <= 0) {
return true;
}
const derivedExpiry = expiry.replace(' / ', '');
const derivedExpiry = expiry.replace(" / ", "");

if (derivedExpiry.length > 4) {
return false;
Expand Down

0 comments on commit 4e8bc2a

Please sign in to comment.