Skip to content

Commit

Permalink
Chore/update types (#77)
Browse files Browse the repository at this point in the history
* Rename types

* Add `created_by` to types

* Rename table names and types

* Add `nonce` attribute
  • Loading branch information
carlomigueldy committed Nov 22, 2021
1 parent d763ce0 commit 95eda9b
Show file tree
Hide file tree
Showing 9 changed files with 38 additions and 27 deletions.
5 changes: 1 addition & 4 deletions client/hooks/useAuth.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import { useEthers } from '@usedapp/core';
import React from 'react';
import { User } from '../types';

type User = {
id: string;
nonce: string;
};
type UserPayload = { user: User | null; setUser: React.Dispatch<User | null> };

const AuthContext = React.createContext<UserPayload | null>(null);
Expand Down
13 changes: 8 additions & 5 deletions client/types/common.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
export type Table =
| 'users'
| 'user_category'
| 'user_keyword'
| 'organizations'
| 'jobs'
| 'job_category'
| 'job_keyword'
| 'job_applications'
| 'gigs'
| 'gig_category'
| 'gig_keyword'
| 'gig_applications'
| 'categories'
| 'company_members'
| 'keywords'
| 'organization_members'
| 'links';

export type WithTimestamp = {
Expand All @@ -32,6 +33,7 @@ export type Application = {
};

/**
* @description
* Status indicator for job/gig applications.
*
* Default status should always be "Draft"
Expand All @@ -49,6 +51,7 @@ export enum ApplicationStatus {
}

/**
* @description
* Status for job/gig postings.
*
* Default status should always be "Draft"
Expand Down
5 changes: 3 additions & 2 deletions client/types/gig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@ export type GigForm = Pick<
| 'featured_photo_url'
| 'experience_level'
| 'status'
| 'created_by'
>;

export type GigCategory = {
export type GigKeyword = {
gig_id: string;
category_id: string;
} & WithTimestamp;
Expand All @@ -40,5 +41,5 @@ export type GigApplication = PrimaryKey & {

export type GigApplicationForm = Pick<
GigApplication,
'gig_id' | 'pitch' | 'content' | 'status'
'gig_id' | 'pitch' | 'content' | 'status' | 'created_by'
>;
3 changes: 2 additions & 1 deletion client/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './common';
export * from './company';
export * from './organization';
export * from './gig';
export * from './job';
export * from './link';
export * from './keyword';
export * from './user';
5 changes: 3 additions & 2 deletions client/types/job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ export type JobForm = Pick<
| 'opportunity'
| 'featured_photo_url'
| 'status'
| 'created_by'
>;

export type JobCategory = {
export type JobKeyword = {
job_id: string;
category_id: string;
} & WithTimestamp;
Expand All @@ -41,5 +42,5 @@ export type JobApplication = PrimaryKey & {

export type JobApplicationForm = Pick<
JobApplication,
'job_id' | 'pitch' | 'content' | 'status'
'job_id' | 'pitch' | 'content' | 'status' | 'created_by'
>;
7 changes: 7 additions & 0 deletions client/types/keyword.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { PrimaryKey, WithTimestamp } from '.';

export type Keyword = PrimaryKey & {
name: string;
} & WithTimestamp;

export type KeywordForm = Pick<Keyword, 'name'>;
1 change: 1 addition & 0 deletions client/types/link.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@ export type LinkForm = Pick<
| 'type'
| 'url'
| 'featured_photo_url'
| 'created_by'
>;
15 changes: 10 additions & 5 deletions client/types/company.ts → client/types/organization.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { CreatedBy, PrimaryKey, WithTimestamp } from './common';

export type Company = PrimaryKey & {
export type Organization = PrimaryKey & {
name: string;
email: string;
description: string;
Expand All @@ -9,12 +9,17 @@ export type Company = PrimaryKey & {
} & WithTimestamp &
CreatedBy;

export type CompanyMember = {
export type OrganizationMember = {
company_id: string;
user_id: string;
} & WithTimestamp;

export type CompanyForm = Pick<
Company,
'cover_photo_url' | 'description' | 'email' | 'logo_url' | 'name'
export type OrganizationForm = Pick<
Organization,
| 'cover_photo_url'
| 'description'
| 'email'
| 'logo_url'
| 'name'
| 'created_by'
>;
11 changes: 3 additions & 8 deletions client/types/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,19 @@ import { PrimaryKey, WithTimestamp } from './common';
export type User = PrimaryKey & {
avatar_url?: string;
cover_photo_url?: string;
nonce?: string;
email: string;
username?: string;
preferences?: string;
wallet_address?: string;
disabled_at?: Date;
} & WithTimestamp;

export type UserCategory = {
export type UserKeyword = {
user_id: string;
category_id: string;
} & WithTimestamp;

export type UserForm = Pick<
User,
| 'avatar_url'
| 'cover_photo_url'
| 'email'
| 'username'
| 'preferences'
| 'wallet_address'
'avatar_url' | 'cover_photo_url' | 'email' | 'username' | 'preferences'
>;

1 comment on commit 95eda9b

@vercel
Copy link

@vercel vercel bot commented on 95eda9b Nov 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.