Show upload photo button for new admins
This commit is contained in:
parent
c475932b8f
commit
a6fd48bd1b
25
src/admin/AdminCTA.tsx
Normal file
25
src/admin/AdminCTA.tsx
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
'use client';
|
||||||
|
|
||||||
|
import PhotoUpload from '@/photo/PhotoUpload';
|
||||||
|
import { PATH_ADMIN_PHOTOS } from '@/site/paths';
|
||||||
|
import { useAppState } from '@/state/AppState';
|
||||||
|
import Link from 'next/link';
|
||||||
|
import { FaArrowRight } from 'react-icons/fa';
|
||||||
|
|
||||||
|
export default function AdminCTA() {
|
||||||
|
const { isUserSignedIn } = useAppState();
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div className="flex justify-center pt-4">
|
||||||
|
{isUserSignedIn
|
||||||
|
? <PhotoUpload showUploadStatus={false} />
|
||||||
|
: <Link
|
||||||
|
href={PATH_ADMIN_PHOTOS}
|
||||||
|
className="button primary"
|
||||||
|
>
|
||||||
|
<span>Admin Dashboard</span>
|
||||||
|
<FaArrowRight size={10} />
|
||||||
|
</Link>}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
@ -19,6 +19,7 @@ export default function ImageInput({
|
|||||||
maxSize = MAX_IMAGE_SIZE,
|
maxSize = MAX_IMAGE_SIZE,
|
||||||
quality = 0.8,
|
quality = 0.8,
|
||||||
loading,
|
loading,
|
||||||
|
showUploadStatus = true,
|
||||||
debug,
|
debug,
|
||||||
}: {
|
}: {
|
||||||
onStart?: () => void
|
onStart?: () => void
|
||||||
@ -32,6 +33,7 @@ export default function ImageInput({
|
|||||||
maxSize?: number
|
maxSize?: number
|
||||||
quality?: number
|
quality?: number
|
||||||
loading?: boolean
|
loading?: boolean
|
||||||
|
showUploadStatus?: boolean
|
||||||
debug?: boolean
|
debug?: boolean
|
||||||
}) {
|
}) {
|
||||||
const ref = useRef<HTMLCanvasElement>(null);
|
const ref = useRef<HTMLCanvasElement>(null);
|
||||||
@ -62,7 +64,7 @@ export default function ImageInput({
|
|||||||
)}
|
)}
|
||||||
aria-disabled={loading}
|
aria-disabled={loading}
|
||||||
>
|
>
|
||||||
<span className="w-4 inline-flex items-center">
|
<span className="w-4 inline-flex items-center mr-1">
|
||||||
{loading
|
{loading
|
||||||
? <Spinner color="text" className="translate-y-[0.5px]" />
|
? <Spinner color="text" className="translate-y-[0.5px]" />
|
||||||
: <FiUploadCloud
|
: <FiUploadCloud
|
||||||
@ -219,7 +221,7 @@ export default function ImageInput({
|
|||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
</label>
|
</label>
|
||||||
{filesLength > 0 &&
|
{showUploadStatus && filesLength > 0 &&
|
||||||
<div className="max-w-full truncate text-ellipsis">
|
<div className="max-w-full truncate text-ellipsis">
|
||||||
{uploadStatusText}
|
{uploadStatusText}
|
||||||
</div>}
|
</div>}
|
||||||
|
|||||||
@ -10,10 +10,12 @@ import { clsx } from 'clsx/lite';
|
|||||||
export default function PhotoUpload({
|
export default function PhotoUpload({
|
||||||
shouldResize,
|
shouldResize,
|
||||||
onLastUpload,
|
onLastUpload,
|
||||||
|
showUploadStatus,
|
||||||
debug,
|
debug,
|
||||||
}: {
|
}: {
|
||||||
shouldResize?: boolean
|
shouldResize?: boolean
|
||||||
onLastUpload?: () => Promise<void>
|
onLastUpload?: () => Promise<void>
|
||||||
|
showUploadStatus?: boolean
|
||||||
debug?: boolean
|
debug?: boolean
|
||||||
}) {
|
}) {
|
||||||
const [isUploading, setIsUploading] = useState(false);
|
const [isUploading, setIsUploading] = useState(false);
|
||||||
@ -75,6 +77,7 @@ export default function PhotoUpload({
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
|
showUploadStatus={showUploadStatus}
|
||||||
debug={debug}
|
debug={debug}
|
||||||
/>
|
/>
|
||||||
</form>
|
</form>
|
||||||
|
|||||||
@ -1,11 +1,11 @@
|
|||||||
|
import AdminCTA from '@/admin/AdminCTA';
|
||||||
import InfoBlock from '@/components/InfoBlock';
|
import InfoBlock from '@/components/InfoBlock';
|
||||||
import SiteGrid from '@/components/SiteGrid';
|
import SiteGrid from '@/components/SiteGrid';
|
||||||
import { IS_SITE_READY } from '@/site/config';
|
import { IS_SITE_READY } from '@/site/config';
|
||||||
import { PATH_ADMIN_CONFIGURATION, PATH_ADMIN_PHOTOS } from '@/site/paths';
|
import { PATH_ADMIN_CONFIGURATION } from '@/site/paths';
|
||||||
import SiteChecklist from '@/site/SiteChecklist';
|
import SiteChecklist from '@/site/SiteChecklist';
|
||||||
import { clsx } from 'clsx/lite';
|
import { clsx } from 'clsx/lite';
|
||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { FaArrowRight } from 'react-icons/fa';
|
|
||||||
import { HiOutlinePhotograph } from 'react-icons/hi';
|
import { HiOutlinePhotograph } from 'react-icons/hi';
|
||||||
|
|
||||||
export default function PhotosEmptyState() {
|
export default function PhotosEmptyState() {
|
||||||
@ -33,13 +33,7 @@ export default function PhotosEmptyState() {
|
|||||||
<div>
|
<div>
|
||||||
Add your first photo:
|
Add your first photo:
|
||||||
</div>
|
</div>
|
||||||
<Link
|
<AdminCTA />
|
||||||
href={PATH_ADMIN_PHOTOS}
|
|
||||||
className="button primary"
|
|
||||||
>
|
|
||||||
<span>Admin Dashboard</span>
|
|
||||||
<FaArrowRight size={10} />
|
|
||||||
</Link>
|
|
||||||
</div>
|
</div>
|
||||||
<div>
|
<div>
|
||||||
Change the name of this blog and other configuration
|
Change the name of this blog and other configuration
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user