When developing custom applications in ERPNext, managing frontend assets efficiently is crucial. Traditionally, ERPNext uses Jinja templates to build web pages, while modern frontend frameworks like Vite.js with React.js offer a more dynamic approach. In this blog post, I'll explore how Jinja and Vite.js handle builds, where to place the build files, and how to integrate them into an ERPNext custom app.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
useEffect(() => { | |
window.addEventListener('message', (e) => { | |
const { disableDarkMode, id } = e.data; | |
const botId = id; | |
if (disableDarkMode) { | |
document.body.style.backgroundColor = 'white'; | |
document.body.style.color = 'black'; | |
document.body.classList.remove('dark-mode'); | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// // @/components/Dashboard/CardImage/CardImage.tsx | |
interface CardImageProps { | |
lastFourDigits: string; | |
cardType: string; | |
} | |
export default function CardImage({ lastFourDigits, cardType }: CardImageProps) { | |
const apiUrl = process.env.NEXT_PUBLIC_API_URL; // Set this in your environment variables | |
const imageUrl = `${apiUrl}/api/card-image?lastFourDigits=${lastFourDigits}&cardType=${cardType}`; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import frappe | |
def before_uninstall(): | |
# Remove Print Format record | |
if frappe.db.exists("Print Format", "Print Designer"): | |
frappe.delete_doc("Print Format", "Print Designer") | |
# Remove Print Designer entries from property setter | |
property_setters = frappe.get_all( | |
"Property Setter", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description=ERPNext Thai Business Suite Translation Updater | |
After=network.target | |
[Service] | |
Type=oneshot | |
User=frappe | |
Group=frappe | |
WorkingDirectory=/home/frappe/moo-bench | |
ExecStart=/bin/bash -c '/usr/local/bin/bench update-po-files --app thai_business_suite && /usr/local/bin/bench compile-po-to-mo --app> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Setup script for ERPNext translation service using OpenAI API | |
# This script works with or without Thai Business Suite installed | |
set -e # Exit on any error | |
# Banner | |
echo "===============================================" | |
echo "ERPNext Translation Service Setup" | |
echo "===============================================" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
frappe.ui.form.on("DFP External Storage", { | |
setup: (frm) => { | |
frm.button_remote_files_list = null; | |
}, | |
refresh: function (frm) { | |
if (frm.is_new() && !frm.doc.doctypes_ignored.length) { | |
frm.doc.doctypes_ignored.push({ doctype_to_ignore: "Data Import" }); | |
frm.doc.doctypes_ignored.push({ doctype_to_ignore: "Prepared Report" }); | |
frm.refresh_field("doctypes_ignored"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# thai_business_suite/setup/__init__.py | |
from . import setup_default_workspace | |
def after_install(): | |
"""Setup workspaces after app installation""" | |
setup_default_workspace.setup_workspaces() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
bench --site your_site_name console |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// translation_tools/public/js/translation_tools/App.jsx | |
import * as React from 'react'; | |
import '../../css/tailwind.css'; | |
import { Button } from '@/components/ui/button'; | |
export function App() { | |
return ( | |
<main className="tw"> | |
<div className="tw-m-4"> |