Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ADD] User Achievement Contracts #15

Merged
merged 4 commits into from
Jul 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions contracts/users/UserAchievement.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import {Timestamp} from 'firebase/firestore';
import {z} from 'zod';

/**
* @interface UserAchievement
* @description Represents an achievement of a user.
*
* @property {string} title - The title of the achievement.
* @property {string} date_awarded - The date when the achievement was awarded (in YYYY-MM-DD format).
* @property {string} description - A brief description of the achievement.
*
* @example
* // Example usage:
* const achievement: UserAchievement = {
* title: 'Best Student Award',
* date_awarded: '2023-06-15',
* description: 'Awarded for outstanding academic performance.'
* };
*
* @remarks
* This interface can be extended to include more achievement-related information
* as needed for various applications.
*
* @since 1.0.0
*/

export interface UserAchievement {
title: string;
issued_date: Timestamp;
description: string;
}

export const UserAchievementSchema: z.ZodSchema<UserAchievement> = z.object({
title: z.string({
required_error: 'Title is required',
invalid_type_error: 'Title must be a string',
}),
issued_date: z
.instanceof(Timestamp)
.refine((item) => item instanceof Timestamp, {
message: 'Date awarded must be an instance of Timestamp',
}),
description: z.string({
required_error: 'Description is required',
invalid_type_error: 'Description must be a string',
}),
});
1 change: 1 addition & 0 deletions frontend/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import './App.css';

export const App = () => {
return (
<div>
Expand Down
47 changes: 47 additions & 0 deletions frontend/src/contracts/users/UserAchievement.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import {Timestamp} from 'firebase/firestore';
import {z} from 'zod';

/**
* @interface UserAchievement
* @description Represents an achievement of a user.
*
* @property {string} title - The title of the achievement.
* @property {string} date_awarded - The date when the achievement was awarded (in YYYY-MM-DD format).
* @property {string} description - A brief description of the achievement.
*
* @example
* // Example usage:
* const achievement: UserAchievement = {
* title: 'Best Student Award',
* date_awarded: '2023-06-15',
* description: 'Awarded for outstanding academic performance.'
* };
*
* @remarks
* This interface can be extended to include more achievement-related information
* as needed for various applications.
*
* @since 1.0.0
*/

export interface UserAchievement {
title: string;
issued_date: Timestamp;
description: string;
}

export const UserAchievementSchema: z.ZodSchema<UserAchievement> = z.object({
title: z.string({
required_error: 'Title is required',
invalid_type_error: 'Title must be a string',
}),
issued_date: z
.instanceof(Timestamp)
.refine((item) => item instanceof Timestamp, {
message: 'Date awarded must be an instance of Timestamp',
}),
description: z.string({
required_error: 'Description is required',
invalid_type_error: 'Description must be a string',
}),
});
47 changes: 47 additions & 0 deletions functions/src/contracts/users/UserAchievement.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import {Timestamp} from 'firebase/firestore';
import {z} from 'zod';

/**
* @interface UserAchievement
* @description Represents an achievement of a user.
*
* @property {string} title - The title of the achievement.
* @property {string} date_awarded - The date when the achievement was awarded (in YYYY-MM-DD format).
* @property {string} description - A brief description of the achievement.
*
* @example
* // Example usage:
* const achievement: UserAchievement = {
* title: 'Best Student Award',
* date_awarded: '2023-06-15',
* description: 'Awarded for outstanding academic performance.'
* };
*
* @remarks
* This interface can be extended to include more achievement-related information
* as needed for various applications.
*
* @since 1.0.0
*/

export interface UserAchievement {
title: string;
issued_date: Timestamp;
description: string;
}

export const UserAchievementSchema: z.ZodSchema<UserAchievement> = z.object({
title: z.string({
required_error: 'Title is required',
invalid_type_error: 'Title must be a string',
}),
issued_date: z
.instanceof(Timestamp)
.refine((item) => item instanceof Timestamp, {
message: 'Date awarded must be an instance of Timestamp',
}),
description: z.string({
required_error: 'Description is required',
invalid_type_error: 'Description must be a string',
}),
});