commit aa9ece09da18df855559ebfa42a0b689cb3b35cf Author: jeowsome Date: Thu Oct 3 05:23:31 2024 +0800 init diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..73816f1 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,21 @@ +# Root editor config file +root = true + +# Common settings +[*] +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true +charset = utf-8 + +# python, js indentation settings +[{*.py,*.js,*.vue,*.css,*.scss,*.html}] +indent_style = tab +indent_size = 4 +max_line_length = 99 + +# JSON files - mostly doctype schema files +[{*.json}] +insert_final_newline = false +indent_style = space +indent_size = 1 diff --git a/.eslintrc b/.eslintrc new file mode 100644 index 0000000..c5e7d68 --- /dev/null +++ b/.eslintrc @@ -0,0 +1,124 @@ +{ + "env": { + "browser": true, + "node": true, + "es2022": true + }, + "parserOptions": { + "sourceType": "module" + }, + "extends": "eslint:recommended", + "rules": { + "indent": "off", + "brace-style": "off", + "no-mixed-spaces-and-tabs": "off", + "no-useless-escape": "off", + "space-unary-ops": ["error", { "words": true }], + "linebreak-style": "off", + "quotes": ["off"], + "semi": "off", + "camelcase": "off", + "no-unused-vars": "off", + "no-console": ["warn"], + "no-extra-boolean-cast": ["off"], + "no-control-regex": ["off"], + }, + "root": true, + "globals": { + "frappe": true, + "Vue": true, + "SetVueGlobals": true, + "__": true, + "repl": true, + "Class": true, + "locals": true, + "cint": true, + "cstr": true, + "cur_frm": true, + "cur_dialog": true, + "cur_page": true, + "cur_list": true, + "cur_tree": true, + "msg_dialog": true, + "is_null": true, + "in_list": true, + "has_common": true, + "posthog": true, + "has_words": true, + "validate_email": true, + "open_web_template_values_editor": true, + "validate_name": true, + "validate_phone": true, + "validate_url": true, + "get_number_format": true, + "format_number": true, + "format_currency": true, + "comment_when": true, + "open_url_post": true, + "toTitle": true, + "lstrip": true, + "rstrip": true, + "strip": true, + "strip_html": true, + "replace_all": true, + "flt": true, + "precision": true, + "CREATE": true, + "AMEND": true, + "CANCEL": true, + "copy_dict": true, + "get_number_format_info": true, + "strip_number_groups": true, + "print_table": true, + "Layout": true, + "web_form_settings": true, + "$c": true, + "$a": true, + "$i": true, + "$bg": true, + "$y": true, + "$c_obj": true, + "refresh_many": true, + "refresh_field": true, + "toggle_field": true, + "get_field_obj": true, + "get_query_params": true, + "unhide_field": true, + "hide_field": true, + "set_field_options": true, + "getCookie": true, + "getCookies": true, + "get_url_arg": true, + "md5": true, + "$": true, + "jQuery": true, + "moment": true, + "hljs": true, + "Awesomplete": true, + "Sortable": true, + "Showdown": true, + "Taggle": true, + "Gantt": true, + "Slick": true, + "Webcam": true, + "PhotoSwipe": true, + "PhotoSwipeUI_Default": true, + "io": true, + "JsBarcode": true, + "L": true, + "Chart": true, + "DataTable": true, + "Cypress": true, + "cy": true, + "it": true, + "describe": true, + "expect": true, + "context": true, + "before": true, + "beforeEach": true, + "after": true, + "qz": true, + "localforage": true, + "extend_cscript": true + } +} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ba04025 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +.DS_Store +*.pyc +*.egg-info +*.swp +tags +node_modules +__pycache__ \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..1a38b03 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,67 @@ +exclude: 'node_modules|.git' +default_stages: [commit] +fail_fast: false + + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.3.0 + hooks: + - id: trailing-whitespace + files: "suppliers_portal.*" + exclude: ".*json$|.*txt$|.*csv|.*md|.*svg" + - id: check-yaml + - id: check-merge-conflict + - id: check-ast + - id: check-json + - id: check-toml + - id: check-yaml + - id: debug-statements + + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.2.0 + hooks: + - id: ruff + name: "Run ruff linter and apply fixes" + args: ["--fix"] + + - id: ruff-format + name: "Format Python code" + + - repo: https://github.com/pre-commit/mirrors-prettier + rev: v2.7.1 + hooks: + - id: prettier + types_or: [javascript, vue, scss] + # Ignore any files that might contain jinja / bundles + exclude: | + (?x)^( + suppliers_portal/public/dist/.*| + .*node_modules.*| + .*boilerplate.*| + suppliers_portal/templates/includes/.*| + suppliers_portal/public/js/lib/.* + )$ + + + - repo: https://github.com/pre-commit/mirrors-eslint + rev: v8.44.0 + hooks: + - id: eslint + types_or: [javascript] + args: ['--quiet'] + # Ignore any files that might contain jinja / bundles + exclude: | + (?x)^( + suppliers_portal/public/dist/.*| + cypress/.*| + .*node_modules.*| + .*boilerplate.*| + suppliers_portal/templates/includes/.*| + suppliers_portal/public/js/lib/.* + )$ + +ci: + autoupdate_schedule: weekly + skip: [] + submodules: false diff --git a/README.md b/README.md new file mode 100644 index 0000000..ebe0daa --- /dev/null +++ b/README.md @@ -0,0 +1,33 @@ +### Suppliers Portal + +Supplier Invoices, Supplier Quotes and Supplier Details + +### Installation + +You can install this app using the [bench](https://github.com/frappe/bench) CLI: + +```bash +cd $PATH_TO_YOUR_BENCH +bench get-app $URL_OF_THIS_REPO --branch develop +bench install-app suppliers_portal +``` + +### Contributing + +This app uses `pre-commit` for code formatting and linting. Please [install pre-commit](https://pre-commit.com/#installation) and enable it for this repository: + +```bash +cd apps/suppliers_portal +pre-commit install +``` + +Pre-commit is configured to use the following tools for checking and formatting your code: + +- ruff +- eslint +- prettier +- pyupgrade + +### License + +mit diff --git a/frontend/.gitignore b/frontend/.gitignore new file mode 100644 index 0000000..53f7466 --- /dev/null +++ b/frontend/.gitignore @@ -0,0 +1,5 @@ +node_modules +.DS_Store +dist +dist-ssr +*.local \ No newline at end of file diff --git a/frontend/.prettierrc.json b/frontend/.prettierrc.json new file mode 100644 index 0000000..b2095be --- /dev/null +++ b/frontend/.prettierrc.json @@ -0,0 +1,4 @@ +{ + "semi": false, + "singleQuote": true +} diff --git a/frontend/README.md b/frontend/README.md new file mode 100644 index 0000000..1a41f83 --- /dev/null +++ b/frontend/README.md @@ -0,0 +1,42 @@ +# Frappe UI Starter + +This template should help get you started developing custom frontend for Frappe +apps with Vue 3 and the Frappe UI package. + +This boilerplate sets up Vue 3, Vue Router, TailwindCSS, and Frappe UI out of +the box. + +## Usage + +This template is meant to be cloned inside an existing Frappe App. Assuming your +apps name is `todo`. Clone this template in the root folder of your app using `degit`. + +``` +cd apps/todo +npx degit netchampfaris/frappe-ui-starter frontend +cd frontend +yarn +yarn dev +``` + +In a development environment, you need to put the below key-value pair in your `site_config.json` file: + +``` +"ignore_csrf": 1 +``` + +This will prevent `CSRFToken` errors while using the vite dev server. In production environment, the `csrf_token` is attached to the `window` object in `index.html` for you. + +The Vite dev server will start on the port `8080`. This can be changed from `vite.config.js`. +The development server is configured to proxy your frappe app (usually running on port `8000`). If you have a site named `todo.test`, open `http://todo.test:8080` in your browser. If you see a button named "Click to send 'ping' request", congratulations! + +If you notice the browser URL is `/frontend`, this is the base URL where your frontend app will run in production. +To change this, open `src/router.js` and change the base URL passed to `createWebHistory`. + +## Resources + +- [Vue 3](https://v3.vuejs.org/guide/introduction.html) +- [Vue Router](https://next.router.vuejs.org/guide/) +- [Frappe UI](https://github.com/frappe/frappe-ui) +- [TailwindCSS](https://tailwindcss.com/docs/utility-first) +- [Vite](https://vitejs.dev/guide/) diff --git a/frontend/index.html b/frontend/index.html new file mode 100644 index 0000000..1a09e1e --- /dev/null +++ b/frontend/index.html @@ -0,0 +1,17 @@ + + + + + + + Supplier Portal + + +
+
+
+ + + + + diff --git a/frontend/package.json b/frontend/package.json new file mode 100644 index 0000000..cb35e82 --- /dev/null +++ b/frontend/package.json @@ -0,0 +1,26 @@ +{ + "name": "frappe-ui-frontend", + "private": true, + "version": "0.0.0", + "scripts": { + "dev": "vite", + "build": "vite build --base=/assets/suppliers_portal/frontend/ && yarn copy-html-entry", + "preview": "vite preview", + "copy-html-entry": "cp ../suppliers_portal/public/frontend/index.html ../suppliers_portal/www/frontend.html" + }, + "dependencies": { + "bootstrap": "5.2.3", + "bootstrap-icons": "^1.11.3", + "feather-icons": "^4.28.0", + "frappe-ui": "^0.1.69", + "vue": "^3.2.25", + "vue-router": "^4.0.12" + }, + "devDependencies": { + "@vitejs/plugin-vue": "^2.0.0", + "autoprefixer": "^10.4.2", + "postcss": "^8.4.5", + "tailwindcss": "^3.0.15", + "vite": "^2.7.2" + } +} diff --git a/frontend/postcss.config.js b/frontend/postcss.config.js new file mode 100644 index 0000000..33ad091 --- /dev/null +++ b/frontend/postcss.config.js @@ -0,0 +1,6 @@ +module.exports = { + plugins: { + tailwindcss: {}, + autoprefixer: {}, + }, +} diff --git a/frontend/public/favicon.png b/frontend/public/favicon.png new file mode 100644 index 0000000..b51db82 Binary files /dev/null and b/frontend/public/favicon.png differ diff --git a/frontend/src/App.vue b/frontend/src/App.vue new file mode 100644 index 0000000..a14d0c3 --- /dev/null +++ b/frontend/src/App.vue @@ -0,0 +1,5 @@ + diff --git a/frontend/src/assets/Inter/Inter-Black.woff b/frontend/src/assets/Inter/Inter-Black.woff new file mode 100644 index 0000000..c7737ed Binary files /dev/null and b/frontend/src/assets/Inter/Inter-Black.woff differ diff --git a/frontend/src/assets/Inter/Inter-Black.woff2 b/frontend/src/assets/Inter/Inter-Black.woff2 new file mode 100644 index 0000000..b16b995 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-Black.woff2 differ diff --git a/frontend/src/assets/Inter/Inter-BlackItalic.woff b/frontend/src/assets/Inter/Inter-BlackItalic.woff new file mode 100644 index 0000000..b5f1447 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-BlackItalic.woff differ diff --git a/frontend/src/assets/Inter/Inter-BlackItalic.woff2 b/frontend/src/assets/Inter/Inter-BlackItalic.woff2 new file mode 100644 index 0000000..a3f1b70 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-BlackItalic.woff2 differ diff --git a/frontend/src/assets/Inter/Inter-Bold.woff b/frontend/src/assets/Inter/Inter-Bold.woff new file mode 100644 index 0000000..e384555 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-Bold.woff differ diff --git a/frontend/src/assets/Inter/Inter-Bold.woff2 b/frontend/src/assets/Inter/Inter-Bold.woff2 new file mode 100644 index 0000000..835dd49 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-Bold.woff2 differ diff --git a/frontend/src/assets/Inter/Inter-BoldItalic.woff b/frontend/src/assets/Inter/Inter-BoldItalic.woff new file mode 100644 index 0000000..ffac3f5 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-BoldItalic.woff differ diff --git a/frontend/src/assets/Inter/Inter-BoldItalic.woff2 b/frontend/src/assets/Inter/Inter-BoldItalic.woff2 new file mode 100644 index 0000000..1a41a14 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-BoldItalic.woff2 differ diff --git a/frontend/src/assets/Inter/Inter-ExtraBold.woff b/frontend/src/assets/Inter/Inter-ExtraBold.woff new file mode 100644 index 0000000..885ac94 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-ExtraBold.woff differ diff --git a/frontend/src/assets/Inter/Inter-ExtraBold.woff2 b/frontend/src/assets/Inter/Inter-ExtraBold.woff2 new file mode 100644 index 0000000..ae956b1 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-ExtraBold.woff2 differ diff --git a/frontend/src/assets/Inter/Inter-ExtraBoldItalic.woff b/frontend/src/assets/Inter/Inter-ExtraBoldItalic.woff new file mode 100644 index 0000000..d6cf862 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-ExtraBoldItalic.woff differ diff --git a/frontend/src/assets/Inter/Inter-ExtraBoldItalic.woff2 b/frontend/src/assets/Inter/Inter-ExtraBoldItalic.woff2 new file mode 100644 index 0000000..8657899 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-ExtraBoldItalic.woff2 differ diff --git a/frontend/src/assets/Inter/Inter-ExtraLight.woff b/frontend/src/assets/Inter/Inter-ExtraLight.woff new file mode 100644 index 0000000..ff76919 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-ExtraLight.woff differ diff --git a/frontend/src/assets/Inter/Inter-ExtraLight.woff2 b/frontend/src/assets/Inter/Inter-ExtraLight.woff2 new file mode 100644 index 0000000..694b2df Binary files /dev/null and b/frontend/src/assets/Inter/Inter-ExtraLight.woff2 differ diff --git a/frontend/src/assets/Inter/Inter-ExtraLightItalic.woff b/frontend/src/assets/Inter/Inter-ExtraLightItalic.woff new file mode 100644 index 0000000..c6ed13a Binary files /dev/null and b/frontend/src/assets/Inter/Inter-ExtraLightItalic.woff differ diff --git a/frontend/src/assets/Inter/Inter-ExtraLightItalic.woff2 b/frontend/src/assets/Inter/Inter-ExtraLightItalic.woff2 new file mode 100644 index 0000000..9a7bd11 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-ExtraLightItalic.woff2 differ diff --git a/frontend/src/assets/Inter/Inter-Italic.woff b/frontend/src/assets/Inter/Inter-Italic.woff new file mode 100644 index 0000000..4fdb59d Binary files /dev/null and b/frontend/src/assets/Inter/Inter-Italic.woff differ diff --git a/frontend/src/assets/Inter/Inter-Italic.woff2 b/frontend/src/assets/Inter/Inter-Italic.woff2 new file mode 100644 index 0000000..deca637 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-Italic.woff2 differ diff --git a/frontend/src/assets/Inter/Inter-Light.woff b/frontend/src/assets/Inter/Inter-Light.woff new file mode 100644 index 0000000..42850ac Binary files /dev/null and b/frontend/src/assets/Inter/Inter-Light.woff differ diff --git a/frontend/src/assets/Inter/Inter-Light.woff2 b/frontend/src/assets/Inter/Inter-Light.woff2 new file mode 100644 index 0000000..65a7dad Binary files /dev/null and b/frontend/src/assets/Inter/Inter-Light.woff2 differ diff --git a/frontend/src/assets/Inter/Inter-LightItalic.woff b/frontend/src/assets/Inter/Inter-LightItalic.woff new file mode 100644 index 0000000..c4ed9a9 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-LightItalic.woff differ diff --git a/frontend/src/assets/Inter/Inter-LightItalic.woff2 b/frontend/src/assets/Inter/Inter-LightItalic.woff2 new file mode 100644 index 0000000..555fc55 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-LightItalic.woff2 differ diff --git a/frontend/src/assets/Inter/Inter-Medium.woff b/frontend/src/assets/Inter/Inter-Medium.woff new file mode 100644 index 0000000..495faef Binary files /dev/null and b/frontend/src/assets/Inter/Inter-Medium.woff differ diff --git a/frontend/src/assets/Inter/Inter-Medium.woff2 b/frontend/src/assets/Inter/Inter-Medium.woff2 new file mode 100644 index 0000000..871ce4c Binary files /dev/null and b/frontend/src/assets/Inter/Inter-Medium.woff2 differ diff --git a/frontend/src/assets/Inter/Inter-MediumItalic.woff b/frontend/src/assets/Inter/Inter-MediumItalic.woff new file mode 100644 index 0000000..389c7a2 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-MediumItalic.woff differ diff --git a/frontend/src/assets/Inter/Inter-MediumItalic.woff2 b/frontend/src/assets/Inter/Inter-MediumItalic.woff2 new file mode 100644 index 0000000..aa80579 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-MediumItalic.woff2 differ diff --git a/frontend/src/assets/Inter/Inter-Regular.woff b/frontend/src/assets/Inter/Inter-Regular.woff new file mode 100644 index 0000000..fa7715d Binary files /dev/null and b/frontend/src/assets/Inter/Inter-Regular.woff differ diff --git a/frontend/src/assets/Inter/Inter-Regular.woff2 b/frontend/src/assets/Inter/Inter-Regular.woff2 new file mode 100644 index 0000000..b52dd0a Binary files /dev/null and b/frontend/src/assets/Inter/Inter-Regular.woff2 differ diff --git a/frontend/src/assets/Inter/Inter-SemiBold.woff b/frontend/src/assets/Inter/Inter-SemiBold.woff new file mode 100644 index 0000000..18d7749 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-SemiBold.woff differ diff --git a/frontend/src/assets/Inter/Inter-SemiBold.woff2 b/frontend/src/assets/Inter/Inter-SemiBold.woff2 new file mode 100644 index 0000000..ece5204 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-SemiBold.woff2 differ diff --git a/frontend/src/assets/Inter/Inter-SemiBoldItalic.woff b/frontend/src/assets/Inter/Inter-SemiBoldItalic.woff new file mode 100644 index 0000000..8ee6439 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-SemiBoldItalic.woff differ diff --git a/frontend/src/assets/Inter/Inter-SemiBoldItalic.woff2 b/frontend/src/assets/Inter/Inter-SemiBoldItalic.woff2 new file mode 100644 index 0000000..b32c0ba Binary files /dev/null and b/frontend/src/assets/Inter/Inter-SemiBoldItalic.woff2 differ diff --git a/frontend/src/assets/Inter/Inter-Thin.woff b/frontend/src/assets/Inter/Inter-Thin.woff new file mode 100644 index 0000000..1a22286 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-Thin.woff differ diff --git a/frontend/src/assets/Inter/Inter-Thin.woff2 b/frontend/src/assets/Inter/Inter-Thin.woff2 new file mode 100644 index 0000000..c56bc7c Binary files /dev/null and b/frontend/src/assets/Inter/Inter-Thin.woff2 differ diff --git a/frontend/src/assets/Inter/Inter-ThinItalic.woff b/frontend/src/assets/Inter/Inter-ThinItalic.woff new file mode 100644 index 0000000..d8ec837 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-ThinItalic.woff differ diff --git a/frontend/src/assets/Inter/Inter-ThinItalic.woff2 b/frontend/src/assets/Inter/Inter-ThinItalic.woff2 new file mode 100644 index 0000000..eca5608 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-ThinItalic.woff2 differ diff --git a/frontend/src/assets/Inter/Inter-italic.var.woff2 b/frontend/src/assets/Inter/Inter-italic.var.woff2 new file mode 100644 index 0000000..1f5d926 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-italic.var.woff2 differ diff --git a/frontend/src/assets/Inter/Inter-roman.var.woff2 b/frontend/src/assets/Inter/Inter-roman.var.woff2 new file mode 100644 index 0000000..05621d8 Binary files /dev/null and b/frontend/src/assets/Inter/Inter-roman.var.woff2 differ diff --git a/frontend/src/assets/Inter/Inter.var.woff2 b/frontend/src/assets/Inter/Inter.var.woff2 new file mode 100644 index 0000000..46bb515 Binary files /dev/null and b/frontend/src/assets/Inter/Inter.var.woff2 differ diff --git a/frontend/src/assets/Inter/inter.css b/frontend/src/assets/Inter/inter.css new file mode 100644 index 0000000..3ca1bbf --- /dev/null +++ b/frontend/src/assets/Inter/inter.css @@ -0,0 +1,152 @@ +@font-face { + font-family: 'Inter'; + font-style: normal; + font-weight: 100; + font-display: swap; + src: url("Inter-Thin.woff2?v=3.12") format("woff2"), + url("Inter-Thin.woff?v=3.12") format("woff"); +} +@font-face { + font-family: 'Inter'; + font-style: italic; + font-weight: 100; + font-display: swap; + src: url("Inter-ThinItalic.woff2?v=3.12") format("woff2"), + url("Inter-ThinItalic.woff?v=3.12") format("woff"); +} + +@font-face { + font-family: 'Inter'; + font-style: normal; + font-weight: 200; + font-display: swap; + src: url("Inter-ExtraLight.woff2?v=3.12") format("woff2"), + url("Inter-ExtraLight.woff?v=3.12") format("woff"); +} +@font-face { + font-family: 'Inter'; + font-style: italic; + font-weight: 200; + font-display: swap; + src: url("Inter-ExtraLightItalic.woff2?v=3.12") format("woff2"), + url("Inter-ExtraLightItalic.woff?v=3.12") format("woff"); +} + +@font-face { + font-family: 'Inter'; + font-style: normal; + font-weight: 300; + font-display: swap; + src: url("Inter-Light.woff2?v=3.12") format("woff2"), + url("Inter-Light.woff?v=3.12") format("woff"); +} +@font-face { + font-family: 'Inter'; + font-style: italic; + font-weight: 300; + font-display: swap; + src: url("Inter-LightItalic.woff2?v=3.12") format("woff2"), + url("Inter-LightItalic.woff?v=3.12") format("woff"); +} + +@font-face { + font-family: 'Inter'; + font-style: normal; + font-weight: 400; + font-display: swap; + src: url("Inter-Regular.woff2?v=3.12") format("woff2"), + url("Inter-Regular.woff?v=3.12") format("woff"); +} +@font-face { + font-family: 'Inter'; + font-style: italic; + font-weight: 400; + font-display: swap; + src: url("Inter-Italic.woff2?v=3.12") format("woff2"), + url("Inter-Italic.woff?v=3.12") format("woff"); +} + +@font-face { + font-family: 'Inter'; + font-style: normal; + font-weight: 500; + font-display: swap; + src: url("Inter-Medium.woff2?v=3.12") format("woff2"), + url("Inter-Medium.woff?v=3.12") format("woff"); +} +@font-face { + font-family: 'Inter'; + font-style: italic; + font-weight: 500; + font-display: swap; + src: url("Inter-MediumItalic.woff2?v=3.12") format("woff2"), + url("Inter-MediumItalic.woff?v=3.12") format("woff"); +} + +@font-face { + font-family: 'Inter'; + font-style: normal; + font-weight: 600; + font-display: swap; + src: url("Inter-SemiBold.woff2?v=3.12") format("woff2"), + url("Inter-SemiBold.woff?v=3.12") format("woff"); +} +@font-face { + font-family: 'Inter'; + font-style: italic; + font-weight: 600; + font-display: swap; + src: url("Inter-SemiBoldItalic.woff2?v=3.12") format("woff2"), + url("Inter-SemiBoldItalic.woff?v=3.12") format("woff"); +} + +@font-face { + font-family: 'Inter'; + font-style: normal; + font-weight: 700; + font-display: swap; + src: url("Inter-Bold.woff2?v=3.12") format("woff2"), + url("Inter-Bold.woff?v=3.12") format("woff"); +} +@font-face { + font-family: 'Inter'; + font-style: italic; + font-weight: 700; + font-display: swap; + src: url("Inter-BoldItalic.woff2?v=3.12") format("woff2"), + url("Inter-BoldItalic.woff?v=3.12") format("woff"); +} + +@font-face { + font-family: 'Inter'; + font-style: normal; + font-weight: 800; + font-display: swap; + src: url("Inter-ExtraBold.woff2?v=3.12") format("woff2"), + url("Inter-ExtraBold.woff?v=3.12") format("woff"); +} +@font-face { + font-family: 'Inter'; + font-style: italic; + font-weight: 800; + font-display: swap; + src: url("Inter-ExtraBoldItalic.woff2?v=3.12") format("woff2"), + url("Inter-ExtraBoldItalic.woff?v=3.12") format("woff"); +} + +@font-face { + font-family: 'Inter'; + font-style: normal; + font-weight: 900; + font-display: swap; + src: url("Inter-Black.woff2?v=3.12") format("woff2"), + url("Inter-Black.woff?v=3.12") format("woff"); +} +@font-face { + font-family: 'Inter'; + font-style: italic; + font-weight: 900; + font-display: swap; + src: url("Inter-BlackItalic.woff2?v=3.12") format("woff2"), + url("Inter-BlackItalic.woff?v=3.12") format("woff"); +} diff --git a/frontend/src/data/session.js b/frontend/src/data/session.js new file mode 100644 index 0000000..46f3e59 --- /dev/null +++ b/frontend/src/data/session.js @@ -0,0 +1,91 @@ +import router from '@/router' +import { computed, reactive } from 'vue' +import { createResource } from 'frappe-ui' + +import { userResource } from './user' + +export function sessionUser() { + const cookies = new URLSearchParams(document.cookie.split('; ').join('&')) + let _sessionUser = cookies.get('user_id') + if (_sessionUser === 'Guest') { + _sessionUser = null + } + return _sessionUser +} + +export function sessionSupplierId() { + const cookies = new URLSearchParams(document.cookie.split('; ').join('&')) + return cookies.get('supplier_id') +} + +export function sessionSupplierName() { + const cookies = new URLSearchParams(document.cookie.split('; ').join('&')) + return cookies.get('supplier_name') +} + +export const session = reactive({ + supplier_login: createResource({ + url: 'suppliers_portal.suppliers_portal.api.validate_supplier_id', + makeParams({ supplier_id }) { + return { + supplier_id, + } + }, + onSuccess(data) { + if (data && data.status === 'success') { + userResource.reload() + session.user = sessionUser() + document.cookie = `supplier_id=${data.supplier_id}` + document.cookie = `supplier_name=${data.supplier_name}` + session.supplier_id = data.supplier_id + session.supplier_name = data.supplier_name + session.login.reset() + router.replace({ name: 'SupplierInvoiceList' }) + } + }, + onError(error) { + console.error('Login failed', error) + }, + }), + login: createResource({ + url: 'login', + makeParams({ email, password }) { + return { + usr: email, + pwd: password, + } + }, + onSuccess(data) { + if (data) { + userResource.reload() + session.user = sessionUser() + // clear supplier_id and supplier_name + document.cookie = `supplier_id=${session.supplier_id}; expires=Thu, 01 Jan 1970 00:00:00 UTC'`; + document.cookie = `supplier_id=${session.supplier_name}; expires=Thu, 01 Jan 1970 00:00:00 UTC'`; + session.supplier_id = '' + session.supplier_name = '' + session.login.reset() + router.replace({ name: 'SupplierInvoiceList' }) + } + }, + onError(error) { + console.error('Login failed', error) + }, + }), + logout: createResource({ + url: 'logout', + onSuccess() { + document.cookie = `supplier_id=${session.supplier_id}; expires=Thu, 01 Jan 1970 00:00:00 UTC'`; + document.cookie = `supplier_id=${session.supplier_name}; expires=Thu, 01 Jan 1970 00:00:00 UTC'`; + session.supplier_id = '' + session.supplier_name = '' + userResource.reset() + session.user = sessionUser() + router.replace({ name: 'Login' }) + }, + }), + user: sessionUser(), + supplier_id: sessionSupplierId(), + supplier_name: sessionSupplierName(), + isLoggedIn: computed(() => !!session.user), +}) \ No newline at end of file diff --git a/frontend/src/data/user.js b/frontend/src/data/user.js new file mode 100644 index 0000000..876b359 --- /dev/null +++ b/frontend/src/data/user.js @@ -0,0 +1,12 @@ +import router from '@/router' +import { createResource } from 'frappe-ui' + +export const userResource = createResource({ + url: 'frappe.auth.get_logged_user', + cache: 'User', + onError(error) { + if (error && error.exc_type === 'AuthenticationError') { + router.push({ name: 'LoginPage' }) + } + }, +}) \ No newline at end of file diff --git a/frontend/src/data/utils.js b/frontend/src/data/utils.js new file mode 100644 index 0000000..8f4d55c --- /dev/null +++ b/frontend/src/data/utils.js @@ -0,0 +1,22 @@ +export const addDays = (date, days) => { + const result = new Date(date); + result.setDate(result.getDate() + days); + return result; +} + +export const parseInvoiceTerms = (invoiceTerm) => { + switch (invoiceTerm) { + case 'NET 10': + return 10; + case 'NET 15': + return 15; + case 'NET 30': + return 30; + case 'NET 45': + return 45; + case 'NET 60': + return 60; + default: + return 0; + } +} \ No newline at end of file diff --git a/frontend/src/index.css b/frontend/src/index.css new file mode 100644 index 0000000..166ac59 --- /dev/null +++ b/frontend/src/index.css @@ -0,0 +1,2 @@ +@import './assets/Inter/inter.css'; +@import 'frappe-ui/src/style.css'; diff --git a/frontend/src/main.js b/frontend/src/main.js new file mode 100644 index 0000000..3420fdd --- /dev/null +++ b/frontend/src/main.js @@ -0,0 +1,32 @@ +import './index.css' + +import { createApp } from 'vue' +import router from './router' +import App from './App.vue' +import 'bootstrap/dist/css/bootstrap.min.css' +import 'bootstrap' +import 'bootstrap-icons/font/bootstrap-icons.css' + + + +import { + Button, + Card, + Input, + setConfig, + frappeRequest, + resourcesPlugin, +} from 'frappe-ui' + +let app = createApp(App) + +setConfig('resourceFetcher', frappeRequest) + +app.use(router) +app.use(resourcesPlugin) + +app.component('Button', Button) +app.component('Card', Card) +app.component('Input', Input) + +app.mount('#app') \ No newline at end of file diff --git a/frontend/src/pages/Login.vue b/frontend/src/pages/Login.vue new file mode 100644 index 0000000..275e76e --- /dev/null +++ b/frontend/src/pages/Login.vue @@ -0,0 +1,66 @@ + + + diff --git a/frontend/src/pages/NewInvoice.vue b/frontend/src/pages/NewInvoice.vue new file mode 100644 index 0000000..427f62f --- /dev/null +++ b/frontend/src/pages/NewInvoice.vue @@ -0,0 +1,597 @@ +