Skip to content

Commit

Permalink
fix(cycles): fix circular dependencies (#199)
Browse files Browse the repository at this point in the history
  • Loading branch information
yannickjacqueline authored May 11, 2021
1 parent a3e1901 commit 5aeb742
Show file tree
Hide file tree
Showing 18 changed files with 40 additions and 65 deletions.
4 changes: 2 additions & 2 deletions front/components/HeaderApp.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { FC } from "react";
import * as React from "react";
import { StyleSheet, Text, View } from "react-native";
import { StyleSheet, View } from "react-native";

import LogoMinistere from "../assets/images/Logo ministere.svg";
import AppLogo from "../assets/images/logo.svg";
Expand All @@ -19,8 +19,8 @@ const HeaderApp: FC = () => (

const styles = StyleSheet.create({
appLogo: {
display: "flex",
alignItems: "center",
display: "flex",
},
logoMinistere: {
padding: Paddings.default,
Expand Down
8 changes: 4 additions & 4 deletions front/constants/Labels.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { EpdsContacts } from ".";
import { epdsContacts } from "./epdsContacts.constants";

export default {
article: {
Expand Down Expand Up @@ -94,7 +94,7 @@ export default {
"Les ressources qui peuvent vous aider les premiers mois de l’enfant",
},
{
paragraphs: EpdsContacts.default.contacts,
paragraphs: epdsContacts,
sectionDescription: "Les lignes téléphoniques d'aide aux parents",
sectionTitle:
"Les ressources numériques ou à distance qui vous apporteront l’information nécessaire",
Expand Down Expand Up @@ -135,7 +135,7 @@ export default {
"Les professionnels qui peuvent vous accompagner pour faire le point",
},
{
paragraphs: EpdsContacts.default.contacts,
paragraphs: epdsContacts,
sectionDescription: "Les lignes téléphoniques d'aide aux parents",
sectionTitle:
"Les ressources numériques ou à distance qui vous apporteront l’information nécessaire",
Expand Down Expand Up @@ -189,7 +189,7 @@ export default {
"Les ressources qui peuvent vous aider les premiers mois de l’enfant",
},
{
paragraphs: EpdsContacts.default.contacts,
paragraphs: epdsContacts,
sectionDescription: "Les lignes téléphoniques d'aide aux parents",
sectionTitle:
"Les ressources numériques ou à distance qui vous apporteront l’information nécessaire",
Expand Down
2 changes: 1 addition & 1 deletion front/constants/epdsContacts.constants.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export default {
export const epdsContacts = {
contacts: [
{
contactName: "FNEPE",
Expand Down
2 changes: 0 additions & 2 deletions front/constants/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import Colors from "./Colors";
import * as DatabaseQueries from "./databaseQueries.constants";
import * as EpdsConstants from "./epdsConstants.constants";
import * as EpdsContacts from "./epdsContacts.constants";
import Formats from "./formats";
import Labels from "./Labels";
import Layouts, { FontWeight } from "./Layout";
Expand All @@ -15,7 +14,6 @@ export {
Colors,
DatabaseQueries,
EpdsConstants,
EpdsContacts,
FontWeight,
Formats,
Labels,
Expand Down
7 changes: 3 additions & 4 deletions front/constants/shadow.constants.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
/* eslint-disable sort-keys-fix/sort-keys-fix */
import { scaleNormalize } from "../utils";
import { scaleNormalize } from "../utils/scaleNormalize.util";

const Shadow = {
radius: scaleNormalize(4),
opacity: 0.25,
offsetHeight: scaleNormalize(2),
offsetWidth: 0,
opacity: 0.25,
radius: scaleNormalize(4),
};

export default Shadow;
3 changes: 2 additions & 1 deletion front/constants/sizes.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/* eslint-disable sort-keys-fix/sort-keys-fix */
import { scaleNormalize } from "../utils";

import { scaleNormalize } from "../utils/scaleNormalize.util";

const Sizes = {
xxxs: scaleNormalize(10),
Expand Down
4 changes: 2 additions & 2 deletions front/constants/spacings.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/* eslint-disable sort-keys-fix/sort-keys-fix */
import { scaleNormalize } from "../utils";
import { scaleNormalize } from "../utils/scaleNormalize.util";

/* eslint-disable sort-keys-fix/sort-keys-fix */
export const Margins = {
smallest: scaleNormalize(4),
smaller: scaleNormalize(8),
Expand Down
2 changes: 1 addition & 1 deletion front/navigation/BottomTabNavigator.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ import * as React from "react";
import Icomoon, { IcomoonIcons } from "../components/Icomoon";
import Colors from "../constants/Colors";
import Labels from "../constants/Labels";
import { EpdsSurveyScreen } from "../screens";
import ArticleDetail from "../screens/ArticleDetail";
import EpdsSurveyScreen from "../screens/epdsSurvey/epdsSurveyScreen.component";
import ListArticles from "../screens/ListArticles";
import TabAroundMeScreen from "../screens/TabAroundMeScreen";
import TabCalendarScreen from "../screens/TabCalendarScreen";
Expand Down
2 changes: 1 addition & 1 deletion front/screens/epdsSurvey/epdsResult.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
Sizes,
} from "../../constants";
import { EpdsSurveyUtils } from "../../utils";
import { EpdsResultInformation } from "..";
import EpdsResultInformation from "./epdsResultInformation/epdsResultInformation.component";

interface Props {
result: number;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ import type {
EpdsResultContactInformation,
EpdsResultSimpleInformation,
} from "../../../type";
import { EpdsResultContactParagraph, EpdsResultSimpleParagraph } from "../..";
import EpdsResultContactParagraph from "./epdsResultContactParagraph.component";
import EpdsResultSimpleParagraph from "./epdsResultSimpleParagraph.component";

interface EpdsResultInformationProps {
leftBorderColor: string;
Expand Down
10 changes: 4 additions & 6 deletions front/screens/epdsSurvey/epdsSurveyContent.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,10 @@ import {
} from "../../constants";
import type { EpdsAnswer, EpdsQuestionAndAnswers } from "../../type";
import { EpdsSurveyUtils, StorageUtils } from "../../utils";
import {
EpdsLoadPreviousSurvey,
EpdsResult,
EpdsSurveyFooter,
EpdsSurveyQuestionsList,
} from "..";
import EpdsLoadPreviousSurvey from "./epdsLoadPreviousSurvey.component";
import EpdsResult from "./epdsResult.component";
import EpdsSurveyFooter from "./epdsSurveyFooter.component";
import EpdsSurveyQuestionsList from "./epdsSurveyQuestionsList.component";

interface Props {
epdsSurvey: EpdsQuestionAndAnswers[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import { SwiperFlatList } from "react-native-swiper-flatlist";
import type { SwiperFlatListRefProps } from "react-native-swiper-flatlist/src/components/SwiperFlatList/SwiperFlatListProps";

import { View } from "../../components/Themed";
import { Colors, FontWeight, Margins, Paddings, Sizes } from "../../constants";
import { Colors, Margins, Paddings, Sizes } from "../../constants";
import type { EpdsAnswer, EpdsQuestionAndAnswers } from "../../type";
import { EpdsQuestion } from "..";
import EpdsQuestion from "./epdsQuestion.component";

interface EpdsSurveyQuestionsListProps {
epdsSurvey: EpdsQuestionAndAnswers[];
Expand Down
3 changes: 2 additions & 1 deletion front/screens/epdsSurvey/epdsSurveyScreen.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ import {
} from "../../constants";
import type { DataFetchingType, EpdsQuestionAndAnswers } from "../../type";
import { DataFetchingUtils, EpdsSurveyUtils, StorageUtils } from "../../utils";
import { EpdsGenderEntry, EpdsSurveyContent } from "..";
import EpdsGenderEntry from "./epdsGenderEntry.component";
import EpdsSurveyContent from "./epdsSurveyContent.component";

const EpdsSurveyScreen: FC = () => {
const [genderIsEntered, setGenderIsEntered] = useState(false);
Expand Down
24 changes: 1 addition & 23 deletions front/screens/index.ts
Original file line number Diff line number Diff line change
@@ -1,25 +1,3 @@
import EpdsGenderEntry from "./epdsSurvey/epdsGenderEntry.component";
import EpdsLoadPreviousSurvey from "./epdsSurvey/epdsLoadPreviousSurvey.component";
import EpdsQuestion from "./epdsSurvey/epdsQuestion.component";
import EpdsResult from "./epdsSurvey/epdsResult.component";
import EpdsResultContactParagraph from "./epdsSurvey/epdsResultInformation/epdsResultContactParagraph.component";
import EpdsResultInformation from "./epdsSurvey/epdsResultInformation/epdsResultInformation.component";
import EpdsResultSimpleParagraph from "./epdsSurvey/epdsResultInformation/epdsResultSimpleParagraph.component";
import EpdsSurveyContent from "./epdsSurvey/epdsSurveyContent.component";
import EpdsSurveyFooter from "./epdsSurvey/epdsSurveyFooter.component";
import EpdsSurveyQuestionsList from "./epdsSurvey/epdsSurveyQuestionsList.component";
import EpdsSurveyScreen from "./epdsSurvey/epdsSurveyScreen.component";

export {
EpdsGenderEntry,
EpdsLoadPreviousSurvey,
EpdsQuestion,
EpdsResult,
EpdsResultContactParagraph,
EpdsResultInformation,
EpdsResultSimpleParagraph,
EpdsSurveyContent,
EpdsSurveyFooter,
EpdsSurveyQuestionsList,
EpdsSurveyScreen,
};
export { EpdsSurveyScreen };
7 changes: 3 additions & 4 deletions front/utils/epdsSurvey.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import type {
EpdsResultData,
QuestionnaireEpdsFromDB,
} from "../type";
import { StorageUtils } from ".";
import { multiRemove } from "./storage.util";

export const getQuestionsAndAnswersFromData = (
data: unknown
Expand Down Expand Up @@ -120,7 +120,6 @@ export const getResultLabelAndStyle = (result: number): EpdsResultData => {
}
};

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const removeEpdsStorageItems = async (): Promise<any> => {
await StorageUtils.multiRemove(StorageKeysConstants.epdsSurveyKeys);
export const removeEpdsStorageItems = async (): Promise<void> => {
await multiRemove(StorageKeysConstants.epdsSurveyKeys);
};
3 changes: 1 addition & 2 deletions front/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import * as DataFetchingUtils from "./dataFetching.util";
import * as EpdsSurveyUtils from "./epdsSurvey.util";
import { scaleNormalize } from "./scaleNormalize.util";
import * as StorageUtils from "./storage.util";

export { DataFetchingUtils, EpdsSurveyUtils, scaleNormalize, StorageUtils };
export { DataFetchingUtils, EpdsSurveyUtils, StorageUtils };
6 changes: 3 additions & 3 deletions front/utils/scaleNormalize.util.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { PixelRatio } from "react-native";

import { PlatformConstants } from "../constants";
import { PLATFORM_IS_IOS, SCREEN_SCALE } from "../constants/platform.constants";

export const scaleNormalize = (size: number): number => {
if (size === 0) {
return 0;
}
const newSize = size * PlatformConstants.SCREEN_SCALE;
const result = PlatformConstants.PLATFORM_IS_IOS
const newSize = size * SCREEN_SCALE;
const result = PLATFORM_IS_IOS
? Math.round(PixelRatio.roundToNearestPixel(newSize))
: Math.round(PixelRatio.roundToNearestPixel(newSize)) - 2;

Expand Down
11 changes: 6 additions & 5 deletions front/utils/storage.util.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
/* eslint-disable @typescript-eslint/explicit-module-boundary-types */
/* eslint-disable @typescript-eslint/no-unsafe-return */
/* eslint-disable @typescript-eslint/no-explicit-any */
import AsyncStorage from "@react-native-async-storage/async-storage";

export const getStringValue = async (storageKey: string): Promise<any> => {
export const getStringValue = async (
storageKey: string
): Promise<string | null | undefined> => {
try {
return await AsyncStorage.getItem(storageKey);
} catch (error: unknown) {
console.error(error);
}
};

// eslint-disable-next-line @typescript-eslint/no-explicit-any
export const getObjectValue = async (storageKey: string): Promise<any> => {
try {
const jsonValue = await AsyncStorage.getItem(storageKey);
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
return jsonValue !== null ? JSON.parse(jsonValue) : null;
} catch (error: unknown) {
console.error(error);
Expand All @@ -33,7 +34,7 @@ export const storeStringValue = async (

export const storeObjectValue = async (
storageKey: string,
value: any
value: unknown
): Promise<void> => {
try {
await storeStringValue(storageKey, JSON.stringify(value));
Expand Down

0 comments on commit 5aeb742

Please sign in to comment.