Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accept payment #48

Open
wants to merge 86 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 9 commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
7c883e2
acceptance page
gideonnnalue Sep 8, 2022
e0d9ad2
code block component enhancement and cleanup
gideonnnalue Sep 10, 2022
2912e73
accept page filled
gideonnnalue Sep 10, 2022
118b461
removed unsused package
gideonnnalue Sep 12, 2022
c477dff
fixed prop on codeblock
gideonnnalue Sep 12, 2022
6178994
source code font
gideonnnalue Sep 12, 2022
19981dd
important code font
gideonnnalue Sep 12, 2022
1dffa6e
rename source code folder
gideonnnalue Sep 12, 2022
eb216b2
renamed source code folder to default
gideonnnalue Sep 12, 2022
e4c8073
feat: verify page
gideonnnalue Sep 13, 2022
16e9b07
table issue
gideonnnalue Sep 13, 2022
80ad896
Merge branch 'accept-payment' of github.com:LazerPay-Finance/Lazerpay…
gideonnnalue Sep 13, 2022
3fa9162
modified table colors
gideonnnalue Sep 13, 2022
992b746
chore: add alert to page
gideonnnalue Sep 13, 2022
a0b284a
verify payment page
gideonnnalue Sep 13, 2022
346279a
code blocks data
gideonnnalue Sep 13, 2022
3cedd9a
page title data
gideonnnalue Sep 13, 2022
3a5b37e
webhook page
gideonnnalue Sep 13, 2022
cdfba2b
feat: create payment link page
gideonnnalue Sep 13, 2022
f5cb086
library section page
gideonnnalue Sep 15, 2022
289d0ed
feat: add crypto-transfers mdc
Palmlight Sep 16, 2022
d795e4f
bug: fix pagination
gideonnnalue Sep 16, 2022
ccd9b5e
fix: build error
gideonnnalue Sep 16, 2022
dca9152
feat: complete transfers
Palmlight Sep 16, 2022
0b2fb09
feat: add webhook transfers
Palmlight Sep 19, 2022
d6ff5cc
Merge pull request #53 from LazerPay-Finance/pagination-fix
Frontend-io Sep 19, 2022
dd4b6be
Merge branch 'main' into accept-payment
gideonnnalue Sep 19, 2022
8c5827f
update code block snippets
gideonnnalue Sep 19, 2022
3747458
Merge branch 'accept-payment' of github.com:LazerPay-Finance/Lazerpay…
gideonnnalue Sep 19, 2022
88a2576
updated snippet
gideonnnalue Sep 19, 2022
a90f78e
code structure change
gideonnnalue Sep 19, 2022
ce22521
indent code
gideonnnalue Sep 19, 2022
6f8405b
indent code
gideonnnalue Sep 19, 2022
fe5481d
indentatioon error
gideonnnalue Sep 19, 2022
6919806
libraries-page
gideonnnalue Sep 19, 2022
57ea2c6
libraries-page revert
gideonnnalue Sep 19, 2022
f41947d
Merge branch 'accept-payment' into verify-payment
gideonnnalue Sep 19, 2022
265b7be
Merge branch 'accept-payment' into webhooks-page
gideonnnalue Sep 19, 2022
71c2228
Merge branch 'accept-payment' into payment-links-page
gideonnnalue Sep 19, 2022
8278c04
Merge branch 'accept-payment' into libraries-page
gideonnnalue Sep 19, 2022
bc57ed2
feat: add transfers to accept payments
Palmlight Sep 19, 2022
775d371
Merge pull request #54 from LazerPay-Finance/transfers
Palmlight Sep 19, 2022
7a0eee1
Merge branch 'accept-payment' into verify-payment
gideonnnalue Sep 19, 2022
1aadad0
Merge pull request #49 from LazerPay-Finance/verify-payment
gideonnnalue Sep 19, 2022
73f2535
Merge branch 'accept-payment' into webhooks-page
gideonnnalue Sep 19, 2022
687a56e
Merge pull request #50 from LazerPay-Finance/webhooks-page
gideonnnalue Sep 19, 2022
f09e1e0
Merge branch 'accept-payment' into payment-links-page
gideonnnalue Sep 19, 2022
b58ffe0
fix comma on snippet
gideonnnalue Sep 19, 2022
4afdf95
Merge pull request #51 from LazerPay-Finance/payment-links-page
gideonnnalue Sep 19, 2022
44b3d25
fix build errors
gideonnnalue Sep 19, 2022
e6c8f9f
Merge pull request #52 from LazerPay-Finance/libraries-page
gideonnnalue Sep 19, 2022
4b62bc6
fix: added pagination component to layout
gideonnnalue Sep 19, 2022
4374478
chore: category type sidebar
gideonnnalue Sep 19, 2022
4e15b12
fixed links and unsused components
gideonnnalue Sep 20, 2022
11c6232
feat: reaction response
gideonnnalue Sep 28, 2022
5465142
chore: fix links and js snippets
gideonnnalue Sep 28, 2022
0e7649c
chore: code cleanup
gideonnnalue Sep 28, 2022
0768b13
feat: swap pages
gideonnnalue Sep 29, 2022
973b633
chore: fix styling issue
gideonnnalue Sep 29, 2022
3113ca3
fix: source code font change
gideonnnalue Sep 29, 2022
5858baf
transaction, customer, swap and product pages
gideonnnalue Oct 4, 2022
8327a68
fix toast issues
gideonnnalue Oct 6, 2022
6c2784a
adjust toast
gideonnnalue Oct 6, 2022
f2b340c
toast adjust
gideonnnalue Oct 7, 2022
a5ee800
Standard and Donation payment link
gideonnnalue Oct 10, 2022
3979e83
change toast
gideonnnalue Oct 11, 2022
1f3d940
change toast
gideonnnalue Oct 11, 2022
f66802c
change toast
gideonnnalue Oct 11, 2022
90f33ec
change toast
gideonnnalue Oct 11, 2022
9f91dd9
change toast
gideonnnalue Oct 11, 2022
ad448ed
change toast
gideonnnalue Oct 11, 2022
b31253c
change toast
gideonnnalue Oct 11, 2022
108a3d0
test toast
gideonnnalue Oct 11, 2022
d0e4805
fix toast
gideonnnalue Oct 11, 2022
51c4171
fix toast
gideonnnalue Oct 11, 2022
6fb7ef8
fix toast
gideonnnalue Oct 11, 2022
101a456
fix toast
gideonnnalue Oct 11, 2022
6e76d13
fix toast
gideonnnalue Oct 11, 2022
d730ed9
fix toast
gideonnnalue Oct 11, 2022
f0a89f8
fix toast bug and update documentation
gideonnnalue Oct 12, 2022
ec3cb95
fix url issue
gideonnnalue Oct 12, 2022
fb2256a
fix typo
gideonnnalue Oct 12, 2022
4954b4a
fix page content
gideonnnalue Oct 16, 2022
4bb5693
reinitiate deployment
gideonnnalue Oct 17, 2022
f139cab
quick start page
gideonnnalue Oct 17, 2022
13f34ff
fix payment link
gideonnnalue Oct 19, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
"semi": false,
"singleQuote": true,
"tabWidth": 2,
"trailingComma": "all"
}
"trailingComma": "all",
"useTabs": false
}
2 changes: 1 addition & 1 deletion components/AcceptPayments/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default function AcceptPayments(): JSX.Element {
</LzButton>
</div>
<div className="lg:max-w-lg xl:max-w-xl xl:w-4/6 bg-pri-50">
<CodeBlock id="api" />
{/* <CodeBlock id="api" /> */}
</div>
</section>
)
Expand Down
30 changes: 30 additions & 0 deletions components/CodeBlock/components/RequestHead.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import cn from "classnames";
import { LzCodeSelect, LzToggle } from "components";
import { RequestData, RequestType } from "../types";

const RequestHead = (props: RequestData) => {
const { method = undefined, requestData, showResponse, onChange, toggleResponse } = props;
const { name } = requestData as RequestType;
const options = {
'POST': 'bg-suc-100',
'GET': ''
}
return (
<div className='bg-neu-50'>
<div className='px-8 py-2.5 flex justify-between'>
<div className='flex items-center font-proxima'>
{method && <span className={cn('uppercase text-neu-700 caption-s rounded-8 px-2.5 py-1 text-xs h-fit mr-4', options[method])}>{method}</span>}
{name.length > 1 && <LzCodeSelect onChange={onChange} items={name} />}
</div>
<div className='flex items-center'>
<span className='text-sm font-semibold leading-5 font-proxima text-neu-600 mr-3.5'>
{showResponse ? 'Hide Response' : 'Show Response'}
</span>
<LzToggle state={showResponse} onChange={toggleResponse} />
</div>
</div>
</div>
)
}

export default RequestHead;
27 changes: 27 additions & 0 deletions components/CodeBlock/components/ResponseHead.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { LzCodeSelect } from "components";
import { ItemType } from "../types";

export type ResponseProp = {
title: string;
item: ItemType;
onChange: (i: number) => void;
}

const ResponseHead = (props: ResponseProp) => {
const { title, item, onChange } = props;
const { name } = item as ItemType;
return (
<div className='bg-neu-50'>
<div className='px-8 py-2.5 flex justify-between border-b border-neu-200'>
<div className='flex items-center'>
<h4 className='text-sm font-proxima font-semibold text-neu-600'>{title || 'Response'}</h4>
</div>
<div className='flex items-center'>
{item.name.length > 1 ? <LzCodeSelect onChange={onChange} items={name} /> : null}
</div>
</div>
</div>
)
}

export default ResponseHead
39 changes: 39 additions & 0 deletions components/CodeBlock/components/TabHead.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { useState, MouseEvent } from "react";
import cn from "classnames";

export type TabProps = {
items: string[];
onChange: (i: number) => void;
}

const TabHead = (props: TabProps) => {
const { items, onChange } = props;
const [active, setActive] = useState<number>(0);

const tabItemClassName = (i: number): string => {
return cn('py-3.5 px-2.5 text-neu-400 relative mr-4', { 'text-pri-600': i === active })
}

const onTabClicked = (e: MouseEvent<HTMLButtonElement>): void => {
e.preventDefault();
const { dataset } = e.target as HTMLButtonElement;
setActive(Number(dataset.value));
onChange(Number(dataset.value))
}
return (
<div className='bg-white'>
<ul className='flex items-center px-8 font-proxima'>
{items.map((title: string, i: number) => (
<li key={title} className={tabItemClassName(i)}>
<button type='button' aria-label={title} data-value={i} onClick={onTabClicked}>{title}</button>
{i === active && (
<div className='absolute bottom-0 left-0 w-full h-1 bg-pri-500 rounded-t-2xl'></div>
)}
</li>
))}
</ul>
</div>
)
}

export default TabHead;
3 changes: 3 additions & 0 deletions components/CodeBlock/components/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { default as RequestHead } from './RequestHead';
export { default as ResponseHead } from './ResponseHead';
export { default as TabHead } from './TabHead';
49 changes: 49 additions & 0 deletions components/CodeBlock/configurePrism.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
const initializePrism = (Prism) => {
Prism.languages.json = {
'property': {
pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?=\s*:)/,
lookbehind: true,
greedy: true
},
'string': {
pattern: /(^|[^\\])"(?:\\.|[^\\"\r\n])*"(?!\s*:)/,
lookbehind: true,
greedy: true
},
'comment': {
pattern: /\/\/.*|\/\*[\s\S]*?(?:\*\/|$)/,
greedy: true
},
'number': /-?\b\d+(?:\.\d+)?(?:e[+-]?\d+)?\b/i,
'punctuation': /[{}[\],]/,
'operator': /:/,
'boolean': /\b(?:false|true)\b/,
'null': {
pattern: /\bnull\b/,
alias: 'keyword'
}
};

Prism.languages.curl = {
'curl': /\bcurl\b/,
'url': /https?:[a-zA-Z0-9:.?=\/\-_{}]*/,
'parameter': {
pattern: /[A-Za-z0-9\[\]-_]+ *(?=[=])/,
},
'value': [{
pattern: /([=])([A-Za-z0-9-_.]*)/,
lookbehind: true,
}, {
pattern: /(["'])(\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,
}, {
pattern: /(\-u )([A-Za-z0-9-_.{}]*)/,
lookbehind: true,
}],
'punctuation': /[{}['’\],]/,
'method': /(?:POST|GET|PATCH)/g,
'option': / *--[a-zA-Z-]*\b/,
};

Prism.languages.webmanifest = Prism.languages.json;
}
export { initializePrism };
42 changes: 42 additions & 0 deletions components/CodeBlock/hooks/useStateSnippet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { snippets } from 'data/snippets';
import { useState, useEffect } from 'react';

import { ItemType, RequestData, RequestType } from '../types';

export type StateSnippetProps = {
type: any;
item: any;
}

export type StateSnippetTypes = {
language: string;
codeSnippet: string;
updateSnippet: any;
}

const useStateSnippet = ({ type, item }: StateSnippetProps): StateSnippetTypes => {
const [codeSnippet, setCodeSnippet] = useState<string>("");
const [language, setLanguage] = useState<string>("jsx");

const updateSnippet = (snippet, lang) => {
setCodeSnippet(snippet);
setLanguage(lang);
}

useEffect(() => {
if (type === 'tab') {
updateSnippet(snippets[(item as ItemType).snippet[0]], (item as ItemType).lang[0]);
}
if (type === 'request') {
const { requestData } = item as RequestData;
updateSnippet(snippets[(requestData as RequestType).snippet[0]], (requestData as RequestType).lang[0])
}
if (type === 'response') {
updateSnippet(snippets[(item as ItemType).snippet[0]], 'json');
}
}, []);

return { language, codeSnippet, updateSnippet };
}

export default useStateSnippet;
22 changes: 19 additions & 3 deletions components/CodeBlock/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,31 @@
position: absolute;
top: -100px;
}

/* Track */
::-webkit-scrollbar-track {
background-color: #FFF;
position: absolute;
}

/* Handle */
::-webkit-scrollbar-thumb {
background: #C2C2C2;
background: #C2C2C2;
border-radius: 50px;
position: absolute;
}
}

.select {
box-shadow: 0px 0px 1px rgba(12, 26, 75, 0.24), 0px 3px 8px -1px rgba(50, 50, 71, 0.05);
visibility: hidden;
top: 1.9rem;
opacity: 0;
transition: all .1s ease-out;
}

.selectActive {
visibility: visible;
top: 1.3rem;
opacity: 1;
}
102 changes: 67 additions & 35 deletions components/CodeBlock/index.tsx
Original file line number Diff line number Diff line change
@@ -1,52 +1,84 @@
import { useEffect } from 'react'
import Prism from 'prismjs'
import { useEffect, useState, FC } from 'react'
import Prism from 'prismjs';
import { CopyToClipboard } from 'react-copy-to-clipboard';
import cn from 'classnames';

import 'prismjs/components/prism-jsx.js'
import 'prismjs/plugins/line-numbers/prism-line-numbers.js'
import 'prismjs/plugins/line-numbers/prism-line-numbers.css'
import Styles from './index.module.scss';
import { snippets } from 'data/snippets'
import classNames from 'classnames'

interface IProps {
id?: string;
req?: string;
lang?: string;
children?: React.ReactNode
import { snippets } from 'data/snippets';

import { RequestHead, ResponseHead, TabHead } from './components';
import { ItemType, RequestType, RequestData, DataProp } from './types';
import { initializePrism } from './configurePrism';
import useStateSnippet from './hooks/useStateSnippet';

initializePrism(Prism);

export interface CodeBlockProps<DataProp> {
responseTheme?: 'default' | 'red';
responseTitle?: string;
data: DataProp;
}

const Label = ({ label }) => {
const options = {
'POST': 'bg-suc-100'
const CodeBlock: FC<CodeBlockProps<DataProp>> = (props) => {
const { data, responseTheme, responseTitle } = props;
const { type, item } = data as DataProp;

const { codeSnippet, language, updateSnippet } = useStateSnippet({ type, item });
const [copied, setCopied] = useState<boolean>(false);
const [showResponse, setShowResponse] = useState<boolean>(true);

const onCodeSwitch = (i: number, items: ItemType | RequestType): void => {
updateSnippet(snippets[(items as ItemType).snippet[i]], (items as ItemType).lang[i]);
}

return (
<div className={classNames(
options[label],
'uppercase text-neu-700 caption-s rounded-8 px-2.5 py-1')}>
{label}
</div>
)
};
const onCopy = (): void => {
setCopied(true);
setTimeout(() => {
setCopied(false);
}, 2000)
}

export default function CodeBlock({ id, lang = 'jsx', req = 'POST' }: IProps) {
const codeSnippet = snippets[id] || 'snippet not found';
// const title = Object.keys(snippets).find(s => s === id);
const responseThemeClassname = (): string => {
if (type === 'response') {
return responseTheme === 'default' ? 'code--default' : 'code--red';
}
return 'code';
}

const codeBg = (): string => {
return type === 'response' ? 'response' : 'default'
}

useEffect(() => {
Prism.highlightAll()
}, [])
if (typeof window !== undefined) {
Prism.highlightAll()
}
}, [codeSnippet])

return (
<div className={classNames(Styles.CodeBlock, 'flex font-code pb-2 bg-white flex-col')}>
<div className='flex items-center px-10 py-4 space-x-5 bg-neu-50 head rounded-t-8'>
<Label label={req} />
<div>
<div className={cn(Styles.CodeBlock, 'flex font-code overflow-hidden bg-white flex-col')}>
{type === 'tab' && <TabHead items={(item as ItemType).name} onChange={(i: number) => onCodeSwitch(i, item as ItemType)} />}
{type === 'request' && <RequestHead showResponse={showResponse} toggleResponse={(state: boolean) => setShowResponse(state)} {...item as RequestData} onChange={(i: number) => onCodeSwitch(i, (item as RequestData).requestData)} />}
{type === 'response' && <ResponseHead title={responseTitle} item={(item as ItemType)} onChange={(i: number) => onCodeSwitch(i, (item as ItemType))} />}
<div className='Code p-0 relative'>
<CopyToClipboard onCopy={onCopy} text={codeSnippet}>
<button
type='button'
className='text-xs text-white py-1 px-2.5 bg-neu-800 rounded-lg absolute right-8 top-4 z-[5] font-proxima'
>{copied ? 'Copied' : 'Copy'}</button>
</CopyToClipboard>
<pre className={cn('!my-0 line-numbers', codeBg())}>
<code className={cn(`language-${language} font-code`, responseThemeClassname(), codeBg())}>{codeSnippet}</code>
</pre>
</div>
</div>
<code>
<pre className="!my-0 line-numbers">
<code className={classNames(`language-${lang}`)}>{codeSnippet}</code>
</pre>
</code>
{(type === 'request' && showResponse) && <div className='mt-5'><CodeBlock responseTheme={responseTheme} responseTitle={responseTitle} data={{ type: 'response', item: (item as RequestData).responseData }} /></div>}
</div>
)
};
};

export default CodeBlock;
Loading