Skip to content

Commit 119f3f5

Browse files
committed
Initial Commit
0 parents  commit 119f3f5

23 files changed

+2678
-0
lines changed

.env

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# NEXT_PUBLIC_* variables can be used on client side
2+
# Replace it with your App Key
3+
NEXT_PUBLIC_APP_KEY=<Your-App-Key>
4+
5+
# Cannot be accessible on client side
6+
# Replace it with your App Secret
7+
APP_SECRET=<Your-App-Secret>
8+
9+
DEPLOY_URL=<NGROK_URL gor local or Your-App-Deployment-Address for production>

.eslintrc.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "next/core-web-vitals"
3+
}

.gitignore

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
2+
3+
# dependencies
4+
/node_modules
5+
/.pnp
6+
.pnp.js
7+
8+
# testing
9+
/coverage
10+
11+
# next.js
12+
/.next/
13+
/out/
14+
15+
# production
16+
/build
17+
18+
# misc
19+
.DS_Store
20+
*.pem
21+
22+
# debug
23+
npm-debug.log*
24+
yarn-debug.log*
25+
yarn-error.log*
26+
.pnpm-debug.log*
27+
28+
# local env files
29+
.env.local
30+
.env.development.local
31+
.env.test.local
32+
.env.production.local
33+
34+
# vercel
35+
.vercel
36+
37+
# typescript
38+
*.tsbuildinfo

@types/http.d.ts

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { Session } from 'next-iron-session';
2+
3+
declare module 'http' {
4+
export interface IncomingMessage {
5+
session: Session;
6+
user?: {
7+
merchantId: string;
8+
authorizedAppId: string;
9+
};
10+
}
11+
}

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2022 ikascom
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
This is a [Next.js](https://nextjs.org/) project bootstrapped with [`create-next-app`](https://github.com/vercel/next.js/tree/canary/packages/create-next-app).
2+
3+
## Getting Started
4+
5+
First, run the development server:
6+
7+
```bash
8+
npm run dev
9+
# or
10+
yarn dev
11+
```
12+
13+
Open [http://localhost:3000](http://localhost:3000) with your browser to see the result.
14+
15+
You can start editing the page by modifying `pages/index.tsx`. The page auto-updates as you edit the file.
16+
17+
[API routes](https://nextjs.org/docs/api-routes/introduction) can be accessed on [http://localhost:3000/api/hello](http://localhost:3000/api/hello). This endpoint can be edited in `pages/api/hello.ts`.
18+
19+
The `pages/api` directory is mapped to `/api/*`. Files in this directory are treated as [API routes](https://nextjs.org/docs/api-routes/introduction) instead of React pages.
20+
21+
## Learn More
22+
23+
To learn more about Next.js, take a look at the following resources:
24+
25+
- [Next.js Documentation](https://nextjs.org/docs) - learn about Next.js features and API.
26+
- [Learn Next.js](https://nextjs.org/learn) - an interactive Next.js tutorial.
27+
28+
You can check out [the Next.js GitHub repository](https://github.com/vercel/next.js/) - your feedback and contributions are welcome!
29+
30+
## Deploy on Vercel
31+
32+
The easiest way to deploy your Next.js app is to use the [Vercel Platform](https://vercel.com/new?utm_medium=default-template&filter=next.js&utm_source=create-next-app&utm_campaign=create-next-app-readme) from the creators of Next.js.
33+
34+
Check out our [Next.js deployment documentation](https://nextjs.org/docs/deployment) for more details.

globals/config.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export const config = {
2+
appId: process.env.NEXT_PUBLIC_APP_KEY || '',
3+
appSecret: process.env.APP_SECRET || '',
4+
// Api access scopes will be used to start oauth2 flow
5+
// Update scopes according to app requirements
6+
scope: 'read_products,write_products',
7+
deployUrl: process.env.DEPLOY_URL || 'http://localhost:3000',
8+
callbackUrl: (process.env.DEPLOY_URL || 'http://localhost:3000') + '/api/oauth/callback',
9+
};

next-env.d.ts

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/// <reference types="next" />
2+
/// <reference types="next/image-types/global" />
3+
4+
// NOTE: This file should not be edited
5+
// see https://nextjs.org/docs/basic-features/typescript for more information.

next.config.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/** @type {import('next').NextConfig} */
2+
const nextConfig = {
3+
reactStrictMode: true,
4+
}
5+
6+
module.exports = nextConfig

package.json

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "ikas-sample-app-nextjs",
3+
"version": "0.1.0",
4+
"private": true,
5+
"scripts": {
6+
"dev": "next dev",
7+
"build": "next build",
8+
"start": "next start",
9+
"lint": "next lint"
10+
},
11+
"dependencies": {
12+
"@ikas/api-client": "^1.0.4-alpha.4",
13+
"@ikas/app-helpers": "^1.0.1-alpha.12",
14+
"ioredis": "^4.28.5",
15+
"jsonwebtoken": "^8.5.1",
16+
"moment": "^2.29.1",
17+
"next": "12.1.0",
18+
"next-connect": "^0.12.2",
19+
"react": "17.0.2",
20+
"react-dom": "17.0.2",
21+
"sass": "^1.49.9",
22+
"uuid": "^8.3.2"
23+
},
24+
"devDependencies": {
25+
"@types/ioredis": "^4.28.8",
26+
"@types/jsonwebtoken": "^8.5.8",
27+
"@types/moment": "^2.13.0",
28+
"@types/node": "^17.0.21",
29+
"@types/react": "17.0.39",
30+
"@types/uuid": "^8.3.4",
31+
"eslint": "8.10.0",
32+
"eslint-config-next": "12.1.0",
33+
"prettier": "^2.5.1",
34+
"typescript": "4.6.2"
35+
},
36+
"prettier": {
37+
"semi": true,
38+
"trailingComma": "all",
39+
"singleQuote": true,
40+
"printWidth": 150,
41+
"tabWidth": 2,
42+
"bracketSpacing": true
43+
}
44+
}

pages/_app.tsx

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import '../styles/globals.scss';
2+
import type { AppProps } from 'next/app';
3+
import Head from 'next/head';
4+
5+
function MyApp({ Component, pageProps }: AppProps) {
6+
return (
7+
<>
8+
<Head>
9+
<title>My Awesome ikas App</title>
10+
<link rel="icon" href="/favicon.ico" />
11+
</Head>
12+
<div>
13+
<Component {...pageProps} />
14+
</div>
15+
</>
16+
);
17+
}
18+
19+
export default MyApp;

pages/authorize-store.tsx

+41
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import type { NextPage } from 'next';
2+
import styles from '../styles/AuthorizeStore.module.scss';
3+
import { useEffect, useState } from 'react';
4+
5+
const AuthorizeStore: NextPage = () => {
6+
const [storeName, setStoreName] = useState<string | null>(null);
7+
const [showError, setShowError] = useState<boolean>(false);
8+
9+
useEffect(() => {
10+
const params = new URLSearchParams(window.location.search);
11+
if (params.has('status') && params.get('status') == 'fail') {
12+
setShowError(true);
13+
}
14+
if (params.has('storeName')) {
15+
setStoreName(params.get('storeName'));
16+
}
17+
}, []);
18+
19+
return (
20+
<main className={styles.main}>
21+
<div className={styles.container}>
22+
<img className={styles.logo} src="/logo.png" alt="ikas Logo" />
23+
<form method={'GET'} action={'/api/oauth/authorize'}>
24+
<input
25+
name={'storeName'}
26+
className={styles.input}
27+
placeholder={'Enter your store name...'}
28+
value={storeName || ''}
29+
onChange={(event) => setStoreName(event.target.value)}
30+
/>
31+
<button type="submit" className={styles.button} disabled={!storeName}>
32+
Add to My Store
33+
</button>
34+
{showError && <div className={styles.error}>Unexpected error occurred</div>}
35+
</form>
36+
</div>
37+
</main>
38+
);
39+
};
40+
41+
export default AuthorizeStore;

pages/dashboard.tsx

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import type { NextPage } from 'next';
2+
import styles from '../styles/Dashboard.module.scss';
3+
4+
const Home: NextPage = () => {
5+
return (
6+
<main className={styles.main}>
7+
<div className={styles.container}>
8+
<div className={styles.title}>Success!</div>
9+
</div>
10+
</main>
11+
);
12+
};
13+
14+
export default Home;

pages/index.tsx

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { NextPage } from 'next';
2+
import styles from '../styles/Home.module.scss';
3+
4+
const Home: NextPage = () => {
5+
return (
6+
<main className={styles.main}>
7+
<div>Please wait...</div>
8+
</main>
9+
);
10+
};
11+
12+
export default Home;

public/favicon.ico

104 KB
Binary file not shown.

public/logo.png

21.7 KB
Loading

public/logo.svg

+15
Loading

styles/AuthorizeStore.module.scss

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
.main {
2+
min-height: 100vh;
3+
flex: 1;
4+
display: flex;
5+
flex-direction: column;
6+
justify-content: center;
7+
align-items: center;
8+
padding-bottom: 20%;
9+
10+
.container {
11+
display: flex;
12+
flex-direction: column;
13+
justify-content: center;
14+
align-items: center;
15+
width: 400px;
16+
17+
.logo {
18+
max-width: 200px;
19+
margin-bottom: 48px;
20+
}
21+
22+
.input {
23+
width: 100%;
24+
margin-bottom: 24px;
25+
font-size: 32px;
26+
padding: 8px;
27+
border: none;
28+
background-color: transparent;
29+
border-bottom: 3px solid var(--color-border);
30+
text-align: center;
31+
transition: 0.3s border-color;
32+
33+
&:focus, &:focus-visible {
34+
outline-color: transparent;
35+
border-color: var(--color-purple);
36+
37+
&::placeholder {
38+
opacity: 0;
39+
}
40+
}
41+
42+
&::placeholder {
43+
color: var(--color-placeholder);
44+
transition: 0.15s opacity;
45+
}
46+
47+
&:not(:placeholder-shown) {
48+
border-color: var(--color-purple);
49+
}
50+
}
51+
52+
.button {
53+
width: 100%;
54+
font-weight: 500;
55+
font-size: 20px;
56+
padding: 8px;
57+
border-radius: 4px;
58+
59+
color: white;
60+
background-color: var(--color-purple);
61+
border: 1px solid white;
62+
cursor: pointer;
63+
user-select: none;
64+
transition: .3s opacity;
65+
66+
&:hover {
67+
opacity: .8;
68+
}
69+
70+
&:disabled {
71+
cursor: not-allowed;
72+
pointer-events: none;
73+
opacity: .3;
74+
}
75+
}
76+
77+
.error {
78+
color: #c41111;
79+
font-size: 16px;
80+
text-align: center;
81+
margin-top: 12px;
82+
}
83+
84+
@media (max-width: 500px) {
85+
width: 90%;
86+
87+
.input {
88+
font-size: 24px;
89+
}
90+
91+
.button {
92+
font-size: 20px;
93+
}
94+
}
95+
}
96+
}

0 commit comments

Comments
 (0)