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
export const COUNTRIES = [ | |
{ code: 'AF', name: 'Afghanistan', dialCode: '+93', flag: '🇦🇫' }, | |
{ code: 'AL', name: 'Albania', dialCode: '+355', flag: '🇦🇱' }, | |
{ code: 'DZ', name: 'Algeria', dialCode: '+213', flag: '🇩🇿' }, | |
{ code: 'AD', name: 'Andorra', dialCode: '+376', flag: '🇦🇩' }, | |
{ code: 'AO', name: 'Angola', dialCode: '+244', flag: '🇦🇴' }, | |
{ code: 'AG', name: 'Antigua and Barbuda', dialCode: '+1-268', flag: '🇦🇬' }, | |
{ code: 'AR', name: 'Argentina', dialCode: '+54', flag: '🇦🇷' }, | |
{ code: 'AM', name: 'Armenia', dialCode: '+374', flag: '🇦🇲' }, | |
{ code: 'AU', name: 'Australia', dialCode: '+61', flag: '🇦🇺' }, |
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
// +page.server.ts | |
import { env } from '$env/dynamic/private'; | |
import type { ValidationErrors } from '$lib/types/form-validation'; | |
//git clone https://gist.github.com/1661f024493c3de8e014cd9498d6c978.git (to get validateForm utility) | |
import { validateForm } from '$lib/utils/form-validation.js'; | |
import { Resend } from 'resend'; | |
const resend = new Resend(env.PRIVATE_RESEND_KEY); | |
function extractAndValidate(formData: FormData) { | |
const values = { | |
message: formData.get('message')?.toString() || '', |
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
import type { ValidationErrors, ValidationValues } from '../../ambient'; | |
export function validateForm(values: Partial<ValidationValues>): ValidationErrors { | |
const errors: ValidationErrors = {}; | |
// Message Validation | |
if ('message' in values) { | |
if (!values.message) { | |
errors.message = 'Please provide a message'; | |
} else if (values.message.trim().length < 50 || values.message.trim().length > 5000) { | |
errors.message = 'Message must be between 50 and 5000 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
<script lang="ts"> | |
import type { FormInputProps } from '../../../ambient'; | |
let { | |
id, | |
label, | |
type = 'text', | |
value = $bindable(''), | |
error = '', | |
placeholder = '' |
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
// src/routes/api/presigned-url/+server.ts | |
import type { RequestHandler } from '@sveltejs/kit'; | |
import { PutObjectCommand } from '@aws-sdk/client-s3'; | |
import { getSignedUrl } from '@aws-sdk/s3-request-presigner'; | |
import { s3Client, S3_BUCKET_NAME } from '$lib/config/s3'; | |
export const POST: RequestHandler = async ({ request }) => { | |
try { | |
const { fileName, fileType } = await request.json(); |
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
import {Root} from '@radix-ui/react-label'; | |
import { cva, type VariantProps } from "class-variance-authority" | |
import { useState } from 'react'; | |
import { PhoneInput } from 'react-international-phone'; | |
import 'react-international-phone/style.css'; | |
import { twMerge } from "tailwind-merge" | |
const field = cva( | |
[ | |
"flex", | |
"flex-wrap", |
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
{ | |
"singleQuote": true, | |
"trailingComma": "all", | |
"endOfLine":"auto" | |
} |
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
module.exports = { | |
parser: '@typescript-eslint/parser', | |
parserOptions: { | |
project: 'tsconfig.json', | |
tsconfigRootDir: __dirname, | |
sourceType: 'module', | |
}, | |
plugins: ['@typescript-eslint/eslint-plugin'], | |
extends: [ | |
'plugin:@typescript-eslint/recommended', |