Compare commits
15
Commits
265fb8dde4
...
v0.3.9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
617d8ff680
|
||
|
|
88c86ac810
|
||
|
|
f59ff54256
|
||
|
|
12ecbf991e | ||
|
|
951610cda2 | ||
|
|
943897044a | ||
|
|
53c8c8e94c | ||
|
|
c4c9f37bbc | ||
|
|
a1c429782f | ||
|
|
0dcc7bbf76 | ||
|
|
77748bcba2 | ||
|
|
994879749b | ||
|
|
41e40c9ab2 | ||
|
|
42871c51cd | ||
|
|
6dc04de222 |
@@ -0,0 +1,14 @@
|
|||||||
|
# CI job image for the Gitea Actions runners.
|
||||||
|
#
|
||||||
|
# JS actions (actions/checkout, docker/build-push-action) execute INSIDE the
|
||||||
|
# job container and need node; builds talk to the runner's daemon through the
|
||||||
|
# mounted /var/run/docker.sock, so this image needs the docker CLI + buildx
|
||||||
|
# but no daemon. Baking them in means jobs never download binaries at runtime:
|
||||||
|
# download.docker.com and github.com releases are unreachable (connection
|
||||||
|
# reset) from the cluster's network.
|
||||||
|
#
|
||||||
|
# Tagged as src.panahifar.ir/ahp/act-job:20 (node 20 / bookworm).
|
||||||
|
FROM node:20-bookworm
|
||||||
|
|
||||||
|
COPY --from=docker:27-cli /usr/local/bin/docker /usr/local/bin/docker
|
||||||
|
COPY --from=docker:27-cli /usr/local/libexec/docker/cli-plugins/docker-buildx /usr/local/libexec/docker/cli-plugins/docker-buildx
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
name: build-and-push
|
||||||
|
|
||||||
|
# On a version tag push (v*), build both images and publish them to the
|
||||||
|
# Gitea container registry. Argo CD then rolls them out via
|
||||||
|
# deploy/helm/pargar (values-apollo.yaml pins the matching image tags).
|
||||||
|
#
|
||||||
|
# Requires a registered Gitea Actions runner, a `REGISTRY_TOKEN` secret
|
||||||
|
# (Gitea access token with write:package scope) so docker login can push to
|
||||||
|
# the registry.
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- "v*"
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: read
|
||||||
|
packages: write
|
||||||
|
|
||||||
|
env:
|
||||||
|
REGISTRY: src.panahifar.ir
|
||||||
|
BACKEND_IMAGE: ahp/pargar-backend
|
||||||
|
FRONTEND_IMAGE: ahp/pargar-frontend
|
||||||
|
# Single credential location shared by login + build steps (the job runs
|
||||||
|
# in a container whose HOME can differ between steps).
|
||||||
|
DOCKER_CONFIG: /tmp/.docker
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
# Gitea runners match on their registered labels (default: linux-amd64)
|
||||||
|
runs-on: linux-amd64
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Image tag (strip leading v)
|
||||||
|
id: meta
|
||||||
|
run: echo "version=${GITHUB_REF_NAME#v}" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
|
# Builds run docker-outside-of-docker through the runner-mounted
|
||||||
|
# /var/run/docker.sock. The apollo runner's job image (act-job:20,
|
||||||
|
# .gitea/job-image) already ships the docker CLI + buildx in system
|
||||||
|
# plugin paths; runners on other networks fall back to installing them
|
||||||
|
# at runtime (needs access to download.docker.com + github.com, and the
|
||||||
|
# plugin must land where docker looks with DOCKER_CONFIG set).
|
||||||
|
- name: Set up Docker CLI (preinstalled on apollo; install elsewhere)
|
||||||
|
run: |
|
||||||
|
set -eu
|
||||||
|
if [ ! -S /var/run/docker.sock ]; then
|
||||||
|
echo "::error::/var/run/docker.sock is not mounted in the job container - the act_runner config must mount it (docker_host: \"\" auto-mounts it)."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
if ! command -v docker >/dev/null 2>&1 || ! docker buildx version >/dev/null 2>&1; then
|
||||||
|
curl -fsSL "https://download.docker.com/linux/static/stable/x86_64/docker-27.5.1.tgz" | tar xz --strip-components=1 -C /usr/local/bin docker/docker
|
||||||
|
mkdir -p /root/.docker/cli-plugins /usr/local/libexec/docker/cli-plugins
|
||||||
|
curl -fsSL "https://github.com/docker/buildx/releases/download/v0.19.3/buildx-v0.19.3.linux-amd64" -o /root/.docker/cli-plugins/docker-buildx
|
||||||
|
cp /root/.docker/cli-plugins/docker-buildx /usr/local/libexec/docker/cli-plugins/docker-buildx
|
||||||
|
chmod +x /root/.docker/cli-plugins/docker-buildx /usr/local/libexec/docker/cli-plugins/docker-buildx
|
||||||
|
fi
|
||||||
|
docker version
|
||||||
|
docker buildx version
|
||||||
|
|
||||||
|
- name: Login to Gitea container registry
|
||||||
|
uses: docker/login-action@v3
|
||||||
|
with:
|
||||||
|
registry: ${{ env.REGISTRY }}
|
||||||
|
username: ${{ github.actor }}
|
||||||
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
||||||
|
|
||||||
|
- name: Build and push backend
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: ./backend
|
||||||
|
push: true
|
||||||
|
tags: |
|
||||||
|
${{ env.REGISTRY }}/${{ env.BACKEND_IMAGE }}:${{ steps.meta.outputs.version }}
|
||||||
|
${{ env.REGISTRY }}/${{ env.BACKEND_IMAGE }}:latest
|
||||||
|
|
||||||
|
- name: Build and push frontend
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: ./frontend
|
||||||
|
push: true
|
||||||
|
# Empty = same-origin API/WS through the Traefik reverse proxy
|
||||||
|
# (the production topology). Override via repo variables if needed.
|
||||||
|
build-args: |
|
||||||
|
NEXT_PUBLIC_API_URL=${{ vars.NEXT_PUBLIC_API_URL }}
|
||||||
|
NEXT_PUBLIC_WS_URL=${{ vars.NEXT_PUBLIC_WS_URL }}
|
||||||
|
tags: |
|
||||||
|
${{ env.REGISTRY }}/${{ env.FRONTEND_IMAGE }}:${{ steps.meta.outputs.version }}
|
||||||
|
${{ env.REGISTRY }}/${{ env.FRONTEND_IMAGE }}:latest
|
||||||
@@ -2,8 +2,8 @@ apiVersion: v2
|
|||||||
name: pargar
|
name: pargar
|
||||||
description: Pargar gated LMS - Go API, Next.js frontend, Postgres, Redis, S3-compatible storage
|
description: Pargar gated LMS - Go API, Next.js frontend, Postgres, Redis, S3-compatible storage
|
||||||
type: application
|
type: application
|
||||||
version: 0.2.3
|
version: 0.2.4
|
||||||
appVersion: "0.2.1"
|
appVersion: "0.3.7"
|
||||||
keywords:
|
keywords:
|
||||||
- lms
|
- lms
|
||||||
- pargar
|
- pargar
|
||||||
|
|||||||
@@ -8,7 +8,10 @@
|
|||||||
{{- else if and .Values.postgres.auth.password (not (hasPrefix "change-me" .Values.postgres.auth.password)) (ne .Values.postgres.auth.password "") }}
|
{{- else if and .Values.postgres.auth.password (not (hasPrefix "change-me" .Values.postgres.auth.password)) (ne .Values.postgres.auth.password "") }}
|
||||||
{{- $pgPass = .Values.postgres.auth.password }}
|
{{- $pgPass = .Values.postgres.auth.password }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{- $pgPass = randAlphaNum 32 }}
|
{{- /* Fail loudly instead of silently minting a random password: under
|
||||||
|
Argo CD (helm template) `lookup` is always empty, and a random
|
||||||
|
value would diverge from the live service on every render. */}}
|
||||||
|
{{- fail "postgres.auth.password must be set: no existing pargar-postgres secret was found and .Values.postgres.auth.password is empty or a change-me placeholder" }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
@@ -30,7 +33,7 @@ stringData:
|
|||||||
{{- else if and .Values.redis.auth.password (not (hasPrefix "change-me" .Values.redis.auth.password)) (ne .Values.redis.auth.password "") }}
|
{{- else if and .Values.redis.auth.password (not (hasPrefix "change-me" .Values.redis.auth.password)) (ne .Values.redis.auth.password "") }}
|
||||||
{{- $rdPass = .Values.redis.auth.password }}
|
{{- $rdPass = .Values.redis.auth.password }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{- $rdPass = randAlphaNum 32 }}
|
{{- fail "redis.auth.password must be set: no existing pargar-redis secret was found and .Values.redis.auth.password is empty or a change-me placeholder" }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
@@ -56,7 +59,7 @@ stringData:
|
|||||||
{{- else if and .Values.rustfs.auth.secretKey (not (hasPrefix "change-me" .Values.rustfs.auth.secretKey)) (ne .Values.rustfs.auth.secretKey "") }}
|
{{- else if and .Values.rustfs.auth.secretKey (not (hasPrefix "change-me" .Values.rustfs.auth.secretKey)) (ne .Values.rustfs.auth.secretKey "") }}
|
||||||
{{- $secret = .Values.rustfs.auth.secretKey }}
|
{{- $secret = .Values.rustfs.auth.secretKey }}
|
||||||
{{- else }}
|
{{- else }}
|
||||||
{{- $secret = randAlphaNum 40 }}
|
{{- fail "rustfs.auth.secretKey must be set: no existing pargar-rustfs secret was found and .Values.rustfs.auth.secretKey is empty or a change-me placeholder" }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: Secret
|
kind: Secret
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
{{- if .Values.backend.metrics.serviceMonitor.enabled }}
|
||||||
|
apiVersion: monitoring.coreos.com/v1
|
||||||
|
kind: ServiceMonitor
|
||||||
|
metadata:
|
||||||
|
name: {{ include "pargar.fullname" . }}-backend
|
||||||
|
labels:
|
||||||
|
{{- include "pargar.labels" . | nindent 4 }}
|
||||||
|
app.kubernetes.io/component: backend
|
||||||
|
spec:
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
{{- include "pargar.selectorLabels" . | nindent 6 }}
|
||||||
|
app.kubernetes.io/component: backend
|
||||||
|
namespaceSelector:
|
||||||
|
matchNames:
|
||||||
|
- {{ .Release.Namespace }}
|
||||||
|
endpoints:
|
||||||
|
- port: http
|
||||||
|
path: /metrics
|
||||||
|
interval: {{ .Values.backend.metrics.serviceMonitor.interval | default "30s" }}
|
||||||
|
scheme: http
|
||||||
|
# /metrics answers 401 without it; Prometheus sends it as
|
||||||
|
# Authorization: Bearer <token>.
|
||||||
|
authorization:
|
||||||
|
type: Bearer
|
||||||
|
credentials:
|
||||||
|
name: {{ include "pargar.appSecretName" . }}
|
||||||
|
key: metrics-token
|
||||||
|
{{- end }}
|
||||||
@@ -11,7 +11,7 @@ backend:
|
|||||||
image:
|
image:
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
repository: pargar-backend
|
repository: pargar-backend
|
||||||
tag: 0.2.1
|
tag: 0.3.9
|
||||||
metrics:
|
metrics:
|
||||||
serviceMonitor:
|
serviceMonitor:
|
||||||
enabled: true
|
enabled: true
|
||||||
@@ -41,7 +41,7 @@ frontend:
|
|||||||
image:
|
image:
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
repository: pargar-frontend
|
repository: pargar-frontend
|
||||||
tag: 0.2.1
|
tag: 0.3.9
|
||||||
podDisruptionBudget:
|
podDisruptionBudget:
|
||||||
enabled: false
|
enabled: false
|
||||||
replicaCount: 2
|
replicaCount: 2
|
||||||
@@ -55,9 +55,13 @@ frontend:
|
|||||||
global:
|
global:
|
||||||
domain: pargar.panahifar.ir
|
domain: pargar.panahifar.ir
|
||||||
frontendOrigins: https://pargar.panahifar.ir
|
frontendOrigins: https://pargar.panahifar.ir
|
||||||
imageRegistry: ""
|
# Images published by .gitea/workflows/build-and-push.yaml on tag push.
|
||||||
|
imageRegistry: src.panahifar.ir/ahp
|
||||||
publicUrl: https://pargar.panahifar.ir
|
publicUrl: https://pargar.panahifar.ir
|
||||||
imagePullSecrets: []
|
# Gitea packages are private: kubelet pulls need secret `gitea-pull`
|
||||||
|
# (docker-registry secret for src.panahifar.ir, created in ns pargar).
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: gitea-pull
|
||||||
ingress:
|
ingress:
|
||||||
enabled: true
|
enabled: true
|
||||||
tls:
|
tls:
|
||||||
|
|||||||
@@ -3,25 +3,26 @@
|
|||||||
# -f deploy/helm/pargar/values-prod.yaml
|
# -f deploy/helm/pargar/values-prod.yaml
|
||||||
#
|
#
|
||||||
# Prerequisites:
|
# Prerequisites:
|
||||||
# - images pushed to ghcr.io/pargar/{backend,frontend}:<tag>
|
# - images pushed to src.panahifar.ir/ahp/{pargar-backend,pargar-frontend}:<tag>
|
||||||
|
# (by .gitea/workflows/build-and-push.yaml on a v* tag push)
|
||||||
# - Secret pargar-app (jwt-secret, admin-password, metrics-token, database-url, redis-url,
|
# - Secret pargar-app (jwt-secret, admin-password, metrics-token, database-url, redis-url,
|
||||||
# storage-access-key, storage-secret-key)
|
# storage-access-key, storage-secret-key)
|
||||||
# - cert-manager ClusterIssuer letsencrypt-prod
|
# - cert-manager ClusterIssuer letsencrypt-prod
|
||||||
# - imagePullSecrets if the registry is private
|
# - imagePullSecrets if the Gitea package registry visibility is private
|
||||||
|
|
||||||
global:
|
global:
|
||||||
domain: app.example.com
|
domain: app.example.com
|
||||||
publicUrl: https://app.example.com
|
publicUrl: https://app.example.com
|
||||||
frontendOrigins: "https://app.example.com"
|
frontendOrigins: "https://app.example.com"
|
||||||
imageRegistry: ghcr.io/pargar
|
imageRegistry: src.panahifar.ir/ahp
|
||||||
|
|
||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
- name: ghcr-pull
|
- name: gitea-pull
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
replicaCount: 2
|
replicaCount: 2
|
||||||
image:
|
image:
|
||||||
repository: backend
|
repository: pargar-backend
|
||||||
tag: "0.2.1"
|
tag: "0.2.1"
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
existingSecret: pargar-app
|
existingSecret: pargar-app
|
||||||
@@ -48,7 +49,7 @@ backend:
|
|||||||
frontend:
|
frontend:
|
||||||
replicaCount: 2
|
replicaCount: 2
|
||||||
image:
|
image:
|
||||||
repository: frontend
|
repository: pargar-frontend
|
||||||
tag: "0.2.1"
|
tag: "0.2.1"
|
||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
resources:
|
resources:
|
||||||
|
|||||||
@@ -25,6 +25,13 @@ backend:
|
|||||||
pullPolicy: IfNotPresent
|
pullPolicy: IfNotPresent
|
||||||
service:
|
service:
|
||||||
port: 8080
|
port: 8080
|
||||||
|
metrics:
|
||||||
|
# Prometheus Operator ServiceMonitor. /metrics is bearer-protected by
|
||||||
|
# METRICS_TOKEN, so the endpoint carries authorization credentials
|
||||||
|
# (pargar-app secret) instead of scraping anonymously.
|
||||||
|
serviceMonitor:
|
||||||
|
enabled: false
|
||||||
|
interval: 30s
|
||||||
resources:
|
resources:
|
||||||
requests:
|
requests:
|
||||||
cpu: 50m
|
cpu: 50m
|
||||||
|
|||||||
@@ -3269,7 +3269,7 @@ ws.onmessage = (ev) => {
|
|||||||
setOpen(true);
|
setOpen(true);
|
||||||
setNotif(null);
|
setNotif(null);
|
||||||
}}
|
}}
|
||||||
className="fixed bottom-24 start-5 end-5 z-[64] flex max-w-full items-center gap-2.5 rounded-2xl border-2 border-white/50 bg-card/85 p-2.5 text-right shadow-offset backdrop-blur-2xl sm:end-auto sm:max-w-[300px]"
|
className="fixed bottom-[calc(5.5rem+env(safe-area-inset-bottom,0px))] start-5 end-5 z-[64] flex max-w-full items-center gap-2.5 rounded-2xl border-2 border-white/50 bg-card/85 p-2.5 text-right shadow-offset backdrop-blur-2xl sm:bottom-24 sm:end-auto sm:max-w-[300px]"
|
||||||
>
|
>
|
||||||
<span className="grid h-9 w-9 shrink-0 place-items-center rounded-xl bg-accent/15">
|
<span className="grid h-9 w-9 shrink-0 place-items-center rounded-xl bg-accent/15">
|
||||||
<MessageSquare className="h-4 w-4 text-accent" />
|
<MessageSquare className="h-4 w-4 text-accent" />
|
||||||
@@ -3286,7 +3286,9 @@ ws.onmessage = (ev) => {
|
|||||||
</AnimatePresence>
|
</AnimatePresence>
|
||||||
|
|
||||||
{me && !open && (
|
{me && !open && (
|
||||||
<div className="fixed bottom-5 start-5 z-[64]">
|
// On mobile the bottom nav is 56px; lift FAB above it + safe area + gap.
|
||||||
|
// md:bottom-5 restores original position when the bottom nav is hidden.
|
||||||
|
<div className="fixed bottom-[calc(4.5rem+env(safe-area-inset-bottom,0px))] start-5 z-[64] md:bottom-5">
|
||||||
<div className="relative">
|
<div className="relative">
|
||||||
{unreadTotal > 0 && (
|
{unreadTotal > 0 && (
|
||||||
<span className="pointer-events-none absolute -inset-1 -z-10 animate-ping rounded-2xl bg-accent/40" aria-hidden />
|
<span className="pointer-events-none absolute -inset-1 -z-10 animate-ping rounded-2xl bg-accent/40" aria-hidden />
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import {
|
|||||||
} from "lucide-react";
|
} from "lucide-react";
|
||||||
import { useMemo, useState } from "react";
|
import { useMemo, useState } from "react";
|
||||||
import type { TreeChapter, TreeData, TreeLesson } from "@/lib/types";
|
import type { TreeChapter, TreeData, TreeLesson } from "@/lib/types";
|
||||||
|
import { useAuth } from "@/lib/auth-store";
|
||||||
import { cn, formatFaNumber } from "@/lib/utils";
|
import { cn, formatFaNumber } from "@/lib/utils";
|
||||||
|
|
||||||
const CHAPTER_ICONS: Record<string, typeof Terminal> = {
|
const CHAPTER_ICONS: Record<string, typeof Terminal> = {
|
||||||
@@ -38,6 +39,8 @@ const CHAPTER_ICONS: Record<string, typeof Terminal> = {
|
|||||||
|
|
||||||
export function SkillTree({ data, onSelect }: { data: TreeData; onSelect?: (id: number) => void }) {
|
export function SkillTree({ data, onSelect }: { data: TreeData; onSelect?: (id: number) => void }) {
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
const role = useAuth((s) => s.user?.role);
|
||||||
|
const isStaff = role === "admin" || role === "mentor";
|
||||||
|
|
||||||
const chapters = useMemo(() => [...data.chapters].sort((a, b) => a.sortOrder - b.sortOrder), [data]);
|
const chapters = useMemo(() => [...data.chapters].sort((a, b) => a.sortOrder - b.sortOrder), [data]);
|
||||||
const byId = useMemo(() => {
|
const byId = useMemo(() => {
|
||||||
@@ -97,6 +100,7 @@ export function SkillTree({ data, onSelect }: { data: TreeData; onSelect?: (id:
|
|||||||
open={expanded.has(ch.id)}
|
open={expanded.has(ch.id)}
|
||||||
onToggle={() => toggle(ch.id)}
|
onToggle={() => toggle(ch.id)}
|
||||||
onSelect={onSelect ?? ((id: number) => router.push(`/player/${id}`))}
|
onSelect={onSelect ?? ((id: number) => router.push(`/player/${id}`))}
|
||||||
|
isStaff={isStaff}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
@@ -110,12 +114,14 @@ function ChapterRow({
|
|||||||
open,
|
open,
|
||||||
onToggle,
|
onToggle,
|
||||||
onSelect,
|
onSelect,
|
||||||
|
isStaff,
|
||||||
}: {
|
}: {
|
||||||
ch: TreeChapter;
|
ch: TreeChapter;
|
||||||
byId: Map<number, TreeLesson>;
|
byId: Map<number, TreeLesson>;
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onToggle: () => void;
|
onToggle: () => void;
|
||||||
onSelect: (id: number) => void;
|
onSelect: (id: number) => void;
|
||||||
|
isStaff: boolean;
|
||||||
}) {
|
}) {
|
||||||
const lessons = [...(ch.lessons ?? [])].sort((a, b) => a.y - b.y || a.x - b.x);
|
const lessons = [...(ch.lessons ?? [])].sort((a, b) => a.y - b.y || a.x - b.x);
|
||||||
const done = lessons.filter((l) => l.progress?.passedQuiz).length;
|
const done = lessons.filter((l) => l.progress?.passedQuiz).length;
|
||||||
@@ -147,8 +153,13 @@ function ChapterRow({
|
|||||||
<CheckCircle2 className="h-3.5 w-3.5" /> کامل شد
|
<CheckCircle2 className="h-3.5 w-3.5" /> کامل شد
|
||||||
</span>
|
</span>
|
||||||
)}
|
)}
|
||||||
|
{isStaff && !ch.isPublished && (
|
||||||
|
<span className="hidden shrink-0 rounded-full border border-dashed border-warning/50 bg-warning/10 px-2 py-0.5 text-[11px] font-bold text-warning sm:inline-block">
|
||||||
|
پیشنویس
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
<span className="hidden shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-bold text-muted-foreground sm:inline-block">
|
<span className="hidden shrink-0 rounded-full bg-muted px-2 py-0.5 text-[11px] font-bold text-muted-foreground sm:inline-block">
|
||||||
هفتهٔ {ch.sortOrder}
|
فصل {ch.sortOrder}
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<p className="truncate text-xs text-muted-foreground">{ch.description}</p>
|
<p className="truncate text-xs text-muted-foreground">{ch.description}</p>
|
||||||
@@ -173,7 +184,7 @@ function ChapterRow({
|
|||||||
<div className="overflow-hidden">
|
<div className="overflow-hidden">
|
||||||
<div className="grid gap-2.5 border-t-2 border-border/70 p-4 sm:grid-cols-2">
|
<div className="grid gap-2.5 border-t-2 border-border/70 p-4 sm:grid-cols-2">
|
||||||
{lessons.map((lesson) => (
|
{lessons.map((lesson) => (
|
||||||
<LessonRow key={lesson.id} lesson={lesson} byId={byId} onSelect={onSelect} />
|
<LessonRow key={lesson.id} lesson={lesson} byId={byId} onSelect={onSelect} isStaff={isStaff} />
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -186,10 +197,12 @@ function LessonRow({
|
|||||||
lesson,
|
lesson,
|
||||||
byId,
|
byId,
|
||||||
onSelect,
|
onSelect,
|
||||||
|
isStaff,
|
||||||
}: {
|
}: {
|
||||||
lesson: TreeLesson;
|
lesson: TreeLesson;
|
||||||
byId: Map<number, TreeLesson>;
|
byId: Map<number, TreeLesson>;
|
||||||
onSelect: (id: number) => void;
|
onSelect: (id: number) => void;
|
||||||
|
isStaff: boolean;
|
||||||
}) {
|
}) {
|
||||||
const passed = !!lesson.progress?.passedQuiz;
|
const passed = !!lesson.progress?.passedQuiz;
|
||||||
const locked = lesson.locked;
|
const locked = lesson.locked;
|
||||||
@@ -254,6 +267,11 @@ function LessonRow({
|
|||||||
</div>
|
</div>
|
||||||
<div className="mt-1.5 flex flex-wrap items-center gap-2">
|
<div className="mt-1.5 flex flex-wrap items-center gap-2">
|
||||||
<span className={cn("rounded-full px-2 py-0.5 text-[11px] font-bold", s.pill)}>{s.pillText}</span>
|
<span className={cn("rounded-full px-2 py-0.5 text-[11px] font-bold", s.pill)}>{s.pillText}</span>
|
||||||
|
{isStaff && lesson.isPublished === false && (
|
||||||
|
<span className="rounded-full border border-dashed border-warning/50 bg-warning/10 px-2 py-0.5 text-[11px] font-bold text-warning">
|
||||||
|
پیشنویس
|
||||||
|
</span>
|
||||||
|
)}
|
||||||
{inProgress && (
|
{inProgress && (
|
||||||
<div className="h-1.5 w-24 overflow-hidden rounded-full bg-muted">
|
<div className="h-1.5 w-24 overflow-hidden rounded-full bg-muted">
|
||||||
<div className="h-full rounded-full bg-primary" style={{ width: `${pct}%` }} />
|
<div className="h-full rounded-full bg-primary" style={{ width: `${pct}%` }} />
|
||||||
|
|||||||
@@ -117,6 +117,7 @@ export interface TreeLesson {
|
|||||||
xpReward: number;
|
xpReward: number;
|
||||||
durationSeconds: number;
|
durationSeconds: number;
|
||||||
chapterId: number;
|
chapterId: number;
|
||||||
|
isPublished?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TreeChapter extends Chapter {
|
export interface TreeChapter extends Chapter {
|
||||||
|
|||||||
Reference in New Issue
Block a user