-
-
Notifications
You must be signed in to change notification settings - Fork 42
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 #165 from complexdatacollective/next
v2.0.0
- Loading branch information
Showing
83 changed files
with
2,426 additions
and
1,462 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
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,51 +1,50 @@ | ||
'use server'; | ||
|
||
import { redirect } from 'next/navigation'; | ||
import { type z } from 'zod'; | ||
import { safeRevalidateTag } from '~/lib/cache'; | ||
import { type AppSetting, appSettingsSchema } from '~/schemas/appSettings'; | ||
import { requireApiAuth } from '~/utils/auth'; | ||
import { prisma } from '~/utils/db'; | ||
import { ensureError } from '~/utils/ensureError'; | ||
|
||
export async function setAnonymousRecruitment(input: boolean) { | ||
await requireApiAuth(); | ||
|
||
await prisma.appSettings.updateMany({ | ||
data: { | ||
allowAnonymousRecruitment: input, | ||
}, | ||
}); | ||
|
||
safeRevalidateTag('allowAnonymousRecruitment'); | ||
|
||
return input; | ||
} | ||
// Convert string | boolean | Date to string | ||
const getStringValue = (value: string | boolean | Date) => { | ||
if (typeof value === 'boolean') return value.toString(); | ||
if (value instanceof Date) return value.toISOString(); | ||
return value; | ||
}; | ||
|
||
export async function setLimitInterviews(input: boolean) { | ||
export async function setAppSetting< | ||
Key extends AppSetting, | ||
V extends z.infer<typeof appSettingsSchema>[Key], | ||
>(key: Key, value: V): Promise<V> { | ||
await requireApiAuth(); | ||
await prisma.appSettings.updateMany({ | ||
data: { | ||
limitInterviews: input, | ||
}, | ||
}); | ||
|
||
safeRevalidateTag('limitInterviews'); | ||
|
||
return input; | ||
} | ||
|
||
export const setAppConfigured = async () => { | ||
await requireApiAuth(); | ||
if (!appSettingsSchema.shape[key]) { | ||
throw new Error(`Invalid app setting: ${key}`); | ||
} | ||
|
||
try { | ||
await prisma.appSettings.updateMany({ | ||
data: { | ||
configured: true, | ||
}, | ||
const result = appSettingsSchema.shape[key].parse(value); | ||
const stringValue = getStringValue(result); | ||
|
||
await prisma.appSettings.upsert({ | ||
where: { key }, | ||
create: { key, value: stringValue }, | ||
update: { value: stringValue }, | ||
}); | ||
|
||
safeRevalidateTag('appSettings'); | ||
safeRevalidateTag(`appSettings-${key}`); | ||
|
||
return value; | ||
} catch (error) { | ||
return { error: 'Failed to update appSettings', appSettings: null }; | ||
const e = ensureError(error); | ||
throw new Error(`Failed to update appSettings: ${key}: ${e.message}`); | ||
} | ||
} | ||
|
||
redirect('/dashboard'); | ||
}; | ||
export async function submitUploadThingForm(token: string) { | ||
await setAppSetting('uploadThingToken', token); | ||
redirect('/setup?step=3'); | ||
} |
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
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
59 changes: 59 additions & 0 deletions
59
app/(blobs)/(setup)/_components/OnboardSteps/ConnectUploadThing.tsx
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,59 @@ | ||
import { submitUploadThingForm } from '~/actions/appSettings'; | ||
import Link from '~/components/Link'; | ||
import { Alert, AlertDescription, AlertTitle } from '~/components/ui/Alert'; | ||
import Heading from '~/components/ui/typography/Heading'; | ||
import Paragraph from '~/components/ui/typography/Paragraph'; | ||
import { UploadThingTokenForm } from '../UploadThingTokenForm'; | ||
|
||
function ConnectUploadThing() { | ||
return ( | ||
<div className="w-[30rem]"> | ||
<div className="mb-4"> | ||
<Heading variant="h2">Connect UploadThing</Heading> | ||
<Paragraph> | ||
Fresco uses a third-party service called UploadThing to store media | ||
files, including protocol assets. In order to use this service, you | ||
need to create an account with UploadThing that will allow you to | ||
generate a token that Fresco can use to securely communicate with it. | ||
</Paragraph> | ||
<Paragraph> | ||
<Link | ||
href="https://uploadthing.com/dashboard/new" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Click here | ||
</Link>{' '} | ||
to visit UploadThing. Create an app and copy and paste your API key | ||
below. | ||
</Paragraph> | ||
<Alert variant="info" className="mt-4"> | ||
<AlertTitle>Good to know:</AlertTitle> | ||
<AlertDescription> | ||
Your UploadThing account is unique to you, meaning that no one else | ||
will have access to the files stored in your instance of Fresco. For | ||
more information about UploadThing, please review the{' '} | ||
<Link href="https://docs.uploadthing.com/" target="_blank"> | ||
UploadThing Docs | ||
</Link> | ||
. | ||
</AlertDescription> | ||
</Alert> | ||
<Paragraph> | ||
For help, please refer to the{' '} | ||
<Link | ||
href="https://documentation.networkcanvas.com/en/fresco/deployment/guide#create-a-storage-bucket-using-uploadthing" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
deployment guide | ||
</Link>{' '} | ||
in the Fresco documentation. | ||
</Paragraph> | ||
<UploadThingTokenForm action={submitUploadThingForm} /> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
export default ConnectUploadThing; |
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
Oops, something went wrong.