Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

3.9 KB
Raw Blame
'use client'

import type { SubscriptionModel } from '@dify/contracts/api/console/features/types.gen'
import type {
  GetWorkspacesCurrentSummaryResponse,
  TenantListItemResponse,
} from '@dify/contracts/api/console/workspaces/types.gen'
import type { ReactNode } from 'react'
import { Select, SelectTrigger } from '@langgenius/dify-ui/select'
import { useTranslation } from 'react-i18next'
import { WorkplaceSelectorContent } from '@/app/components/header/account-menu/workplace-selector'
import { PlanBadge } from '@/app/components/header/plan-badge'

type AppliedEducationContentProps = {
  workspaces: TenantListItemResponse[]
  currentWorkspace: GetWorkspacesCurrentSummaryResponse
  plan: SubscriptionModel['plan']
  action: ReactNode
  isSwitchingWorkspace: boolean
  onSwitchWorkspace: (tenantId: string) => void
}

const AppliedEducationContent = ({
  workspaces,
  currentWorkspace,
  plan,
  action,
  isSwitchingWorkspace,
  onSwitchWorkspace,
}: AppliedEducationContentProps) => {
  const { t } = useTranslation(['education'])
  const currentWorkspaceInList = workspaces.find((workspace) => workspace.current)
  const workspacePlan = currentWorkspaceInList?.plan ?? plan
  const workspaceName = currentWorkspaceInList?.name || currentWorkspace?.name
  const workspaceId = currentWorkspaceInList?.id || currentWorkspace?.id

  return (
    <div className="flex w-full flex-col gap-4">
      <div className="rounded-lg border border-effects-highlight bg-background-default-subtle px-3">
        <div className="flex items-center gap-2">
          <div className="flex size-5 shrink-0 items-center justify-center rounded-full bg-state-success-solid text-text-primary-on-surface">
            <span className="i-ri-check-line size-3.5" aria-hidden="true" />
          </div>
          <div>
            <div className="text-text-secondary">
              {t(($) => $['applied.step1.description'], { ns: 'education' })}
            </div>
          </div>
        </div>
      </div>
      <div className="rounded-lg px-3">
        <div className="mb-3.5 flex items-center gap-2">
          <div className="flex size-5 shrink-0 items-center justify-center rounded-full bg-components-icon-bg-blue-solid system-xs-semibold text-text-primary-on-surface">
            2
          </div>
          <div>
            <div className="system-xl-medium text-text-secondary">
              {t(($) => $['applied.step2.description'], { ns: 'education' })}
            </div>
          </div>
        </div>
        <div className="ml-7">
          <Select
            value={workspaceId ?? ''}
            onValueChange={(value) => {
              if (value) onSwitchWorkspace(value)
            }}
          >
            <SelectTrigger
              className="h-12! w-fit max-w-full min-w-70 cursor-pointer justify-between rounded-lg border-[0.5px] border-transparent bg-components-input-bg-normal px-3! py-1.5! hover:bg-state-base-hover"
              disabled={isSwitchingWorkspace}
            >
              <span className="flex min-w-0 items-center gap-3">
                <span className="flex size-8 shrink-0 items-center justify-center rounded-lg bg-components-icon-bg-blue-solid text-[14px]">
                  <span className="bg-linear-to-r from-components-avatar-shape-fill-stop-0 to-components-avatar-shape-fill-stop-100 bg-clip-text font-semibold text-shadow-shadow-1 uppercase opacity-90">
                    {workspaceName?.[0]?.toLocaleUpperCase()}
                  </span>
                </span>
                <span className="min-w-0 truncate system-md-semibold text-text-primary">
                  {workspaceName}
                </span>
                <PlanBadge plan={workspacePlan} />
              </span>
            </SelectTrigger>
            <WorkplaceSelectorContent workspaces={workspaces} />
          </Select>
          <div className="mt-3 pr-5">{action}</div>
        </div>
      </div>
    </div>
  )
}

export default AppliedEducationContent