返回 AiToEarn
1 /**
2 * 发布弹框底部操作栏
3 * 包含发布按钮等操作
4 */
5
6 import { ArrowRight } from 'lucide-react'
7 import { memo } from 'react'
8 import { useShallow } from 'zustand/react/shallow'
9 import { useTransClient } from '@/app/i18n/client'
10 import PublishDatePicker from '@/components/PublishDialog/compoents/PublishDatePicker'
11 import { useValidatedPublishTrigger } from '@/components/PublishDialog/hooks/useValidatedPublishTrigger'
12 import { usePublishDialog } from '@/components/PublishDialog/usePublishDialog'
13 import { Button } from '@/components/ui/button'
14
15 interface PublishFooterProps {
16 createLoading: boolean
17 // 外部回调
18 onPublish: () => void
19 onNextStep: () => void
20 }
21
22 /**
23 * 发布弹框底部操作栏
24 */
25 export const PublishFooter = memo(
26 ({
27 createLoading,
28 onPublish,
29 onNextStep,
30 }: PublishFooterProps) => {
31 const { t } = useTransClient('publish')
32 const { step, pubListChoosed } = usePublishDialog(
33 useShallow(state => ({
34 step: state.step,
35 pubListChoosed: state.pubListChoosed,
36 })),
37 )
38 const { triggerPublish } = useValidatedPublishTrigger(onPublish)
39
40 // ============ Render ============
41
42 return (
43 <div
44 className="flex items-center border-t border-border justify-between box-border p-5"
45 onClick={e => e.stopPropagation()}
46 data-testid="publish-footer"
47 >
48 <div className="flex w-full justify-end gap-3">
49 {step === 0 && pubListChoosed.length >= 2 ? (
50 <Button
51 size="lg"
52 variant="outline"
53 onClick={onNextStep}
54 className="gap-2 cursor-pointer"
55 data-testid="publish-customize-button"
56 >
57 {t('buttons.customizePerAccount')}
58 <ArrowRight className="h-4 w-4" />
59 </Button>
60 ) : (
61 <PublishDatePicker loading={createLoading} onClick={triggerPublish} />
62 )}
63 </div>
64 </div>
65 )
66 },
67 )
68
69 PublishFooter.displayName = 'PublishFooter'
70
71 export default PublishFooter
72
72 lines Plain Text