-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from thanhdanh27600/staging
Staging
- Loading branch information
Showing
39 changed files
with
531 additions
and
124 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
prisma/migrations/20230829160135_add_media_for_history/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
-- CreateTable | ||
CREATE TABLE "Media" ( | ||
"id" SERIAL NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
"url" TEXT NOT NULL, | ||
"urlShortenerHistoryId" INTEGER, | ||
|
||
CONSTRAINT "Media_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Media_url_key" ON "Media"("url"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "Media_urlShortenerHistoryId_key" ON "Media"("urlShortenerHistoryId"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "Media" ADD CONSTRAINT "Media_urlShortenerHistoryId_fkey" FOREIGN KEY ("urlShortenerHistoryId") REFERENCES "UrlShortenerHistory"("id") ON DELETE CASCADE ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
#!/bin/sh | ||
|
||
if [ -z "$1" ] | ||
if [ -z "$1" ] || [ -z "$2" ] | ||
then | ||
echo "Decript failed. Host is empty!" | ||
else | ||
echo "Decript with host: $1..."; | ||
echo "Decript with host: $1, to $2..."; | ||
# --batch to prevent interactive command | ||
# --yes to assume "yes" for questions | ||
gpg --quiet --batch --yes --decrypt --passphrase="$SECRET_PASSPHRASE" \ | ||
--output ./.env $1 | ||
--output $2 $1 | ||
echo "Decript successfully"; | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import { UploadCloud } from '@styled-icons/feather'; | ||
import { API } from 'api/axios'; | ||
import { CldUploadWidget } from 'next-cloudinary'; | ||
import { MouseEventHandler, useState } from 'react'; | ||
import { isProduction } from 'types/constants'; | ||
|
||
export const UploadImage = ({ | ||
onSuccess, | ||
}: { | ||
onSuccess: ({ url, mediaId }: { url: string; mediaId: number }) => void; | ||
}) => { | ||
const [resource, setResource] = useState<any>(); | ||
|
||
return ( | ||
<div> | ||
<CldUploadWidget | ||
options={{ | ||
maxFileSize: 5e6, | ||
maxImageHeight: 2400, | ||
croppingAspectRatio: 1200 / 630, | ||
cropping: true, | ||
multiple: false, | ||
showSkipCropButton: false, | ||
singleUploadAutoClose: true, | ||
showPoweredBy: false, | ||
showUploadMoreButton: false, | ||
maxFiles: 1, | ||
}} | ||
signatureEndpoint="/api/cld" | ||
uploadPreset="clickdi" | ||
onSuccess={async (result, widget) => { | ||
setResource(result?.info); | ||
const url = (result?.info as any)?.secure_url; | ||
const rs = await API.post('/api/i', { url }); | ||
if (url && rs) { | ||
onSuccess({ url, mediaId: rs.data.id }); | ||
} | ||
widget.close(); | ||
}}> | ||
{({ open }) => { | ||
const handleOnClick: MouseEventHandler<HTMLButtonElement> = (e) => { | ||
e.preventDefault(); | ||
open(); | ||
}; | ||
return ( | ||
<button | ||
className="w-fit cursor-pointer rounded-lg border border-gray-300 p-4 transition-colors hover:bg-gray-100" | ||
onClick={handleOnClick}> | ||
<UploadCloud className="h-8 w-8 text-gray-700" /> | ||
</button> | ||
); | ||
}} | ||
</CldUploadWidget> | ||
{!isProduction && ( | ||
<a className="mt-2 block" href={resource?.secure_url} target="_blank"> | ||
URL (debug): {resource?.secure_url.slice(-20) || '--'} | ||
</a> | ||
)} | ||
</div> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.