> = {}) {
const {
- event = "onChange"
+ event = "onChange",
+ property = "value",
} = options;
return (
field: P,
extractor: (...args: TArgs) => T[P] = ((event: DOMEvent) => event.target.value as unknown as T[P]) as any
) => ({
- value: subject[field],
+ [property]: subject[field],
[event]: (...args: TArgs) => update({
...subject,
[field]: extractor(...args),
} as T)
})
}
+
+
+export type BoundProperty =
+ { [property in TProperty]: T; } &
+ { [event in TEvent]: (value: T) => void; }
diff --git a/src/provider/dummy/company.ts b/src/provider/dummy/company.ts
index df684dd..a1c0848 100644
--- a/src/provider/dummy/company.ts
+++ b/src/provider/dummy/company.ts
@@ -4,9 +4,8 @@ import { makeIdSequence } from "./helpers";
const companySequence = makeIdSequence();
const officeSequence = makeIdSequence();
-export const sampleCompanies: Company[] = [
+export const sampleCompanies: Company[] = companySequence.assignIds([
{
- id: companySequence(),
name: "Intel",
url: "https://www.intel.com/content/www/us/en/jobs/locations/poland.html",
nip: "9570752316",
@@ -22,7 +21,6 @@ export const sampleCompanies: Company[] = [
}]
},
{
- id: companySequence(),
name: "IHS Markit",
url: "http://ihsgdansk.com/",
nip: "5842068320",
@@ -38,12 +36,10 @@ export const sampleCompanies: Company[] = [
}]
},
{
- id: companySequence(),
name: "Asseco Poland",
url: "http://pl.asseco.com/",
nip: "5842068320",
- offices: [{
- id: officeSequence(),
+ offices: officeSequence.assignIds([{
address: {
city: "Gdynia",
street: "ul. Podolska",
@@ -52,7 +48,6 @@ export const sampleCompanies: Company[] = [
country: "Poland"
}
}, {
- id: officeSequence(),
address: {
city: "Łódź",
street: "al. Marszałka Józefa Piłsudskiego",
@@ -61,7 +56,6 @@ export const sampleCompanies: Company[] = [
country: "Poland"
}
}, {
- id: officeSequence(),
address: {
city: "Wrocław",
street: "Traugutta",
@@ -69,6 +63,6 @@ export const sampleCompanies: Company[] = [
postalCode: "50-449",
country: "Poland"
}
- }]
+ }])
}
-]
+])
diff --git a/src/provider/dummy/internship.ts b/src/provider/dummy/internship.ts
index 99ab50f..9d86cc1 100644
--- a/src/provider/dummy/internship.ts
+++ b/src/provider/dummy/internship.ts
@@ -1,5 +1,12 @@
import { Nullable } from "@/helpers";
-import { Internship, InternshipType } from "@/data";
+import { emptyCompany, Internship, Mentor } from "@/data";
+
+export const emptyMentor: Mentor = {
+ phone: null,
+ email: "",
+ name: "",
+ surname: ""
+}
export const emptyInternship: Nullable = {
intern: null,
@@ -9,4 +16,6 @@ export const emptyInternship: Nullable = {
program: null,
isAccepted: false,
lengthInWeeks: 0,
+ mentor: emptyMentor,
+ company: emptyCompany,
}