Compare commits

..
3 Commits
Author SHA1 Message Date
Amirmahdi a186db08e2 feat: add product 3 mount 2026-06-17 19:10:21 +03:30
Amirmahdi 958f29b685 deploy 2026-06-07 23:52:16 +03:30
Amirmahdi 6c52a020eb deploy 2026-06-07 17:53:12 +03:30
5 changed files with 78 additions and 13 deletions
+22
View File
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
# Runs on `git push`. If a tag ref is among what's being pushed, build locally
# and deploy to the server. Normal branch pushes are untouched.
set -euo pipefail
deploy=0
tag=""
while read -r local_ref _local_sha _remote_ref _remote_sha; do
case "$local_ref" in
refs/tags/*)
deploy=1
tag="${local_ref#refs/tags/}"
;;
esac
done
if [ "$deploy" = "1" ]; then
echo "→ Tag '$tag' is being pushed — building locally and deploying to the server…"
exec "$(git rev-parse --show-toplevel)/scripts/deploy.sh"
fi
exit 0
+5 -10
View File
@@ -1,5 +1,10 @@
import { User } from "@/types/user";
// Single source of truth for product type labels lives in types/product.ts
// (kept in sync with the backend Product::TYPES). Re-exported here so existing
// `@/lib/utils` imports keep working without a divergent (previously wrong) map.
export { getProductTypeLabel } from "@/types/product";
export const formatDate = (dateString: string | null): string => {
if (!dateString) return 'نامشخص';
@@ -20,16 +25,6 @@ export const formatPrice = (price: number | null): string => {
return new Intl.NumberFormat('fa-IR').format(price);
};
export const getProductTypeLabel = (type: number | null): string => {
const types: Record<number, string> = {
1: 'ماهیانه',
2: 'سه ماهه',
3: 'شش ماهه',
4: 'سالیانه',
};
return type && types[type] ? types[type] : 'نامشخص';
};
export const getFullName = (user: User): string => {
if (user.full_name) return user.full_name;
+3 -2
View File
@@ -4,9 +4,10 @@
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build && next export && mv out appro-admin",
"build": "next build",
"start": "next start",
"lint": "eslint"
"lint": "eslint",
"prepare": "git config core.hooksPath .githooks || true"
},
"dependencies": {
"@heroicons/react": "^2.2.0",
+46
View File
@@ -0,0 +1,46 @@
#!/usr/bin/env bash
# Build the static site locally, then replace the server directory with it.
#
# - Builds on THIS machine (npm run build -> ./out).
# - Streams out/ over a single SSH connection (tar pipe) and swaps the
# contents of the target dir on the server. No rsync/sshpass required.
#
# Password handling:
# - If `sshpass` is installed AND DEPLOY_PASSWORD is set (env or .env.deploy),
# the deploy is fully unattended.
# - Otherwise SSH prompts for the password once (interactive).
#
# Config (override via env or .env.deploy):
set -euo pipefail
cd "$(git rev-parse --show-toplevel 2>/dev/null || dirname "$(dirname "$0")")"
# Optional local secrets file (gitignored).
[ -f .env.deploy ] && . ./.env.deploy
DEPLOY_HOST="${DEPLOY_HOST:-185.226.116.88}"
DEPLOY_USER="${DEPLOY_USER:-ubuntu}"
DEPLOY_PATH="${DEPLOY_PATH:-/var/www/appro-admin}"
DEPLOY_PASSWORD="${DEPLOY_PASSWORD:-}"
echo "▸ Building locally…"
npm run build
if [ ! -d out ]; then
echo "✗ Build did not produce ./out" >&2
exit 1
fi
# Pick the SSH command: unattended with sshpass, else interactive prompt.
ssh_cmd=(ssh -o StrictHostKeyChecking=no "$DEPLOY_USER@$DEPLOY_HOST")
if command -v sshpass >/dev/null 2>&1 && [ -n "$DEPLOY_PASSWORD" ]; then
ssh_cmd=(sshpass -p "$DEPLOY_PASSWORD" "${ssh_cmd[@]}")
else
echo " sshpass/password not available — SSH will prompt for the password."
fi
echo "▸ Uploading to $DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH"
# Replace the directory contents (incl. dotfiles) then extract the new build.
tar -C out -czf - . | "${ssh_cmd[@]}" \
"set -e; mkdir -p '$DEPLOY_PATH'; find '$DEPLOY_PATH' -mindepth 1 -delete; tar -C '$DEPLOY_PATH' -xzf -"
echo "✓ Deployed to $DEPLOY_HOST:$DEPLOY_PATH"
+2 -1
View File
@@ -35,7 +35,8 @@ export const PRODUCT_TYPES = {
1: 'دائمی',
2: 'سالیانه',
3: '۶ ماهه',
4: 'ماهیانه'
4: 'ماهیانه',
5: 'سه ماهه'
} as const;
export type ProductType = keyof typeof PRODUCT_TYPES;