From a53414a9a0e1c7d79f50a10ca25f727f6c60ad2d Mon Sep 17 00:00:00 2001 From: Eddie Jaoude Date: Sun, 18 Jun 2023 10:43:58 +0700 Subject: [PATCH] fix: onboarding workflow and progress --- .github/workflows/vercel-preview.yml | 66 ++++++++++++++-------------- pages/account/manage/profile.js | 14 +++--- pages/account/no-profile.js | 13 +++--- pages/account/statistics.js | 10 +---- pages/api/account/manage/profile.js | 1 + 5 files changed, 52 insertions(+), 52 deletions(-) diff --git a/.github/workflows/vercel-preview.yml b/.github/workflows/vercel-preview.yml index b9baf6df0b5..703c82fe419 100644 --- a/.github/workflows/vercel-preview.yml +++ b/.github/workflows/vercel-preview.yml @@ -1,34 +1,34 @@ -name: Deploy to Vercel Preview -env: - VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} - VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} -on: - workflow_dispatch: - push: - branches: - - manage-forms +# name: Deploy to Vercel Preview +# env: +# VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} +# VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} +# on: +# workflow_dispatch: +# push: +# branches: +# - manage-forms -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - name: install Vercel CLI - run: npm install --global vercel@latest - - name: pull Vercel environment information - run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} - - name: build project artifacts - run: vercel build --token=${{ secrets.VERCEL_TOKEN }} - - name: deploy project artifacts to Vercel - run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} - - name: assign beta domain - run: | - vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} > domain.txt - vercel alias --scope ${{ secrets.VERCEL_TEAM_ID }} --token ${{ secrets.VERCEL_TOKEN }} set `cat domain.txt` linkfree-preview.vercel.app - load-data: - runs-on: ubuntu-latest - needs: deploy - steps: - - name: load json files - if: steps.changes.outputs.data == 'true' - run: curl -f https://linkfree-preview.vercel.app/api/system/reload?secret=${{ secrets.LINKFREE_API_SECRET_PREVIEW }} +# jobs: +# deploy: +# runs-on: ubuntu-latest +# steps: +# - uses: actions/checkout@v3 +# - name: install Vercel CLI +# run: npm install --global vercel@latest +# - name: pull Vercel environment information +# run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }} +# - name: build project artifacts +# run: vercel build --token=${{ secrets.VERCEL_TOKEN }} +# - name: deploy project artifacts to Vercel +# run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} +# - name: assign beta domain +# run: | +# vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }} > domain.txt +# vercel alias --scope ${{ secrets.VERCEL_TEAM_ID }} --token ${{ secrets.VERCEL_TOKEN }} set `cat domain.txt` linkfree-preview.vercel.app +# load-data: +# runs-on: ubuntu-latest +# needs: deploy +# steps: +# - name: load json files +# if: steps.changes.outputs.data == 'true' +# run: curl -f https://linkfree-preview.vercel.app/api/system/reload?secret=${{ secrets.LINKFREE_API_SECRET_PREVIEW }} diff --git a/pages/account/manage/profile.js b/pages/account/manage/profile.js index cf915e48d92..e3e4f774411 100644 --- a/pages/account/manage/profile.js +++ b/pages/account/manage/profile.js @@ -64,7 +64,9 @@ export default function Profile({ BASE_URL, profile, fileExists }) { }); const [layout, setLayout] = useState(profile.layout || "classic"); const [name, setName] = useState(profile.name); - const [bio, setBio] = useState(profile.bio); + const [bio, setBio] = useState( + profile.bio || "Have a look at my links below..." + ); const [tags, setTags] = useState(profile.tags || []); const layouts = ["classic", "inline"]; @@ -109,7 +111,7 @@ export default function Profile({ BASE_URL, profile, fileExists }) { {fileExists && ( )} @@ -187,8 +189,8 @@ export default function Profile({ BASE_URL, profile, fileExists }) { value={name} onChange={(e) => setName(e.target.value)} required - minlength="2" - maxlength="32" + minLength="2" + maxLength="32" /> @@ -200,8 +202,8 @@ export default function Profile({ BASE_URL, profile, fileExists }) { value={bio} onChange={(e) => setBio(e.target.value)} required - minlength="2" - maxlength="256" + minLength="2" + maxLength="256" />

You can use Markdown syntax. diff --git a/pages/account/no-profile.js b/pages/account/no-profile.js index fc98836fa3c..e606f95ba75 100644 --- a/pages/account/no-profile.js +++ b/pages/account/no-profile.js @@ -1,5 +1,7 @@ import { authOptions } from "../api/auth/[...nextauth]"; import { getServerSession } from "next-auth/next"; + +import { clientEnv } from "@config/schemas/clientSchema"; import Page from "@components/Page"; import PageHead from "@components/PageHead"; import Link from "@components/Link"; @@ -17,11 +19,11 @@ export async function getServerSideProps(context) { } return { - props: {}, + props: { BASE_URL: clientEnv.NEXT_PUBLIC_BASE_URL }, }; } -export default function NoProfile() { +export default function NoProfile({ BASE_URL }) { return ( <>

- Please follow the QuickStart guide to create your Profile + Please follow the QuickStart guide to create your Profile or + click on the Forms button to create your Profile

- Example + Go to Forms !Object.keys(profile).includes(property) + (property) => !profile[property]?.length ); progress.percentage = ( ((profileSections.length - progress.missing.length) / @@ -153,10 +150,7 @@ export default function Statistics({ data, profile, progress, BASE_URL }) {
-
diff --git a/pages/api/account/manage/profile.js b/pages/api/account/manage/profile.js index 8e92178cbb4..013fd63162c 100644 --- a/pages/api/account/manage/profile.js +++ b/pages/api/account/manage/profile.js @@ -69,6 +69,7 @@ export async function updateProfileApi(username, data) { try { getProfile = await Profile.findOneAndUpdate({ username }, updateProfile, { upsert: true, + new: true, }); log.info(`profile created for username: ${username}`); } catch (e) {