-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement contacts, languages, user input for staff user (#42)
Signed-off-by: maxwellgithinji <maxwellgithinji@gmail.com>
- Loading branch information
1 parent
17dc65f
commit dd76b3f
Showing
22 changed files
with
1,290 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package enums | ||
|
||
import ( | ||
"fmt" | ||
"io" | ||
"log" | ||
"strconv" | ||
) | ||
|
||
// ContactType is a list of all the contact types. | ||
type ContactType string | ||
|
||
// contacts type constants | ||
const ( | ||
PhoneContact ContactType = "PHONE" | ||
EmailContact ContactType = "EMAIL" | ||
) | ||
|
||
// AllContacts is a set of a valid and known contact types. | ||
var AllContacts = []ContactType{ | ||
PhoneContact, | ||
EmailContact, | ||
} | ||
|
||
// IsValid returns true if a contact is valid | ||
func (m ContactType) IsValid() bool { | ||
switch m { | ||
case PhoneContact, EmailContact: | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
func (m ContactType) String() string { | ||
return string(m) | ||
} | ||
|
||
// UnmarshalGQL converts the supplied value to a contact type. | ||
func (m *ContactType) UnmarshalGQL(v interface{}) error { | ||
str, ok := v.(string) | ||
if !ok { | ||
return fmt.Errorf("enums must be strings") | ||
} | ||
|
||
*m = ContactType(str) | ||
if !m.IsValid() { | ||
return fmt.Errorf("%s is not a valid ContactType", str) | ||
} | ||
return nil | ||
} | ||
|
||
// MarshalGQL writes the contact type to the supplied | ||
func (m ContactType) MarshalGQL(w io.Writer) { | ||
_, err := fmt.Fprint(w, strconv.Quote(m.String())) | ||
if err != nil { | ||
log.Printf("%v\n", err) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package enums | ||
|
||
import ( | ||
"fmt" | ||
) | ||
|
||
// UsersType is a list of all the user types. | ||
type UsersType string | ||
|
||
// contacts type constants | ||
const ( | ||
HealthcareWorkerUser UsersType = "HEALTHCAREWORKER" | ||
ClientUser UsersType = "CLIENT" | ||
) | ||
|
||
// AllUsers is a set of a valid and known user types. | ||
var AllUsers = []UsersType{ | ||
HealthcareWorkerUser, | ||
ClientUser, | ||
} | ||
|
||
// IsValid returns true if a user is valid | ||
func (m UsersType) IsValid() bool { | ||
switch m { | ||
case HealthcareWorkerUser, ClientUser: | ||
return true | ||
} | ||
return false | ||
} | ||
|
||
func (m UsersType) String() string { | ||
return string(m) | ||
} | ||
|
||
// UnmarshalGQL converts the supplied value to a user type. | ||
func (m *UsersType) UnmarshalGQL(v interface{}) error { | ||
str, ok := v.(string) | ||
if !ok { | ||
return fmt.Errorf("enums must be strings") | ||
} | ||
|
||
*m = UsersType(str) | ||
if !m.IsValid() { | ||
return fmt.Errorf("%s is not a valid UsersType", str) | ||
} | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.