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

Feature/order #19

Merged
merged 70 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
189bb8c
feat(AuthPage, AuthLayout, assets): keep authpage, change authLayout …
TanNguyen17112003 Sep 15, 2023
92ae9cf
feat(formValidate): config AuthLayout, AuthPage, loginForm; add valid…
TanNguyen17112003 Sep 16, 2023
9d1e871
feat(AuthPage, validateSchema): move validateSchema, change arrowFunc…
TanNguyen17112003 Sep 18, 2023
0ccbef6
Merge branch 'feature/auth' of github.com:TickLabVN/ssps-fe into feat…
ngyngcphu Sep 18, 2023
e2b5cca
feat(auth): create router template and change return type of /api/user
ngyngcphu Sep 19, 2023
00ad52c
fix(async-await): add prefix await before getUserData function and re…
ngyngcphu Sep 19, 2023
7d3d546
ci(workflows): add jobs for staging and production
ngyngcphu Sep 20, 2023
dca3586
Merge pull request #3 from TickLabVN/feature/auth
ngyngcphu Sep 20, 2023
63017c7
feat(navigation): create template for navigation bar
ngyngcphu Sep 20, 2023
78c9932
Merge pull request #4 from TickLabVN/sub-feature/navigation
ngyngcphu Sep 20, 2023
c3ef3cd
feat(home_page): add component Orders, Slides, images and Edit Homepa…
TanNguyen17112003 Sep 21, 2023
46f1903
feat(Orders): edit useRef value
TanNguyen17112003 Sep 21, 2023
0d1c4dc
Merge pull request #9 from TickLabVN/feature/home
TanNguyen17112003 Sep 21, 2023
931500a
refactor(component): divide sub folder in src/components and remove j…
ngyngcphu Sep 23, 2023
5c21b1d
chore(server): create a mock-server to fake API
ngyngcphu Sep 23, 2023
9124008
refactor(flow): create flow-call API from types, services, states
ngyngcphu Sep 23, 2023
a50e800
feat(navigation_bar): edit AppNavigation, AppDrawer and ToglleSidebarBtn
Minhtuei Sep 23, 2023
a6357a6
refactor(HomePage): limit the use of HTML in React
ngyngcphu Sep 23, 2023
b034d0f
feat(add_ux_sidebar): add ux for sidebar&navbar, resolve merge confli…
Minhtuei Sep 26, 2023
e1e67ed
refactor(side-nav-bar): implement navigation logic and add closure hook
ngyngcphu Sep 30, 2023
c598c69
Merge pull request #10 from TickLabVN/sub-feature/navigation
ngyngcphu Sep 30, 2023
c9e391b
feat(template): create choose-file-box and upload-document-box template
ngyngcphu Sep 30, 2023
96b899a
fix(form-ux): create smoothness between nested dialogs
ngyngcphu Oct 1, 2023
a4f6dab
refactor(folder structure): add folder order in component
ngyngcphu Oct 1, 2023
96f29ee
feat(order): create workflows template for order printing
ngyngcphu Oct 1, 2023
8904e71
fix(naming): rename Form, Box in component/order
ngyngcphu Oct 1, 2023
29a7c41
feat(order): create templates for 2 form: wallet and order-success
ngyngcphu Oct 1, 2023
44ce0b0
chore(comment): rename owner's task
ngyngcphu Oct 1, 2023
26ac74d
Merge pull request #12 from TickLabVN/sub-feature/top-up-wallet
ngyngcphu Oct 1, 2023
ab5a0c8
feat(ChooseFileBox): release Upload file component
MLAkainu Oct 1, 2023
6990ec0
test(preview): create TestPreviewPage to test preview document
ngyngcphu Oct 1, 2023
b30bfc9
fix(ChooseFileBox): fix choose file component
MLAkainu Oct 2, 2023
0fe7b8a
fix(choosefilebox): fix some lg desktop but I don't fix width Dialogb…
MLAkainu Oct 2, 2023
3fcb277
feat(orders): no changes
TanNguyen17112003 Oct 3, 2023
8baf29e
feat(order): no changes
TanNguyen17112003 Oct 3, 2023
8b1c4d4
chore(mock-server): fake file-server to upload file
ngyngcphu Oct 7, 2023
2ce2073
feat: implement TestPreviewPage, remove Auth to test on mock-server
qmi03 Oct 8, 2023
34754ba
fix(mobile_box): fix choose file mobile
MLAkainu Oct 9, 2023
acdd30e
fix(format_tailwind): fix width heigth format
MLAkainu Oct 9, 2023
b20a177
feat(three_order_form): implement 3 forms and add some types
TanNguyen17112003 Oct 9, 2023
d739480
feat(file): preview image after uploading
ngyngcphu Oct 12, 2023
c763152
Merge branch 'sub-feature/preview-document' of github.com:TickLabVN/s…
ngyngcphu Oct 12, 2023
a4f45c5
test(file): preview pdf file after uploading
ngyngcphu Oct 12, 2023
23c5877
test(file): fix unknown prop in styled-component and valid prop in is…
ngyngcphu Oct 12, 2023
c914762
feat(file): complete uploading and previewing file
ngyngcphu Oct 12, 2023
ca2fa16
Merge pull request #14 from TickLabVN/sub-feature/choose-file-to-print
ngyngcphu Oct 12, 2023
47552f8
Merge pull request #11 from TickLabVN/feature/home
ngyngcphu Oct 12, 2023
6327d92
Merge branch 'feature/order' of github.com:TickLabVN/ssps-fe into fea…
ngyngcphu Oct 12, 2023
1d962a3
feat(preview-docs): add preview document form in order workflow
ngyngcphu Oct 21, 2023
9b9d1b6
refactor(order-workflow): divide into mobile and desktop folder
ngyngcphu Oct 21, 2023
c72608f
feat(file): add file-size file in return type when uploading
ngyngcphu Oct 22, 2023
3365841
refactor(layout-side): use custom hook instead of component with too …
ngyngcphu Oct 23, 2023
beb2357
feat(upload&preview): complete reponsive for desktop
ngyngcphu Oct 28, 2023
372ec8f
fix(order-workflow): refactor logic code at 2 components: OrderWorkfl…
ngyngcphu Oct 28, 2023
d505a54
refactor(api_homepage): fetch data from api for home page
Minhtuei Nov 2, 2023
97b567f
chore(state): add zustand devtools to inspect state
ngyngcphu Nov 13, 2023
aae9c7f
refactor(breaking-change): optimize folder structure
ngyngcphu Nov 13, 2023
09f815d
refactor(file-box): recustom ui and logic
ngyngcphu Nov 13, 2023
4f08256
refactor(api): combine file-operation api
ngyngcphu Nov 15, 2023
cb772bf
refactor(BREAKING-CHANGE): migrate api-state to react-query
ngyngcphu Nov 16, 2023
55710c3
refactor(create-printing-request): create mutation hook
ngyngcphu Nov 16, 2023
5cf1391
refactor(state): separate client state and server state
ngyngcphu Nov 16, 2023
3d6736d
fix(upload-file): add body to api
ngyngcphu Nov 17, 2023
501fbd8
feat(responsive): keep form when resizing screen
ngyngcphu Nov 20, 2023
a3da2e5
refactor(order-form): add delete file api and update amount of files api
ngyngcphu Nov 22, 2023
59103ee
fix(order-step): add prev step and current step in order printing
ngyngcphu Nov 22, 2023
c9705f6
feat(hook): add useEvent hook to refetch listFiles after deleting file
ngyngcphu Nov 23, 2023
9e7b9e7
fix(order-form): handle total cost and state-exchange in mobile order…
ngyngcphu Nov 24, 2023
0e3b2df
fix(order): handle refetching after updating and deleting
ngyngcphu Nov 24, 2023
b8b42ce
ci(workflow): refactor ci, cd github workflow
ngyngcphu Nov 24, 2023
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
6 changes: 5 additions & 1 deletion .barrelsby.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
{
"directory": [
"./src/components",
"./src/components/common",
"./src/components/home",
"./src/components/order/common",
"./src/components/order/mobile",
"./src/components/order/desktop",
"./src/constants",
"./src/hooks",
"./src/interfaces",
Expand Down
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# This file is not allowed to be deleted, because it represents which environment variables to use when the project is open-source.
VITE_BACKEND_URL=
12 changes: 9 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
"extends": [
"prettier",
"plugin:@typescript-eslint/recommended",
"plugin:react-hooks/recommended"
"plugin:react-hooks/recommended",
"plugin:@tanstack/eslint-plugin-query/recommended"
],
"plugins": [
"@typescript-eslint"
"@typescript-eslint",
"@tanstack/query"
],
"parserOptions": {
"ecmaVersion": 2018,
Expand All @@ -21,6 +23,10 @@
"@typescript-eslint/no-inferrable-types": 0,
"@typescript-eslint/no-unused-vars": 2,
"@typescript-eslint/no-var-requires": 0,
"eqeqeq": "error"
"@tanstack/query/exhaustive-deps": "error",
"@tanstack/query/no-rest-destructuring": "warn",
"@tanstack/query/stable-query-client": "error",
"eqeqeq": "error",
"no-console": "error"
}
}
50 changes: 36 additions & 14 deletions .github/workflows/cd.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,39 @@
name: CD
name: Staging

on:
push:
branches: ['main']
paths-ignore:
- '*.md'

env:
REGISTRY: ghcr.io
IMAGE_NAME: ticklabvn/ssps-fe
ORG_USERNAME: ${{ github.actor }}

permissions:
contents: write
pull-requests: write
packages: write

jobs:
release:
runs-on: ubuntu-latest
outputs:
build: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: google-github-actions/release-please-action@v3
id: release
with:
release-type: node
pull-request-header: 'Bot (:robot:) requested to create a new release on ${{ github.ref_name }}'

build:
name: Build
needs: [release]
runs-on: ubuntu-latest
if: ${{ needs.release.outputs.build == 'true' }}
steps:
- name: Checkout
uses: actions/checkout@v3
Expand Down Expand Up @@ -46,19 +61,26 @@ jobs:

deploy:
name: Deploy
runs-on: self-hosted
runs-on: ubuntu-latest
needs: [build]
steps:
- uses: actions/checkout@v3
- name: Deploy
uses: appleboy/ssh-action@master
with:
fetch-depth: 0
- name: start nginx
run: |
export CR_PAT=${{ secrets.GITHUB_TOKEN }}
echo $CR_PAT | docker login ${{ env.REGISTRY }} -u ${{ env.ORG_USERNAME }} --password-stdin
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest
host: ${{ secrets.VPS_HOST }}
port: ${{ secrets.VPS_PORT }}
username: ${{ secrets.VPS_USERNAME }}
password: ${{ secrets.VPS_PASSWORD }}

script: |
export CR_PAT=${{ secrets.GITHUB_TOKEN }}
echo $CR_PAT | docker login ${{ env.REGISTRY }} -u ${{ env.ORG_USERNAME }} --password-stdin
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest

docker compose stop ssps-fe
docker compose rm -f ssps-fe
docker compose up -d ssps-fe
docker logout ${{ env.REGISTRY }}
cd ssps-fe
export TOKEN=${{ secrets.CURL_TOKEN }}
curl -s https://[email protected]/ticklabvn/ssps-fe/main/docker-compose.yml -o docker-compose.yml
docker compose stop ssps-fe
docker compose rm -f ssps-fe
docker compose up -d ssps-fe
docker logout ${{ env.REGISTRY }}
4 changes: 2 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/vite.svg" />
<link rel="icon" type="image/svg+xml+jpg" href="/ssps-logo.jpg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Vite + React + TS</title>
<title>Smart Service Printing System</title>
</head>
<body>
<div id="root"></div>
Expand Down
18 changes: 14 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,32 @@
"barrels": "barrelsby --config .barrelsby.json -q",
"lint": "eslint '**/*.{tsx,ts,js}'",
"format": "prettier '**/*.{tsx,ts,js,json,md,yml,yaml}' --write",
"prepare": "husky install"
"prepare": "is-ci || husky install && yarn api:pull",
"api:pull": "openapi-typescript https://ssps-server.tickflow.net/docs/json -o src/openapi-spec.ts"
},
"dependencies": {
"@cyntler/react-doc-viewer": "^1.14.0",
"@emotion/is-prop-valid": "^1.2.1",
"@heroicons/react": "^2.0.18",
"@hookform/resolvers": "^3.2.0",
"@material-tailwind/react": "^2.1.0",
"axios": "^1.4.0",
"@tanstack/react-query": "^5.8.4",
"moment": "^2.29.4",
"openapi-fetch": "^0.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-hook-form": "^7.45.4",
"react-router-dom": "^6.15.0",
"react-toastify": "^9.1.3",
"styled-components": "^6.0.8",
"yup": "^1.2.0",
"zustand": "^4.4.1"
},
"devDependencies": {
"@commitlint/cli": "^17.7.1",
"@commitlint/config-conventional": "^17.7.0",
"@tanstack/eslint-plugin-query": "^5.8.4",
"@tanstack/react-query-devtools": "^5.8.4",
"@types/node": "^20.5.0",
"@types/react": "^18.2.20",
"@types/react-dom": "^18.2.7",
Expand All @@ -42,11 +49,14 @@
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-react-hooks": "^4.6.0",
"husky": "^8.0.3",
"is-ci": "^3.0.1",
"lint-staged": "^14.0.0",
"openapi-typescript": "^7.0.0-next.2",
"postcss": "^8.4.27",
"prettier": "3.0.1",
"tailwindcss": "^3.3.3",
"typescript": "^5.0.2",
"vite": "^4.4.5"
"typescript": "^5.2.2",
"vite": "^4.4.5",
"vite-tsconfig-paths": "^4.2.1"
}
}
Binary file added public/ssps-logo.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion public/vite.svg

This file was deleted.

98 changes: 91 additions & 7 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,94 @@
import { AuthLayout } from '@layouts';
import { AuthPage } from '@pages';
import { useEffect } from 'react';
import { toast } from 'react-toastify';
import { NavigateFunction, useNavigate, useLocation } from 'react-router-dom';
import { AppSkeleton } from '@components/common';
import { MAIN_MENU, SUB_MENU } from '@constants';
import { useUserQuery } from '@hooks';
import { AppLayout, AuthLayout } from '@layouts';
import { AuthPage, HomePage } from '@pages';

export default function App() {
return (
<AuthLayout>
<AuthPage />
</AuthLayout>
);
const navigate: NavigateFunction = useNavigate();
const {
info: { isFetching, isError, isSuccess, refetch }
} = useUserQuery();
const { pathname } = useLocation();

useEffect(() => {
refetch({ throwOnError: true }).catch((err) => {
if (err.statusCode !== 401) toast.error(err.message);
});
}, [refetch]);

useEffect(() => {
if (pathname === '/' && isSuccess) {
navigate('/home');
}
}, [pathname, isSuccess, navigate]);

if (isFetching) return <AppSkeleton />;

if (isError)
return (
<AuthLayout>
<AuthPage />
</AuthLayout>
);

if (isSuccess) {
return (
<AppLayout
menu={[
{
type: 'skeleton',
path: '/',
name: 'Skeleton',
element: <AppSkeleton />
},
{
type: 'main-item',
path: '/home',
name: MAIN_MENU.home,
element: <HomePage />
},
{
type: 'main-item',
path: '/order',
name: MAIN_MENU.order,
element: <></>
},
{
type: 'main-item',
path: '/payment',
name: MAIN_MENU.payment,
element: <></>
},
{
type: 'main-item',
path: '/location',
name: MAIN_MENU.location,
element: <></>
},
{
type: 'sub-item',
path: '/help',
name: SUB_MENU.help,
element: <></>
},
{
type: 'sub-item',
path: '/settings',
name: SUB_MENU.settings,
element: <></>
},
{
type: 'logout-btn',
name: SUB_MENU.logout,
onClick() {}
//onClick: () => authService.logout().then(() => getData())
}
]}
/>
);
}
}
Binary file added src/assets/coin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/corner.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/corner.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/header.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/landscape-bottom.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/landscape-left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/landscape-right.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/landscape-top.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 0 additions & 11 deletions src/assets/login.svg

This file was deleted.

Binary file added src/assets/logobk.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/portrait-bottom.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/portrait-left.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/portrait-right.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/assets/portrait-top.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/assets/react.svg

This file was deleted.

Binary file added src/assets/ticklab.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 0 additions & 24 deletions src/components/ToggleSidebarBtn.tsx

This file was deleted.

16 changes: 16 additions & 0 deletions src/components/common/AppDrawer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, { ReactNode } from 'react';
import { Drawer } from '@material-tailwind/react';

export const AppDrawer: Component<{
open: boolean;
children: ReactNode;
onClose: () => void;
}> = ({ open, children, onClose }) => {
return (
<React.Fragment>
<Drawer open={open} className='p-0 rounded-r-2xl' onClose={onClose} size={320}>
{children}
</Drawer>
</React.Fragment>
);
};
50 changes: 50 additions & 0 deletions src/components/common/AppNavigation.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { UserCircleIcon } from '@heroicons/react/24/solid';
import coin from '@assets/coin.png';
import { AppDrawer, DesktopNavbar, ToggleSidebarBtn, useSidebarMenu } from '@components/common';
import { ScreenSize } from '@constants';
import { useScreenSize, useUserQuery } from '@hooks';
import { useMenuBarStore } from '@states';

export const AppNavigation: Component<{ mainMenu: RouteMenu; subMenu: RouteMenu }> = ({
mainMenu,
subMenu
}) => {
const { screenSize } = useScreenSize();
const { openSidebar, handleOpenSidebar, SidebarMenu } = useSidebarMenu();
const { selectedMenu } = useMenuBarStore();
const {
remainCoins: { data }
} = useUserQuery();

return (
<div className='w-full max-h-[768px] px-6 lg:px-9 py-3 lg:py-3 shadow-md lg:sticky my-3 lg:my-0'>
<div className='flex items-center justify-between h-full'>
<div className='flex items-center lg:hidden'>
<div
className='cursor-pointer opacity-40 focus:opacity-100 active:opacity-100 mr-4'
onClick={handleOpenSidebar}
>
<ToggleSidebarBtn open={openSidebar} />
</div>
<div className='text-2xl font-semibold'>{selectedMenu}</div>
</div>
{screenSize < ScreenSize.LG ? (
<AppDrawer open={openSidebar} onClose={handleOpenSidebar}>
<SidebarMenu mainMenu={mainMenu} subMenu={subMenu} />
</AppDrawer>
) : (
<DesktopNavbar mainMenu={mainMenu} />
)}
<div className='flex items-center'>
{data && (
<div className='flex items-center w-18.25 lg:w-26 h-6 lg:h-9 bg-[#FEECDC] pl-4 pr-6 lg:pl-6 lg:pr-9 rounded-lg -mr-5 font-bold text-[#9F580A] lg:font-semibold lg:text-2xl select-none text-base'>
{data}
</div>
)}
<img className='w-7 h-7 lg:w-10 lg:h-10' src={coin}></img>
<UserCircleIcon className='w-10 h-10 hidden lg:block lg:opacity-40 lg:ml-6 lg:cursor-pointer' />
</div>
</div>
</div>
);
};
File renamed without changes.
Loading