diff --git a/src/components/form/form-component.tsx b/src/components/form/form-component.tsx new file mode 100644 index 0000000..fa00227 --- /dev/null +++ b/src/components/form/form-component.tsx @@ -0,0 +1,138 @@ +import { FormColumn } from '@/types/form' +import { UIDataType } from '@/types/ui-data' +import React from 'react' +import { toast } from 'react-hot-toast' + +import { Input } from '@/components/input' + +export const getFormComponent = (column: FormColumn): React.ReactNode => { + if (!Object.values(UIDataType).includes(column.uidt)) { + return ( +

+ This system does not support {column.uidt}. +

+ ) + } + switch (column.uidt) { + case 'SingleLineText': + return ( + + ) + case 'PhoneNumber': + return ( + + ) + case 'Number': + return ( + + ) + case 'Checkbox': + return ( +
+ +
+ ) + case 'SingleSelect': + return ( +
+ +

+ จำเป็นต้องเลือก +

+
+ ) + case 'LongText': + return ( +
+