Skip to content

Commit

Permalink
Prettified Code!
Browse files Browse the repository at this point in the history
  • Loading branch information
anthonyray authored and actions-user committed Mar 14, 2024
1 parent 4d1a9fa commit 77d1f27
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
2 changes: 1 addition & 1 deletion shared/src/types/employers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { DocumentReference, Timestamp } from 'firebase-admin/firestore';
import { Timestamp } from 'firebase-admin/firestore';

export const EMPLOYERS_FIRESTORE_PATH = 'employers';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { zodResolver } from '@hookform/resolvers/zod';
import { EMPLOYERS_FIRESTORE_PATH, Employer } from '@socialincome/shared/src/types/employers';
import { USER_FIRESTORE_PATH } from '@socialincome/shared/src/types/user';
import { Button, Form, FormControl, FormField, FormItem, FormMessage, Input } from '@socialincome/ui';
import { Timestamp, addDoc, collection, doc } from 'firebase/firestore';
import { Timestamp, addDoc, collection } from 'firebase/firestore';
import { useForm } from 'react-hook-form';
import { useFirestore } from 'reactfire';
import * as z from 'zod';
Expand Down Expand Up @@ -43,10 +43,12 @@ export function AddEmployerForm({ onNewEmployerSubmitted, translations }: AddEmp
created: Timestamp.now(),
};

await addDoc(collection(firestore, USER_FIRESTORE_PATH, user_id, EMPLOYERS_FIRESTORE_PATH), new_employer).then(() => {
form.reset();
onNewEmployerSubmitted();
});
await addDoc(collection(firestore, USER_FIRESTORE_PATH, user_id, EMPLOYERS_FIRESTORE_PATH), new_employer).then(
() => {
form.reset();
onNewEmployerSubmitted();
},
);
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ type EmployersListProps = {
} & DefaultParams;

type EmployerWithId = {
id: string
id: string;
} & Employer;

export function EmployersList({ translations }: EmployersListProps) {
Expand All @@ -51,7 +51,8 @@ export function EmployersList({ translations }: EmployersListProps) {
await deleteDoc(employerRef).then(() => onEmployersUpdated());
};

const onArchiveEmployer = async (employer_id: string) => { // Not leveraging type system ....
const onArchiveEmployer = async (employer_id: string) => {
// Not leveraging type system ....
const employerRef = doc(firestore, USER_FIRESTORE_PATH, user!.id, EMPLOYERS_FIRESTORE_PATH, employer_id);
await updateDoc(employerRef, { is_current: false }).then(() => onEmployersUpdated());
};
Expand All @@ -66,7 +67,7 @@ export function EmployersList({ translations }: EmployersListProps) {

const employers: EmployerWithId[] = data!.docs.map((e) => {
const employer: Employer = e.data() as Employer;
return { id: e.id, ...employer }
return { id: e.id, ...employer };
});
const currentEmployers: EmployerWithId[] = employers.filter((e) => e.is_current);
const pastEmployers: EmployerWithId[] = employers.filter((e) => !e.is_current);
Expand Down

0 comments on commit 77d1f27

Please sign in to comment.