Get image upload to cloudinary with the same public id
This means we can put a consistent url in the head for the card image
This commit is contained in:
24
app/web/src/helpers/hooks/useUpdateSocialCard.ts
Normal file
24
app/web/src/helpers/hooks/useUpdateSocialCard.ts
Normal file
@@ -0,0 +1,24 @@
|
||||
import { useMutation } from '@redwoodjs/web'
|
||||
|
||||
const UPDATE_SOCIAL_CARD_MUTATION_HOOK = gql`
|
||||
mutation updateSocialCardByProjectId($projectId: String!, $url: String!) {
|
||||
updateSocialCardByProjectId(projectId: $projectId, url: $url) {
|
||||
id
|
||||
url
|
||||
}
|
||||
}
|
||||
`
|
||||
|
||||
export const useUpdateSocialCard = ({ onCompleted = () => {} }) => {
|
||||
const [updateSocialCard, { loading, error }] = useMutation(
|
||||
UPDATE_SOCIAL_CARD_MUTATION_HOOK,
|
||||
{ onCompleted }
|
||||
)
|
||||
|
||||
return { updateSocialCard, loading, error }
|
||||
}
|
||||
|
||||
export const makeSocialPublicId = (
|
||||
userName: string,
|
||||
projectTitle: string
|
||||
): string => `u-${userName}-slash-p-${projectTitle}`
|
||||
Reference in New Issue
Block a user