Skip to content

Commit

Permalink
wip getCurrentUser
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlevy0 committed Dec 29, 2023
1 parent 7ca272d commit 022c4ea
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 17 deletions.
16 changes: 8 additions & 8 deletions amplify/backend/function/S3Triggera6bc74ca/lib/rekognition.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import * as fs from 'fs/promises'
import {
RekognitionClient,
StartFaceDetectionCommand,
GetFaceDetectionCommand,
FaceDetection,
GetFaceDetectionCommandOutput,
BoundingBox,
Emotion,
FaceDetection,
GetFaceDetectionCommand,
GetFaceDetectionCommandOutput,
RekognitionClient,
StartFaceDetectionCommand,
} from '@aws-sdk/client-rekognition'
import * as fs from 'fs/promises'
import { conf } from './config'
import { sleep } from './utils'
import { CropCoordinates, VideoShot } from './types'
import { sleep } from './utils'

const {
jobCheckDelay,
Expand Down Expand Up @@ -276,4 +276,4 @@ export async function analyzeVideo(Name: string, Bucket: string): Promise<VideoS
console.log('mergedShots ->', mergedShots.length)
console.log({ mergedShots })
return mergedShots
}
}
32 changes: 23 additions & 9 deletions src/app/Main.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
/* eslint-disable react/jsx-no-undef */
'use client'
import '@aws-amplify/ui-react/styles.css'
import { loadStripe } from '@stripe/stripe-js'

import {
AccountSettings,
Authenticator,
Button,
Card,
CheckboxField,
defaultDarkModeOverride,
Divider,
Flex,
Grid,
Expand All @@ -17,16 +15,17 @@ import {
Menu,
MenuItem,
ThemeProvider,
defaultDarkModeOverride,
useAuthenticator,
useTheme,
} from '@aws-amplify/ui-react'
import { StorageManager } from '@aws-amplify/ui-react-storage'
import '@aws-amplify/ui-react/styles.css'
import { loadStripe } from '@stripe/stripe-js'
import React, { useEffect, useRef, useState } from 'react'
// @ts-expect-error:next-line
import dynamic from 'next/dynamic'
// Import { Auth } from 'aws-amplify'
import { signOut } from 'aws-amplify/auth'
import { signOut, getCurrentUser } from 'aws-amplify/auth'
// @ts-expect-error:next-line
import { Features } from './Features.tsx'
// @ts-expect-error:next-line
Expand All @@ -53,21 +52,36 @@ function Picker(props: { onClick: React.MouseEventHandler<HTMLButtonElement> | u

const ReactPlayer = dynamic(() => import('react-player/lazy'), { ssr: false })

async function currentAuthenticatedUser() {
try {
const { username, userId, signInDetails } = await getCurrentUser()
console.log(`The username: ${username}`)
console.log(`The userId: ${userId}`)
console.log(`The signInDetails: ${signInDetails}`)
} catch (err) {
console.log(err)
}
}

export function Main() {
const { tokens } = useTheme()

// const { user } = useAuthenticator(context => [context.user])
const { user } = useAuthenticator(context => [context.user])
const { authStatus } = useAuthenticator(context => [context.authStatus])
const { route, toSignIn, toSignUp } = useAuthenticator(context => [context.route])
const [showAccountSettings, setShowAccountSettings] = useState(false)
const [showFeatures, setShowFeatures] = useState(false)
const [renderAuth, setRenderAuth] = useState<'signIn' | 'signUp' | undefined>(undefined)

console.log({ user })

useEffect(() => {
if (![authStatus, route].includes('authenticated')) {
return
}
setRenderAuth(undefined)

currentAuthenticatedUser()
}, [route, authStatus])

const goSignIn = (): void => {
Expand Down Expand Up @@ -410,11 +424,11 @@ function Clip() {
flex={1}
>
<StorageManager
// maxFileSize={''} // TODO
maxFileSize={1000} // 1Go
ref={ref}
isResumable
// accessLevel="public"
accessLevel="guest" // TODO
accessLevel="private"
// accessLevel="guest"
acceptedFileTypes={['video/*']}
maxFileCount={1}
onUploadSuccess={onSuccess}
Expand Down

0 comments on commit 022c4ea

Please sign in to comment.