Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
origranot committed Nov 2, 2024
1 parent eb3758b commit 2b2bfd6
Show file tree
Hide file tree
Showing 6 changed files with 1,040 additions and 1,306 deletions.
2 changes: 1 addition & 1 deletion apps/backend/src/core/users/dto/update.dto.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IsOptional, IsString, MaxLength, MinLength } from 'class-validator';
import { IsBase64, IsOptional, IsString, MaxLength, MinLength } from 'class-validator';

export class UpdateDto {
@IsOptional()
Expand Down
128 changes: 64 additions & 64 deletions apps/frontend/src/components/dashboard/links/link-modal/link-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,69 @@ interface CreateLinkInput {
utm_content?: string;
}

const CreateLinkInputSchema = z
.object({
url: z
.string({
required_error: "The url field can't be empty.",
})
.min(1, {
message: "The url field can't be empty.",
})
.regex(/^(?:https?:\/\/)?(?:[\w-]+\.)+[a-z]{2,}(?::\d{1,5})?(?:\/\S*)?$/, {
message: "The url you've entered is not valid",
}),
key: z
.string()
.max(20, { message: 'The short link cannot exceed 20 characters.' })
.regex(/^[a-zA-Z0-9-]*$/, {
message: 'The short link can only contain letters, numbers, and dashes.',
})
.optional()
.refine(
(val) => {
if (!val?.length) {
return true;
}
if (val?.length && val?.length < 4) {
return false;
}

return true;
},
{
message: 'The short link must be at least 4 characters long.',
}
),
expirationTime: z.string().optional(),
expirationTimeToggle: z.string().optional(),
passwordProtection: z
.string()
.min(6, {
message: 'Password must be at least 6 characters long.',
})
.max(25, {
message: 'Password must be at most 25 characters long.',
})
.optional(),
passwordProtectionToggle: z.string().optional(),
utmBuilderToggle: z.string().optional(),
utm_ref: z.string().max(100, { message: 'Referral (ref) must be at most 100 characters long' }).optional(),
utm_source: z.string().max(100, { message: 'UTM Source must be at most 100 characters long' }).optional(),
utm_medium: z.string().max(100, { message: 'UTM Medium must be at most 100 characters long' }).optional(),
utm_campaign: z.string().max(100, { message: 'UTM Campaign must be at most 100 characters long' }).optional(),
utm_term: z.string().max(100, { message: 'UTM Term must be at most 100 characters long' }).optional(),
utm_content: z.string().max(100, { message: 'UTM Content must be at most 100 characters long' }).optional(),
})
.refine((data) => !(data.expirationTimeToggle && !data.expirationTime), {
message: 'Please select a date for your link to expire.',
path: ['expirationTime'],
})
.refine((data) => !(data.passwordProtectionToggle && !data.passwordProtection), {
message: 'Please enter a password for your link.',
path: ['passwordProtection'],
});

type FieldErrors = Partial<Record<keyof CreateLinkInput, string[]>>;

const useCreateLink = globalAction$(
Expand Down Expand Up @@ -101,70 +164,7 @@ const useCreateLink = globalAction$(
key: data.key,
};
},
zod$((z) =>
z
.object({
url: z
.string({
required_error: "The url field can't be empty.",
})
.min(1, {
message: "The url field can't be empty.",
})
.regex(/^(?:https?:\/\/)?(?:[\w-]+\.)+[a-z]{2,}(?::\d{1,5})?(?:\/\S*)?$/, {
message: "The url you've entered is not valid",
}),
key: z
.string()
.max(20, { message: 'The short link cannot exceed 20 characters.' })
.regex(/^[a-zA-Z0-9-]*$/, {
message: 'The short link can only contain letters, numbers, and dashes.',
})
.optional()
.refine(
(val) => {
if (!val?.length) {
return true;
}
if (val?.length && val?.length < 4) {
return false;
}

return true;
},
{
message: 'The short link must be at least 4 characters long.',
}
),
expirationTime: z.string().optional(),
expirationTimeToggle: z.string().optional(),
passwordProtection: z
.string()
.min(6, {
message: 'Password must be at least 6 characters long.',
})
.max(25, {
message: 'Password must be at most 25 characters long.',
})
.optional(),
passwordProtectionToggle: z.string().optional(),
utmBuilderToggle: z.string().optional(),
utm_ref: z.string().max(100, { message: 'Referral (ref) must be at most 100 characters long' }).optional(),
utm_source: z.string().max(100, { message: 'UTM Source must be at most 100 characters long' }).optional(),
utm_medium: z.string().max(100, { message: 'UTM Medium must be at most 100 characters long' }).optional(),
utm_campaign: z.string().max(100, { message: 'UTM Campaign must be at most 100 characters long' }).optional(),
utm_term: z.string().max(100, { message: 'UTM Term must be at most 100 characters long' }).optional(),
utm_content: z.string().max(100, { message: 'UTM Content must be at most 100 characters long' }).optional(),
})
.refine((data) => !(data.expirationTimeToggle && !data.expirationTime), {
message: 'Please select a date for your link to expire.',
path: ['expirationTime'],
})
.refine((data) => !(data.passwordProtectionToggle && !data.passwordProtection), {
message: 'Please enter a password for your link.',
path: ['passwordProtection'],
})
)
zod$(CreateLinkInputSchema)
);

export interface LinkModalProps {
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/src/routes/dashboard/settings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export const updateProfile = globalAction$(
message: 'Display name must be less than 25 characters',
}),
profilePicture: z
.string()
.any()
.optional()
.transform((value) => {
// If value is not base 64 return undefined
Expand Down
2 changes: 2 additions & 0 deletions apps/frontend/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { qwikVite } from '@builder.io/qwik/optimizer';
import { qwikCity } from '@builder.io/qwik-city/vite';
import { defineConfig, loadEnv } from 'vite';
import tsconfigPaths from 'vite-tsconfig-paths';
import { qwikNxVite } from 'qwik-nx/plugins';
import path from 'path';

export default defineConfig(({ mode }) => {
Expand All @@ -14,6 +15,7 @@ export default defineConfig(({ mode }) => {
},
cacheDir: '../../node_modules/.vite/apps/frontend',
plugins: [
qwikNxVite(),
qwikCity(),
qwikVite({
client: {
Expand Down
Loading

0 comments on commit 2b2bfd6

Please sign in to comment.