Skip to content

Commit

Permalink
updated, improved and fixed the entire project
Browse files Browse the repository at this point in the history
  • Loading branch information
jd-apprentice committed Jul 24, 2022
1 parent bff8839 commit 7e778a5
Show file tree
Hide file tree
Showing 27 changed files with 84 additions and 60 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_BASE_URL=
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ Make sure you have node.js and git installed
>> cd ./React-Boilerplate
>> cp .env.example .env
>> npm run install
>> npm run start
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
<title>React-Boilerplate</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
Binary file removed public/logo192.png
Binary file not shown.
Binary file removed public/logo512.png
Binary file not shown.
21 changes: 2 additions & 19 deletions public/manifest.json
Original file line number Diff line number Diff line change
@@ -1,23 +1,6 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "favicon.ico",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"short_name": "React Boilerplate",
"name": "React + Mui + MobX",
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
Expand Down
2 changes: 1 addition & 1 deletion public/robots.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
Disallow: *
10 changes: 3 additions & 7 deletions src/@types/index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export {};

declare global {
interface Window {
baseUrl: string;
}
}
/* Declare modules here if needed */
/* Example -> */
// declare module "ModuleName"
9 changes: 0 additions & 9 deletions src/App.test.tsx

This file was deleted.

11 changes: 5 additions & 6 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { Divider } from "@mui/material";
import BasicAlerts from "components/common/alert";
import BasicRating from "components/common/rating";
import React from "react";
import { Alert, Rating } from "components/index";
import React, { ReactElement } from "react";

const App = () => {
const App: React.FC = (): ReactElement => {
return (
<>
<h1 className="title">React + TS + Sass + Eslint + Prettier + MobX + Apisauce</h1>
<Divider>
<BasicRating text="Quality" />
<Rating text="Quality" />
</Divider>
<Divider>
<BasicAlerts text="This is an sample alert" />
<Alert text="This is an sample alert" />
</Divider>
</>
);
Expand Down
3 changes: 1 addition & 2 deletions src/components/common/alert/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@ import Alert from '@mui/material/Alert';
import Stack from '@mui/material/Stack';
import { BasicAlertsProps } from 'models/interfaces/types';

const BasicAlerts: React.FC<BasicAlertsProps> = (props: BasicAlertsProps) => {
const { text } = props;
const BasicAlerts: React.FC<BasicAlertsProps> = ({ text }: BasicAlertsProps) => {
return (
<Stack sx={{ width: '100%', marginTop: "5px" }} spacing={2}>
<Alert severity="error">{text}</Alert>
Expand Down
4 changes: 4 additions & 0 deletions src/components/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export { default as Home } from "./section/home/index";
export { default as About } from "./section/about/index";
export { default as Alert } from "./common/alert/index";
export { default as Rating } from "./common/rating/index";
7 changes: 7 additions & 0 deletions src/components/section/about/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React, { ReactElement } from "react"

const About: React.FC = (): ReactElement => {
return <h1>About</h1>
}

export default About;
7 changes: 7 additions & 0 deletions src/components/section/home/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React, { ReactElement } from "react"

const Home: React.FC = (): ReactElement => {
return <h1>Home</h1>
}

export default Home;
9 changes: 9 additions & 0 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// You can set your configuration here

const config = {
app: {
baseURL: process.env.REACT_APP_BASE_URL
}
}

export default config;
11 changes: 11 additions & 0 deletions src/models/interfaces/types.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
/* eslint-disable camelcase */
export interface BasicRatingProps {
text: string
}

export interface ExampleResponse {
id: number;
uid: string;
account_number: string;
iban: string;
bank_name: string;
routing_number: string;
swift_bic: string;
}

export type BasicAlertsProps = BasicRatingProps
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
const API_URL = window.config.baseUrl;
import config from "config/index";

const API_URL = config.app.baseURL || "";

/**
* The options used to configure the API.
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/services/api.ts → src/services/api/api.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ApisauceInstance, create } from "apisauce";
import { ApiConfig, DEFAULT_API_CONFIG } from "./api-config";
import { ExampleApi } from "./example";
import { ExampleApi } from "../index";

/**
* Manages all requests to the API.
Expand Down
21 changes: 10 additions & 11 deletions src/services/example.ts → src/services/example/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ApiResponse } from "apisauce";
import { Api } from "./api";
import { getGeneralApiProblem } from "./api-problem";
import { ExampleResponse } from "models/interfaces/types";
import { Api } from "../api/api";
import { getGeneralApiProblem } from "../api/api-problem";

export class ExampleApi {
private api: Api;
Expand All @@ -9,10 +10,10 @@ export class ExampleApi {
this.api = api;
}

async getExample(): Promise<any> {
async getExample() {
try {
const response: ApiResponse<never> = await this.api.apisauce.get(
`your/route`
`bank/random_bank`
);
if (!response.ok) {
const problem = getGeneralApiProblem(response);
Expand All @@ -26,7 +27,7 @@ export class ExampleApi {
}
}

async postExample(payload: any): Promise<any> {
async postExample(payload: ExampleResponse) {
try {
const response: ApiResponse<never> = await this.api.apisauce.post(
`your/route`, { payload }
Expand All @@ -43,10 +44,10 @@ export class ExampleApi {
}
}

async putExample(id: any): Promise<any> {
async putExample(id: string, payload: ExampleResponse) {
try {
const response: ApiResponse<never> = await this.api.apisauce.put(
`your/route/${id}`
`your/route/${id}`, payload
);
if (!response.ok) {
const problem = getGeneralApiProblem(response);
Expand All @@ -60,7 +61,7 @@ export class ExampleApi {
}
}

async deleteExample(id: any): Promise<any> {
async deleteExample(id: string) {
try {
const response: ApiResponse<never> = await this.api.apisauce.delete(
`your/route/${id}`
Expand All @@ -77,6 +78,4 @@ export class ExampleApi {
}
}

}


}
1 change: 1 addition & 0 deletions src/services/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./example/index";
9 changes: 9 additions & 0 deletions src/test/App.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import App from '../App';

test('renders the home pag', () => {
render(<App />);
const linkElement = screen.getByText("React + TS + Sass + Eslint + Prettier + MobX + Apisauce");
expect(linkElement).toBeInTheDocument();
});
1 change: 1 addition & 0 deletions src/theme/_fonts.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Fonts are declared here
1 change: 1 addition & 0 deletions src/theme/_layout.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// General layout styles are declared here
1 change: 1 addition & 0 deletions src/theme/_variables.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Variables go here

0 comments on commit 7e778a5

Please sign in to comment.